diff --git a/test/deckfile/deck.dashboard.yaml b/examples/deck.dashboard.yaml similarity index 100% rename from test/deckfile/deck.dashboard.yaml rename to examples/deck.dashboard.yaml diff --git a/getdeck/__main__.py b/getdeck/__main__.py index 793d30c..e5e1976 100755 --- a/getdeck/__main__.py +++ b/getdeck/__main__.py @@ -9,6 +9,10 @@ os.environ["PYOXIDIZER"] = "1" logger = logging.getLogger("deck") + +ARGUMENT_DECKFILE_HELP = "the deck.yaml location (as file, git or https)" + + parser = argparse.ArgumentParser( prog="deck", description="The Deck CLI. For more help please visit: https://getdeck.dev", @@ -19,7 +23,7 @@ # list all decks of the given deck.yaml list_parser = action.add_parser("list") list_parser.add_argument( - "Deckfile", help="the deck.yaml location (as file, git or https)" + "Deckfile", help=ARGUMENT_DECKFILE_HELP, nargs="?", default="." ) # rollout the cluster and install the deck from the given deck.yaml @@ -59,9 +63,7 @@ def check_positive(value): type=check_positive, required=False, ) -get_parser.add_argument( - "Deckfile", help="the deck.yaml location (as file, git or https)" -) +get_parser.add_argument("Deckfile", help=ARGUMENT_DECKFILE_HELP, nargs="?", default=".") remove_parser = action.add_parser("remove") remove_parser.add_argument( @@ -82,7 +84,7 @@ def check_positive(value): required=False, ) remove_parser.add_argument( - "Deckfile", help="the deck.yaml location (as file, git or https)" + "Deckfile", help=ARGUMENT_DECKFILE_HELP, nargs="?", default="." ) stop_parser = action.add_parser("stop") @@ -94,7 +96,7 @@ def check_positive(value): required=False, ) stop_parser.add_argument( - "Deckfile", help="the deck.yaml location (as file, git or https)" + "Deckfile", help=ARGUMENT_DECKFILE_HELP, nargs="?", default="." ) version_parser = action.add_parser("version") @@ -103,7 +105,7 @@ def check_positive(value): hosts_parser = action.add_parser("hosts") hosts_parser.add_argument("host_action", help="list/write/remove") hosts_parser.add_argument( - "Deckfile", help="the deck.yaml location (as file, git or https)" + "Deckfile", help=ARGUMENT_DECKFILE_HELP, nargs="?", default="." ) hosts_parser.add_argument( "--name", help="the Deck whose hosts will be considered", required=False diff --git a/getdeck/api/list.py b/getdeck/api/list.py index 7ccde84..b038b7a 100644 --- a/getdeck/api/list.py +++ b/getdeck/api/list.py @@ -9,7 +9,7 @@ @stopwatch def get_available_decks(deckfile_location: str) -> List: - data_aux = fetch_data(deckfile_location) + data_aux = fetch_data(deckfile_location, fetch_sources=False) available_decks = data_aux.deckfile.get_decks() del data_aux diff --git a/getdeck/fetch/fetch.py b/getdeck/fetch/fetch.py index 02946bb..f7f2241 100644 --- a/getdeck/fetch/fetch.py +++ b/getdeck/fetch/fetch.py @@ -91,7 +91,7 @@ def fetch_data( file = os.path.join(data_aux.deckfile_aux.path, data_aux.deckfile_aux.name) if not os.path.isfile(file): del data_aux - raise RuntimeError(f"Cannot identify {location} as Deckfile") + raise RuntimeError(f"Cannot identify Deckfile at location: '{location}'") deckfile = deckfile_selector.get(file) data_aux.deckfile = deckfile diff --git a/test/deckfile/deck.yaml b/test/deckfile/deck.yaml new file mode 100644 index 0000000..ce9ea58 --- /dev/null +++ b/test/deckfile/deck.yaml @@ -0,0 +1,40 @@ +version: "1" + +cluster: + provider: k3d + minVersion: 4.0.0 + name: test-empty-file + nativeConfig: + apiVersion: k3d.io/v1alpha4 + kind: Simple + servers: 1 + agents: 1 + image: rancher/k3s:v1.22.9-k3s1 + options: + k3s: + extraArgs: + - arg: --disable=traefik + nodeFilters: + - server:* + ports: + - port: 61346:80 + nodeFilters: + - loadbalancer + - port: 8443:443 + nodeFilters: + - loadbalancer + - port: 31820:31820/UDP + nodeFilters: + - agent:0 + +decks: + - name: empty + namespace: default + sources: + - type: inline + content: + { + "kind": "Namespace", + "apiVersion": "v1", + "metadata": { "name": "content", "labels": { "name": "content" } }, + }