forked from 2i2c-org/infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 2i2c-org#4041 from consideRatio/pr/deployer-comman…
…d-to-list-clusters deployer: add command config get-clusters (with --provider filter flag)
- Loading branch information
Showing
8 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
|
||
import typer | ||
from ruamel.yaml import YAML | ||
|
||
from deployer.cli_app import config_app | ||
from deployer.infra_components.cluster import Cluster | ||
from deployer.utils.file_acquisition import get_all_cluster_yaml_files | ||
|
||
# Without `pure=True`, I get an exception about str / byte issues | ||
yaml = YAML(typ="safe", pure=True) | ||
|
||
|
||
@config_app.command() | ||
def get_clusters( | ||
provider: str = typer.Option( | ||
"", help="(Optional) Filter results to clusters with this provider specified." | ||
), | ||
): | ||
""" | ||
Prints all cluster names sorted alphabetically, optionally filtered by the | ||
'provider' field in the cluster.yaml file. | ||
""" | ||
cluster_names = [] | ||
for config_file_path in get_all_cluster_yaml_files(): | ||
with open(config_file_path) as f: | ||
cluster = Cluster(yaml.load(f), config_file_path.parent) | ||
if provider and cluster.spec["provider"] != provider: | ||
continue | ||
cluster_names.append(os.path.basename(config_file_path.parent)) | ||
|
||
cluster_names = sorted(cluster_names) | ||
for cn in cluster_names: | ||
print(cn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters