Skip to content

Commit

Permalink
ocm: Add ClusterServiceConfig.GetCSClusterStatus method
Browse files Browse the repository at this point in the history
Will add something similar for node pools once the new "aro_hcp"
API is available from Cluster Service.
  • Loading branch information
Matthew Barnes committed Oct 21, 2024
1 parent b759ed8 commit fd4bed1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/ocm/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ func (csc *ClusterServiceClient) GetCSCluster(ctx context.Context, internalID In
return cluster, nil
}

// GetCSClusterStatus creates and sends a GET request to fetch a cluster's status from Clusters Service
func (csc *ClusterServiceClient) GetCSClusterStatus(ctx context.Context, internalID InternalID) (*cmv1.ClusterStatus, error) {
client, ok := internalID.GetClusterClient(csc.Conn)
if !ok {
return nil, fmt.Errorf("OCM path is not a cluster: %s", internalID)
}
clusterStatusGetResponse, err := client.Status().Get().SendContext(ctx)
if err != nil {
return nil, err
}
status, ok := clusterStatusGetResponse.GetBody()
if !ok {
return nil, fmt.Errorf("empty response body")
}
return status, nil
}

// PostCSCluster creates and sends a POST request to create a cluster in Clusters Service
func (csc *ClusterServiceClient) PostCSCluster(ctx context.Context, cluster *cmv1.Cluster) (*cmv1.Cluster, error) {
clustersAddResponse, err := csc.Conn.ClustersMgmt().V1().Clusters().Add().Body(cluster).SendContext(ctx)
Expand Down

0 comments on commit fd4bed1

Please sign in to comment.