Skip to content

Commit

Permalink
Write a function that reads which cloud a cluster is on from cluster.…
Browse files Browse the repository at this point in the history
…yaml
  • Loading branch information
sgibson91 committed Oct 3, 2024
1 parent 3609bfe commit 513d2c1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions deployer/commands/grafana/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,20 @@ def update_central_grafana_token(cluster_name, token):

# Encrypt the private key
subprocess.check_call(["sops", "--in-place", "--encrypt", grafana_token_file])


def get_cluster_cloud_provider(cluster_name):
"""
Get the cloud provider a cluster is hosted on from its cluster.yaml file
Args:
cluster_name (str): name of the cluster
provider (str): name of the cloud provider the cluster is hosted on
"""
cluster_config_dir_path = find_absolute_path_to_cluster_file(cluster_name).parent
config_filename = cluster_config_dir_path.joinpath("cluster.yaml")

with open(config_filename) as f:
cluster_config = yaml.load(f)

return cluster_config["provider"]

0 comments on commit 513d2c1

Please sign in to comment.