Skip to content

Commit

Permalink
Small changes to code
Browse files Browse the repository at this point in the history
  • Loading branch information
appilon committed Feb 11, 2022
1 parent 18f93b1 commit 8841601
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
27 changes: 13 additions & 14 deletions vsphere/data_source_vsphere_license.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ func dataSourceVSphereLicense() *schema.Resource {
"license_key": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"labels": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},

// computed properties returned by the API
"id": {
Type: schema.TypeString,
Computed: true,
},
"labels": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"edition_key": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -55,16 +54,16 @@ func dataSourceVSphereLicenseRead(d *schema.ResourceData, meta interface{}) erro
licenseKey := d.Get("license_key").(string)
if info := getLicenseInfoFromKey(d.Get("license_key").(string), manager); info != nil {
log.Println("[INFO] Setting the values")
_ = d.Set("edition_key", info.EditionKey)
_ = d.Set("total", info.Total)
_ = d.Set("used", info.Used)
_ = d.Set("name", info.Name)
_ = d.Set("labels", keyValuesToMap(info.Labels))
d.Set("edition_key", info.EditionKey)
d.Set("total", info.Total)
d.Set("used", info.Used)
d.Set("name", info.Name)
if err := d.Set("labels", keyValuesToMap(info.Labels)); err != nil {
return err
}
d.SetId(licenseKey)

return nil
} else {
return ErrNoSuchKeyFound
}

return nil
}
6 changes: 1 addition & 5 deletions vsphere/data_source_vsphere_license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ func testAccDataSourceVSphereLicensePreCheck(t *testing.T) {

func testAccDataSourceVSphereLicenseConfig() string {
return fmt.Sprintf(`
data "vsphere_datacenter" "dc" {
name = "%s"
}
data "vsphere_license" "license" {
license_key = "%s"
}
`, os.Getenv("TF_VAR_VSPHERE_DATACENTER"), os.Getenv("TF_VAR_VSPHERE_LICENSE"))
`, os.Getenv("TF_VAR_VSPHERE_LICENSE"))
}

0 comments on commit 8841601

Please # to comment.