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

[262] added separate api client method for kubeconfig update #266

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/uffizzi/cli/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def handle_delete_command(project_slug, command_args)
def handle_update_kubeconfig_command(project_slug)
cluster_name = options[:name]
kubeconfig_path = options[:kubeconfig] || KubeconfigService.default_path
response = get_cluster(Uffizzi::ConfigFile.read_option(:server), project_slug, cluster_name)
response = get_kubeconfig(Uffizzi::ConfigFile.read_option(:server), project_slug, cluster_name)
return Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.ok?(response)

cluster_data = response.dig(:body, :cluster)
Expand Down
7 changes: 7 additions & 0 deletions lib/uffizzi/clients/api/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ def get_cluster(server, project_slug, cluster_name)
build_response(response)
end

def get_kubeconfig(server, project_slug, cluster_name)
uri = cluster_kubeconfig_uri(server, project_slug, cluster_name)
response = http_client.make_get_request(uri)

build_response(response)
end

def get_access_token(server, code)
uri = access_token_url(server, code)
response = http_client.make_get_request(uri)
Expand Down
4 changes: 4 additions & 0 deletions lib/uffizzi/clients/api/api_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def cluster_uri(server, project_slug, cluster_name)
"#{server}/api/cli/v1/projects/#{project_slug}/clusters/#{cluster_name}"
end

def cluster_kubeconfig_uri(server, project_slug, cluster_name)
"#{server}/api/cli/v1/projects/#{project_slug}/clusters/#{cluster_name}/kubeconfig"
end

def access_token_url(server, code)
"#{server}/api/cli/v1/access_tokens/#{code}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/services/cluster_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def failed?(cluster_state)

def wait_cluster_deploy(project_slug, cluster_name)
loop do
response = get_cluster(Uffizzi::ConfigFile.read_option(:server), project_slug, cluster_name)
response = get_kubeconfig(Uffizzi::ConfigFile.read_option(:server), project_slug, cluster_name)
return Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.ok?(response)

cluster_data = response.dig(:body, :cluster)
Expand Down
Loading