Skip to content

Commit

Permalink
fixes based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
blentz committed Jan 3, 2022
1 parent 64c02f2 commit 6226acb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
40 changes: 17 additions & 23 deletions gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,27 +1211,23 @@ func newCluster(cluster *dataprocpb.Cluster, region string) *types.Cluster {

func getClusterState(s dataprocpb.ClusterStatus_State) types.State {
// convert ClusterSTatus_State to types.State

// This array must match the const ordering from here:
// https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1#ClusterStatus_State
statuses := []types.State{
types.Unknown,
types.Creating,
types.Running,
types.Error,
types.Deleting,
types.Updating,
types.Stopping,
types.Stopped,
types.Starting,
}

for i, status := range statuses {
if i == int(s) {
return status
}
statuses := map[int32]types.State{
0: types.Unknown,
1: types.Creating,
2: types.Running,
3: types.Error,
4: types.Deleting,
5: types.Updating,
6: types.Stopping,
7: types.Stopped,
8: types.Starting,
}

status, ok := statuses[s]
if !ok {
return types.Unknown
}
return types.Unknown
return status
}

func (p gcpProvider) GetClusters() ([]*types.Cluster, error) {
Expand Down Expand Up @@ -1274,9 +1270,7 @@ func (p gcpProvider) GetClusters() ([]*types.Cluster, error) {
}
if len(clist) > 0 {
log.Debugf("[GET_CLUSTERS] Found %d clusters in %s", len(clist), r)
for _, c := range clist {
clusters = append(clusters, c)
}
clusters = append(clusters, clist...)
}
}
return clusters, nil
Expand Down
2 changes: 1 addition & 1 deletion types/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Cluster struct {
Region string `json:"Region"`
Tags map[string]string `json:"Tags"`
Config *dataprocpb.ClusterConfig `json:"ClusterConfig"`
State State `json:"State"`
State State `json:"State"`
}

// GetName returns the name of the cluster
Expand Down

0 comments on commit 6226acb

Please sign in to comment.