Skip to content

Commit

Permalink
fix(bigtable): Guard for nil EncryptionConfig in Clusters, GetCluster (
Browse files Browse the repository at this point in the history
…#4113)

* fix(bigtable): Fixes #4105 by guarding on nil EncryptionConfig
  • Loading branch information
crwilcox committed May 18, 2021
1 parent f232763 commit a17ff67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit a17ff67

Please sign in to comment.