Skip to content

Commit

Permalink
[385] added cluster actual status message
Browse files Browse the repository at this point in the history
  • Loading branch information
moklidia committed Dec 15, 2023
1 parent 3173343 commit dce8c79
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/uffizzi/cli/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ def handle_update_kubeconfig_command(command_args)

Uffizzi.ui.say("Kubeconfig was updated by the path: #{kubeconfig_path}")

synced_cluster_data = ClusterService.sync_cluster_data(command_args[:cluster_name], **cluster_api_connection_params)
synced_cluster_data = ClusterService.sync_cluster_data(command_args[:cluster_name], server: server, project_slug: project_slug)
cluster_state = synced_cluster_data[:state]
return if ClusterService.deployed?(cluster_state)

if ClusterService.scaled_down?(synced_cluster_data[:state])
Uffizzi.ui.say('The cluster is scaled down.')
handle_scale_up_cluster(cluster_name, cluster_api_connection_params)
end
Uffizzi.ui.say(ClusterService.cluster_status_text_map[cluster_state])
handle_scale_up_cluster(cluster_name, cluster_api_connection_params) if ClusterService.scaled_down?(cluster_state)
end

def handle_sleep_command(command_args)
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/clients/api/api_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def scale_down_cluster_uri(server, project_slug, cluster_name)
end

def sync_cluster_uri(server, project_slug, cluster_name)
"#{server}/api/cli/v1/projects/#{project_slug}/clusters/#{cluster_name}/sync_cluster"
"#{server}/api/cli/v1/projects/#{project_slug}/clusters/#{cluster_name}/sync"
end

def access_token_url(server, code)
Expand Down
11 changes: 11 additions & 0 deletions lib/uffizzi/services/cluster_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,16 @@ def build_render_data(cluster_data)
host: cluster_data[:host],
}
end

def cluster_status_text_map
{
CLUSTER_STATE_SCALING_UP => 'The cluster is scaling up',
CLUSTER_STATE_SCALED_DOWN => 'The cluster is scaled down',
CLUSTER_STATE_SCALING_DOWN => 'The cluster is scaling down',
CLUSTER_FAILED_SCALING_UP => 'The cluster failed scaling up',
CLUSTER_STATE_FAILED_DEPLOY_NAMESPACE => 'The cluster failed',
CLUSTER_STATE_FAILED => 'The cluster failed',
}
end
end
end

0 comments on commit dce8c79

Please sign in to comment.