import click
from osmclient.cli_commands import common, utils
+from osmclient.common.exceptions import ClientException
from osmclient.common import print_output
import logging
import yaml
default=True,
help="bootstrap the cluster with Flux (prepare for GitOps) (default=True)",
)
+@click.option("--config", default=None, help="cluster specific yaml configuration")
+@click.option(
+ "--config_file", default=None, help="cluster specific yaml configuration file"
+)
@click.pass_context
def cluster_create(
ctx,
region_name,
resource_group,
bootstrap,
- **kwargs
+ config,
+ config_file,
+ **kwargs,
):
"""creates a K8s cluster
if resource_group:
cluster["resource_group"] = resource_group
cluster["bootstrap"] = bootstrap
+ if config_file:
+ if config:
+ raise ClientException(
+ '"--config" option is incompatible with "--config_file" option'
+ )
+ with open(config_file, "r", encoding="utf-8") as cf:
+ config = cf.read()
+ if config:
+ try:
+ cluster["config"] = yaml.safe_load(config)
+ except yaml.YAMLError as e:
+ raise ClientException(f"Error parsing YAML configuration: {e}") from e
ctx.obj.cluster.create(name, content_dict=cluster)
default=True,
help="bootstrap the cluster with Flux (prepare for GitOps) (default=True)",
)
+@click.option(
+ "--openshift",
+ required=False,
+ default=False,
+ help="flag to indicate that the cluster is Openshift-based (bootstrap is slightly different) (default=False)",
+)
@click.pass_context
def cluster_register(
ctx,
creds,
description,
bootstrap,
+ openshift,
):
"""registers a K8s cluster to OSM
if description:
cluster["description"] = description
cluster["bootstrap"] = bootstrap
+ if openshift:
+ cluster["openshift"] = openshift
ctx.obj.cluster.register(name, cluster)