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

Fix: kubernetes: observe and update field master.regional.location #389

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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ BUG FIXES:
* compute: fix `filesystem` in `compute_instance_group` resource
* greenplum: add Cloud Storage support
* postgresql: do not recreate cluster on network change
* kubernetes: fix bug with observe and update of field `master.regional.location` in `yandex_kubernetes_cluster` resource

WARNING:
* managed-kafka: 'unmanaged_topics' cluster flag are now deprecated
Expand Down
17 changes: 15 additions & 2 deletions yandex/resource_yandex_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,12 +1048,25 @@ func (h *masterSchemaHelper) flattenClusterZonalMaster(m *k8s.Master_ZonalMaster
h.getZonalMaster()["zone"] = m.ZonalMaster.GetZoneId()
}

func (h *masterSchemaHelper) flattenClusterRegionalMaster(m *k8s.Master_RegionalMaster) {
func (h *masterSchemaHelper) flattenClusterRegionalMaster(m *k8s.Master_RegionalMaster, master *k8s.Master) {
h.master["internal_v4_address"] = m.RegionalMaster.GetInternalV4Address()
h.master["external_v4_address"] = m.RegionalMaster.GetExternalV4Address()
h.master["external_v6_address"] = m.RegionalMaster.GetExternalV6Address()

h.getRegionalMaster()["region"] = m.RegionalMaster.GetRegionId()
h.getRegionalMaster()["location"] = flattenClusterRegionalMasterLocations(master)
}

func flattenClusterRegionalMasterLocations(master *k8s.Master) []map[string]interface{} {
masterLocations := master.GetLocations()
locations := make([]map[string]interface{}, 0, len(masterLocations))
for _, location := range masterLocations {
locations = append(locations, map[string]interface{}{
"zone": location.ZoneId,
"subnet_id": location.SubnetId,
})
}
return locations
}

func flattenKubernetesMaster(cluster *k8s.Cluster) (*masterSchemaHelper, error) {
Expand Down Expand Up @@ -1086,7 +1099,7 @@ func flattenKubernetesMaster(cluster *k8s.Cluster) (*masterSchemaHelper, error)
case *k8s.Master_ZonalMaster:
h.flattenClusterZonalMaster(m)
case *k8s.Master_RegionalMaster:
h.flattenClusterRegionalMaster(m)
h.flattenClusterRegionalMaster(m, clusterMaster)
default:
return nil, fmt.Errorf("unsupported Kubernetes master type (currently only zonal and regional master are supported)")
}
Expand Down