Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UUID validation for diff fields #314

Merged
merged 3 commits into from
Aug 9, 2024
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
11 changes: 6 additions & 5 deletions civo/firewall/resource_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ func ResourceFirewall() *schema.Resource {
Description: "The firewall name",
},
"network_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: "The firewall network, if is not defined we use the default network",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: utils.ValidateUUID,
Description: "The firewall network, if is not defined we use the default network",
},
"region": {
Type: schema.TypeString,
Expand Down
22 changes: 12 additions & 10 deletions civo/instances/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ func ResourceInstance() *schema.Resource {
Description: "This should be either 'none' or 'create' (default: 'create')",
},
"network_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: "This must be the ID of the network from the network listing (optional; default network used when not specified)",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: utils.ValidateUUID,
Description: "This must be the ID of the network from the network listing (optional; default network used when not specified)",
},
"disk_image": {
Type: schema.TypeString,
Expand All @@ -79,15 +80,16 @@ func ResourceInstance() *schema.Resource {
Description: "Add some notes to the instance",
},
"sshkey_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The ID of an already uploaded SSH public key to use for login to the default user (optional; if one isn't provided a random password will be set and returned in the initial_password field)",
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: utils.ValidateUUID,
Description: "The ID of an already uploaded SSH public key to use for login to the default user (optional; if one isn't provided a random password will be set and returned in the initial_password field)",
},
"firewall_id": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
ValidateFunc: utils.ValidateUUID,
Description: "The ID of the firewall to use, from the current list. If left blank or not sent, the default firewall will be used (open to all)",
},
"tags": {
Expand Down
16 changes: 9 additions & 7 deletions civo/kubernetes/resource_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ func ResourceKubernetesCluster() *schema.Resource {
Description: "The region for the cluster, if not declare we use the region in declared in the provider",
},
"network_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The network for the cluster, if not declare we use the default one",
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: utils.ValidateUUID,
Description: "The network for the cluster, if not declare we use the default one",
},
"num_target_nodes": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -86,9 +87,10 @@ func ResourceKubernetesCluster() *schema.Resource {
}, " "),
},
"firewall_id": {
Type: schema.TypeString,
Required: true,
Description: "The existing firewall ID to use for this cluster",
Type: schema.TypeString,
Required: true,
ValidateFunc: utils.ValidateUUID,
Description: "The existing firewall ID to use for this cluster",
},
"cluster_type": {
Type: schema.TypeString,
Expand Down
Loading