-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retrieves the version of the manager datasource. Signed-off-by: Kobi Samoray <[email protected]>
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* Copyright © 2024 Broadcom, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 */ | ||
|
||
package nsxt | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
const nsxVersionId = "nsxversion" | ||
|
||
func dataSourceNsxtVersion() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceNsxtVersionRead, | ||
Schema: map[string]*schema.Schema{ | ||
"version": { | ||
Type: schema.TypeString, | ||
Description: "Version of NSXT manager", | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceNsxtVersionRead(d *schema.ResourceData, m interface{}) error { | ||
connector := getPolicyConnector(m) | ||
version, err := getNSXVersion(connector) | ||
if err != nil { | ||
return fmt.Errorf("failed to retrieve NSX version: %v", err) | ||
} | ||
d.Set("version", version) | ||
d.SetId(nsxVersionId) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Copyright © 2024 Broadcom, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 */ | ||
|
||
package nsxt | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceNsxtVersion_basic(t *testing.T) { | ||
testResourceName := "data.nsxt_version.test" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: ` | ||
data "nsxt_version" "test" { | ||
}`, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(testResourceName, "version"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
subcategory: "Manager" | ||
layout: "nsxt" | ||
page_title: "nsxt_version" | ||
description: A NSX-T version data source. | ||
--- | ||
|
||
# nsxt_version | ||
|
||
This data source provides the version of the NSX-T manager. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "nsxt_version" "cluster" {} | ||
``` | ||
|
||
## Attributes Reference | ||
|
||
* `version` - The software version of the NSX-T manager node. |