Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .changes/v1.0.0/12-features.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- **New Resource:** `vcfa_content_library` to manage Content Libraries [GH-12, GH-42, GH-43, GH-50, GH-53, GH-62, GH-69]
- **New Data Source:** `vcfa_content_library` to read Content Libraries [GH-12, GH-42, GH-50, GH-53, GH-62, GH-69, GH-70]
- **New Resource:** `vcfa_content_library` to manage Content Libraries [GH-12, GH-42, GH-43, GH-50, GH-53, GH-62, GH-69, GH-72]
- **New Data Source:** `vcfa_content_library` to read Content Libraries [GH-12, GH-42, GH-50, GH-53, GH-62, GH-69, GH-70, GH-72]
- **New Data Source:** `vcfa_region_storage_policy` to read Region Storage Policies [GH-12]
- **New Data Source:** `vcfa_storage_class` to read Storage Classes [GH-12]
18 changes: 11 additions & 7 deletions vcfa/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const (
envSecondVcfaSysOrg = "VCFA_SYSORG2"
)

// vsphereProviderVersion specifies the version of vSphere Terraform Provider
var vsphereProviderVersion = "~> 2.11"

func init() {

// To list the flags when we run "go test -tags functional -vcfa-help", the flag name must start with "vcfa"
Expand Down Expand Up @@ -101,13 +104,12 @@ type TestConfig struct {
SupervisorZone string `json:"supervisorZone"`
} `json:"cci"`
Tm struct {
Org string `json:"org"`
CreateRegion bool `json:"createRegion"`
Region string `json:"region"`
StorageClass string `json:"storageClass"`
RegionVmClasses []string `json:"regionVmClasses"`
ContentLibrary string `json:"contentLibrary"`
SubscriptionContentLibraryUrl string `json:"subscriptionContentLibraryUrl"`
Org string `json:"org"`
CreateRegion bool `json:"createRegion"`
Region string `json:"region"`
StorageClass string `json:"storageClass"`
RegionVmClasses []string `json:"regionVmClasses"`
ContentLibrary string `json:"contentLibrary"`

CreateNsxManager bool `json:"createNsxManager"`
NsxManagerUsername string `json:"nsxManagerUsername"`
Expand All @@ -121,6 +123,8 @@ type TestConfig struct {
VcenterUsername string `json:"vcenterUsername"`
VcenterPassword string `json:"vcenterPassword"`
VcenterUrl string `json:"vcenterUrl"`
VcenterDatacenter string `json:"vcenterDatacenter"`
VcenterDatastore string `json:"vcenterDatastore"`
VcenterStorageProfile string `json:"vcenterStorageProfile"`
VcenterSupervisor string `json:"vcenterSupervisor"`
VcenterSupervisorZone string `json:"vcenterSupervisorZone"`
Expand Down
9 changes: 3 additions & 6 deletions vcfa/datasource_vcfa_content_library.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ func datasourceVcfaContentLibrary() *schema.Resource {
Computed: true,
Description: fmt.Sprintf("Subscription url of this %s", labelVcfaContentLibrary),
},
"password": {
Type: schema.TypeString,
Computed: true,
Description: "Password to use to authenticate with the publisher",
},
},
},
},
Expand All @@ -103,7 +98,9 @@ func datasourceVcfaContentLibraryRead(ctx context.Context, d *schema.ResourceDat
}
return tmClient.GetContentLibraryByName(name, tenantContext)
},
stateStoreFunc: setContentLibraryData,
stateStoreFunc: func(tmClient *VCDClient, d *schema.ResourceData, outerType *govcd.ContentLibrary) error {
return setContentLibraryData(tmClient, d, outerType, "datasource")
},
}
return readDatasource(ctx, d, meta, c)
}
21 changes: 14 additions & 7 deletions vcfa/resource_vcfa_content_library.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,19 @@ func resourceVcfaContentLibrary() *schema.Resource {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
ForceNew: true, // Can't change subscription settings
Description: fmt.Sprintf("A block representing subscription settings of a %s", labelVcfaContentLibrary),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"subscription_url": {
Type: schema.TypeString,
Required: true,
ForceNew: true, // Can't change subscription url
Description: fmt.Sprintf("Subscription url of this %s", labelVcfaContentLibrary),
},
"password": {
Type: schema.TypeString,
Optional: true, // Required at Runtime as cannot be Required + Computed in schema. (It is computed as password cannot be recovered)
Computed: true,
Optional: true,
Sensitive: true,
Description: "Password to use to authenticate with the publisher",
},
},
Expand All @@ -133,7 +133,7 @@ func resourceVcfaContentLibraryCreate(ctx context.Context, d *schema.ResourceDat
if err != nil {
return diag.FromErr(err)
}
err = setContentLibraryData(tmClient, d, cl)
err = setContentLibraryData(tmClient, d, cl, "resource")
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func resourceVcfaContentLibraryRead(_ context.Context, d *schema.ResourceData, m
return diag.FromErr(err)
}

err = setContentLibraryData(tmClient, d, cl)
err = setContentLibraryData(tmClient, d, cl, "resource")
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -261,7 +261,7 @@ func getContentLibraryType(d *schema.ResourceData) *types.ContentLibrary {
return t
}

func setContentLibraryData(_ *VCDClient, d *schema.ResourceData, cl *govcd.ContentLibrary) error {
func setContentLibraryData(_ *VCDClient, d *schema.ResourceData, cl *govcd.ContentLibrary, origin string) error {
if cl == nil || cl.ContentLibrary == nil {
return fmt.Errorf("provided %s is nil", labelVcfaContentLibrary)
}
Expand Down Expand Up @@ -292,10 +292,17 @@ func setContentLibraryData(_ *VCDClient, d *schema.ResourceData, cl *govcd.Conte
subscriptionConfig = []interface{}{
map[string]interface{}{
"subscription_url": cl.ContentLibrary.SubscriptionConfig.SubscriptionUrl,
"password": cl.ContentLibrary.SubscriptionConfig.Password,
},
}
// Password is only available in resource
if origin == "resource" {
// Password is never returned by backend. We save what we have currently
if p := d.Get("subscription_config.0.password"); p != "" {
subscriptionConfig[0].(map[string]interface{})["password"] = p
}
}
}

err = d.Set("subscription_config", subscriptionConfig)
if err != nil {
return err
Expand Down
Loading