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(bigtable): Guard for nil EncryptionConfig in Clusters, GetCluster #4113

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions bigtable/admin.go
Expand Up @@ -1158,17 +1158,22 @@ func (iac *InstanceAdminClient) Clusters(ctx context.Context, instanceID string)
if err != nil {
return nil, err
}

var cis []*ClusterInfo
for _, c := range res.Clusters {
nameParts := strings.Split(c.Name, "/")
locParts := strings.Split(c.Location, "/")
kmsKeyName := ""
if c.EncryptionConfig != nil {
kmsKeyName = c.EncryptionConfig.KmsKeyName
}
cis = append(cis, &ClusterInfo{
Name: nameParts[len(nameParts)-1],
Zone: locParts[len(locParts)-1],
ServeNodes: int(c.ServeNodes),
State: c.State.String(),
StorageType: storageTypeFromProto(c.DefaultStorageType),
KMSKeyName: c.EncryptionConfig.KmsKeyName,
KMSKeyName: kmsKeyName,
})
}
if len(res.FailedLocations) > 0 {
Expand All @@ -1195,6 +1200,10 @@ func (iac *InstanceAdminClient) GetCluster(ctx context.Context, instanceID, clus
return nil, err
}

kmsKeyName := ""
if c.EncryptionConfig != nil {
kmsKeyName = c.EncryptionConfig.KmsKeyName
}
nameParts := strings.Split(c.Name, "/")
locParts := strings.Split(c.Location, "/")
cis := &ClusterInfo{
Expand All @@ -1203,7 +1212,7 @@ func (iac *InstanceAdminClient) GetCluster(ctx context.Context, instanceID, clus
ServeNodes: int(c.ServeNodes),
State: c.State.String(),
StorageType: storageTypeFromProto(c.DefaultStorageType),
KMSKeyName: c.EncryptionConfig.KmsKeyName,
KMSKeyName: kmsKeyName,
}
return cis, nil
}
Expand Down
1 change: 0 additions & 1 deletion bigtable/integration_test.go
Expand Up @@ -2396,7 +2396,6 @@ func TestIntegration_InstanceUpdate(t *testing.T) {
if err != nil {
t.Errorf("InstanceInfo: %v", err)
}

if iInfo.Name != adminClient.instance {
t.Errorf("InstanceInfo returned name %#v, want %#v", iInfo.Name, adminClient.instance)
}
Expand Down