@@ -96,19 +96,19 @@ func resourceVcfaContentLibrary() *schema.Resource {
9696 Type : schema .TypeList ,
9797 MaxItems : 1 ,
9898 Optional : true ,
99- ForceNew : true , // Can't change subscription settings
10099 Description : fmt .Sprintf ("A block representing subscription settings of a %s" , labelVcfaContentLibrary ),
101100 Elem : & schema.Resource {
102101 Schema : map [string ]* schema.Schema {
103102 "subscription_url" : {
104103 Type : schema .TypeString ,
105104 Required : true ,
105+ ForceNew : true , // Can't change subscription url
106106 Description : fmt .Sprintf ("Subscription url of this %s" , labelVcfaContentLibrary ),
107107 },
108108 "password" : {
109109 Type : schema .TypeString ,
110- Optional : true , // Required at Runtime as cannot be Required + Computed in schema. (It is computed as password cannot be recovered)
111- Computed : true ,
110+ Optional : true ,
111+ Sensitive : true ,
112112 Description : "Password to use to authenticate with the publisher" ,
113113 },
114114 },
@@ -133,7 +133,7 @@ func resourceVcfaContentLibraryCreate(ctx context.Context, d *schema.ResourceDat
133133 if err != nil {
134134 return diag .FromErr (err )
135135 }
136- err = setContentLibraryData (tmClient , d , cl )
136+ err = setContentLibraryData (tmClient , d , cl , "resource" )
137137 if err != nil {
138138 return diag .FromErr (err )
139139 }
@@ -163,7 +163,7 @@ func resourceVcfaContentLibraryRead(_ context.Context, d *schema.ResourceData, m
163163 return diag .FromErr (err )
164164 }
165165
166- err = setContentLibraryData (tmClient , d , cl )
166+ err = setContentLibraryData (tmClient , d , cl , "resource" )
167167 if err != nil {
168168 return diag .FromErr (err )
169169 }
@@ -261,7 +261,7 @@ func getContentLibraryType(d *schema.ResourceData) *types.ContentLibrary {
261261 return t
262262}
263263
264- func setContentLibraryData (_ * VCDClient , d * schema.ResourceData , cl * govcd.ContentLibrary ) error {
264+ func setContentLibraryData (_ * VCDClient , d * schema.ResourceData , cl * govcd.ContentLibrary , origin string ) error {
265265 if cl == nil || cl .ContentLibrary == nil {
266266 return fmt .Errorf ("provided %s is nil" , labelVcfaContentLibrary )
267267 }
@@ -292,10 +292,17 @@ func setContentLibraryData(_ *VCDClient, d *schema.ResourceData, cl *govcd.Conte
292292 subscriptionConfig = []interface {}{
293293 map [string ]interface {}{
294294 "subscription_url" : cl .ContentLibrary .SubscriptionConfig .SubscriptionUrl ,
295- "password" : cl .ContentLibrary .SubscriptionConfig .Password ,
296295 },
297296 }
297+ // Password is only available in resource
298+ if origin == "resource" {
299+ // Password is never returned by backend. We save what we have currently
300+ if p := d .Get ("subscription_config.0.password" ); p != "" {
301+ subscriptionConfig [0 ].(map [string ]interface {})["password" ] = p
302+ }
303+ }
298304 }
305+
299306 err = d .Set ("subscription_config" , subscriptionConfig )
300307 if err != nil {
301308 return err
0 commit comments