Skip to content

Commit

Permalink
add check for vfxt name and licensing id output (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
anhowe authored Aug 14, 2020
1 parent 729bba7 commit 9bc0d91
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,5 @@ const (
node_names = "node_names"
junction_namespace_path = "junction_namespace_path"
primary_cluster_ips = "primary_cluster_ips"
licensing_id = "licensing_id"
)
23 changes: 21 additions & 2 deletions src/terraform/providers/terraform-provider-avere/resource_vfxt.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func resourceVfxt() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringDoesNotContainAny(" '\"$"),
ValidateFunc: ValidateVfxtName,
},
vfxt_admin_password: {
Type: schema.TypeString,
Expand Down Expand Up @@ -363,6 +363,10 @@ func resourceVfxt() *schema.Resource {
Type: schema.TypeString,
},
},
licensing_id: {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -512,6 +516,12 @@ func resourceVfxtRead(d *schema.ResourceData, m interface{}) error {
d.Set(vfxt_node_count, len(*(avereVfxt.NodeNames)))
}

cluster, err := avereVfxt.GetCluster()
if err != nil {
return fmt.Errorf("error encountered getting cluster '%v'", err)
}
d.Set(licensing_id, cluster.LicensingId)

return nil
}

Expand Down Expand Up @@ -1513,7 +1523,6 @@ func ValidateExportSubdirectory(v interface{}, _ string) (warnings []string, err
return warnings, errors
}

// ValidateAutomationRunbookName validates Automation Account Runbook names
func ValidateUserName(v interface{}, _ string) (warnings []string, errors []error) {
input := v.(string)

Expand All @@ -1528,6 +1537,16 @@ func ValidateUserName(v interface{}, _ string) (warnings []string, errors []erro
return warnings, errors
}

func ValidateVfxtName(v interface{}, _ string) (warnings []string, errors []error) {
input := v.(string)

if !regexp.MustCompile(`^[a-z]([-a-z0-9]*[a-z0-9])?$`).MatchString(input) {
errors = append(errors, fmt.Errorf("the vfxt name '%s' is invalid, and per vfxt.py must match the regular expressesion ^[a-z]([-a-z0-9]*[a-z0-9])?$ ''", input))
}

return warnings, errors
}

func unflattenStringSlice(input []interface{}) *[]string {
output := make([]string, 0)

Expand Down
1 change: 1 addition & 0 deletions src/terraform/providers/terraform-provider-avere/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,5 @@ type Cluster struct {
NtpServers string `json:"NTPservers"`
ClusterName string `json:"name"`
Proxy string `json:"proxy"`
LicensingId string `json:"id"`
}

0 comments on commit 9bc0d91

Please sign in to comment.