Skip to content

Commit

Permalink
Signed-off-by: abarreiro <[email protected]>
Browse files Browse the repository at this point in the history
Improve docs and validation wording for `vcd_tm_org` resource (#1351)

ForceNew

Signed-off-by: abarreiro <[email protected]>
  • Loading branch information
abarreiro committed Nov 20, 2024
1 parent e752483 commit 718002a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .changes/v4.0.0/1345-features.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* **New Resource:** `vcd_tm_org` to manage TM Organizations [GH-1345]
* **New Resource:** `vcd_tm_org` to manage TM Organizations [GH-1345, GH-1351]
* **New Data Source:** `vcd_tm_org` to read TM Organizations [GH-1345]
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ website/node_modules
*.test
*.iml

# Ignore test coverage files
*.cover

vcd/vcd_test_config*.json
vcd/go-vcloud-director.log
vcd/test-artifacts
Expand Down
4 changes: 4 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ testextnetwork: fmtcheck
# Runs the acceptance test for tm
testtm: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' tm"
# Runs the acceptance test for tm with coverage
testtm-coverage: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' tm-coverage"


testtm-binary-prepare: install
cd vcd && go test -tags tm -vcd-add-provider -vcd-short -v .
Expand Down
3 changes: 3 additions & 0 deletions scripts/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ case $wanted in
tm)
acceptance_test tm
;;
tm-coverage)
acceptance_test tm "-coverprofile=tm.cover"
;;
network)
acceptance_test network
;;
Expand Down
26 changes: 16 additions & 10 deletions vcd/resource_vcd_tm_content_library_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,32 @@ func resourceVcdTmContentLibraryItem() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true, // TODO: TM: Update not supported yet
Description: fmt.Sprintf("Name of the %s", labelTmContentLibraryItem),
},
"description": {
Type: schema.TypeString,
Optional: true,
ForceNew: true, // TODO: TM: Update not supported yet
Description: fmt.Sprintf("The description of the %s", labelTmContentLibraryItem),
},
"content_library_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true, // TODO: TM: Update not supported yet
Description: fmt.Sprintf("ID of the Content Library that this %s belongs to", labelTmContentLibraryItem),
},
"file_path": {
Type: schema.TypeString,
Optional: true, // Not needed when Importing
ForceNew: true, // TODO: TM: Update not supported yet
Description: fmt.Sprintf("Path to the OVA/ISO to create the %s", labelTmContentLibraryItem),
},
"creation_date": {
Type: schema.TypeString,
Computed: true,
Description: fmt.Sprintf("The ISO-8601 timestamp representing when this %s was created", labelTmContentLibraryItem),
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: fmt.Sprintf("The description of the %s", labelTmContentLibraryItem),
},
"image_identifier": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -111,8 +115,10 @@ func resourceVcdTmContentLibraryItemCreate(ctx context.Context, d *schema.Resour
return createResource(ctx, d, meta, c)
}

func resourceVcdTmContentLibraryItemUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
vcdClient := meta.(*VCDClient)
func resourceVcdTmContentLibraryItemUpdate(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics {
// TODO: TM: Update is not supported yet
return diag.Errorf("update not supported")
/*vcdClient := meta.(*VCDClient)
clId := d.Get("content_library_id").(string)
cl, err := vcdClient.GetContentLibraryById(clId)
Expand All @@ -127,7 +133,7 @@ func resourceVcdTmContentLibraryItemUpdate(ctx context.Context, d *schema.Resour
resourceReadFunc: resourceVcdTmContentLibraryItemRead,
}
return updateResource(ctx, d, meta, c)
return updateResource(ctx, d, meta, c)*/
}

func resourceVcdTmContentLibraryItemRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
Expand Down Expand Up @@ -164,7 +170,7 @@ func resourceVcdTmContentLibraryItemDelete(ctx context.Context, d *schema.Resour
return deleteResource(ctx, d, meta, c)
}

func resourceVcdTmContentLibraryItemImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
func resourceVcdTmContentLibraryItemImport(_ context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
vcdClient := meta.(*VCDClient)

id := strings.Split(d.Id(), ImportSeparator)
Expand All @@ -187,7 +193,7 @@ func resourceVcdTmContentLibraryItemImport(ctx context.Context, d *schema.Resour
return []*schema.ResourceData{d}, nil
}

func getContentLibraryItemType(vcdClient *VCDClient, d *schema.ResourceData) (*types.ContentLibraryItem, error) {
func getContentLibraryItemType(_ *VCDClient, d *schema.ResourceData) (*types.ContentLibraryItem, error) {
t := &types.ContentLibraryItem{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Expand Down
2 changes: 1 addition & 1 deletion vcd/resource_vcd_tm_org.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func validateRenameOrgDisabled(d *schema.ResourceData, oldCfg *govcd.TmOrg, newC
if d.HasChange("name") &&
// this condition is a negative xor - it will be matched if Org is not transitioning from or to disabled state
((!newCfg.IsEnabled && !oldCfg.TmOrg.IsEnabled) || newCfg.IsEnabled && oldCfg.TmOrg.IsEnabled) {
return fmt.Errorf("%s must be disabled (is_enabled=false) to change name", labelTmOrg)
return fmt.Errorf("%s must be disabled (is_enabled=false) to change name because it changes tenant login URL", labelTmOrg)
}

return nil
Expand Down
7 changes: 6 additions & 1 deletion website/docs/r/tm_content_library.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ This resource is exclusive to **VMware Cloud Foundation Tenant Manager**. Suppor
## Example Usage for a Provider Content Library

```hcl
data "vcd_tm_region" "region" {
name = "My Region"
}
data "vcd_tm_region_storage_policy" "sp" {
name = "vSAN Default Storage Policy"
region_id = data.vcd_tm_region.region.id
name = "vSAN Default Storage Policy"
}
resource "vcd_tm_content_library" "cl" {
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/tm_org.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ resource "vcd_tm_org" "test" {
The following arguments are supported:

* `name` - (Required) A name for Organization with which users log in to it as it will be used in
the URL
the URL. The Org must be disabled to or transition from previous disabled state
(`is_enabled=false`) to change a name because it changes tenant login URL
* `display_name` - (Required) A human readable name for Organization
* `description` - (Optional) An optional description for Organization
* `is_enabled` - (Optional) Defines if Organization is enabled. Default `true`. **Note:**
Expand Down

0 comments on commit 718002a

Please sign in to comment.