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

feat(cluster): add use_instance_metadata_hostname flag to cloud_provider block #1271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ The following attributes are exported:
* `name` - (Optional) RKE Cloud Provider name (string)
* `openstack_cloud_provider` - (Optional/Computed) RKE Openstack Cloud Provider config for Cloud Provider [rke-openstack-cloud-provider](https://rancher.com/docs/rke/latest/en/config-options/cloud-providers/openstack/) (list maxitems:1)
* `vsphere_cloud_provider` - (Optional/Computed) RKE Vsphere Cloud Provider config for Cloud Provider [rke-vsphere-cloud-provider](https://rancher.com/docs/rke/latest/en/config-options/cloud-providers/vsphere/) Extra argument `name` is required on `virtual_center` configuration. (list maxitems:1)
* `use_instance_metadata_hostname` - (Optional/Computed) (bool)

##### `aws_cloud_provider`

Expand Down
5 changes: 5 additions & 0 deletions rancher2/schema_cluster_rke_config_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func clusterRKEConfigCloudProviderFields() map[string]*schema.Schema {
Schema: clusterRKEConfigCloudProviderVsphereFields(),
},
},
"use_instance_metadata_hostname": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
}
return s
}
8 changes: 8 additions & 0 deletions rancher2/structure_cluster_rke_config_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func flattenClusterRKEConfigCloudProvider(in *managementClient.CloudProvider, p
obj["vsphere_cloud_provider"] = vsphereProvider
}

if in.UseInstanceMetadataHostname != nil {
obj["use_instance_metadata_hostname"] = *in.UseInstanceMetadataHostname
}

return []interface{}{obj}, nil
}

Expand Down Expand Up @@ -122,5 +126,9 @@ func expandClusterRKEConfigCloudProvider(p []interface{}) (*managementClient.Clo
obj.VsphereCloudProvider = vsphereProvider
}

if v, ok := in["use_instance_metadata_hostname"].(bool); ok {
obj.UseInstanceMetadataHostname = &v
}

return obj, nil
}
10 changes: 6 additions & 4 deletions rancher2/structure_cluster_rke_config_cloud_provider_z_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ func init() {
},
}
testClusterRKEConfigCloudProviderConf = &managementClient.CloudProvider{
CustomCloudProvider: "XXXXXXXXXXXX",
Name: "test",
CustomCloudProvider: "XXXXXXXXXXXX",
Name: "test",
UseInstanceMetadataHostname: newTrue(),
}
testClusterRKEConfigCloudProviderInterface = []interface{}{
map[string]interface{}{
"custom_cloud_provider": "XXXXXXXXXXXX",
"name": "test",
"custom_cloud_provider": "XXXXXXXXXXXX",
"name": "test",
"use_instance_metadata_hostname": true,
},
}
}
Expand Down