Skip to content

Commit

Permalink
Make gke login optional (#24)
Browse files Browse the repository at this point in the history
* Make GKE configuration and context setup optional

* Improve variable with prefix and make conditional explicit

---------

Co-authored-by: Oliver Hookins <[email protected]>
  • Loading branch information
roobert and ohookins authored Aug 28, 2024
1 parent c84c179 commit b123ca9
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions fycli/kubernetes/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..environment.environment import Environment, EnvironmentError

try:
from sh import kubectl, kube_score, kapp
from sh import kapp, kube_score, kubectl
except ImportError as error:
for command in ["gcloud", "kube-score", "kubectl", "kapp"]:
if re.search(r".*'" + command + "'.*", str(error)):
Expand Down Expand Up @@ -77,7 +77,8 @@ def _setup(self, args, disable_gcloud_sandbox=False):
except KeyError:
pass

self.environment.activate_container_cluster_context()
if not os.environ.get("FY_KUBECTL_CONFIGURE") == "false":
self.environment.activate_container_cluster_context()

def _detect_manifest_dir_type(self):
fy_deployment_config_file = Path(
Expand Down Expand Up @@ -116,7 +117,10 @@ def _detect_manifest_dir_type(self):
def use(self):
parser = ExtendedHelpArgumentParser(usage="\n fy k8s use [-h|--help]")
parser.add_argument(
"-s", "--skip-version-check", help="skip dependency version check", action="store_true"
"-s",
"--skip-version-check",
help="skip dependency version check",
action="store_true",
)
parser.add_argument(
"--skip-environment", help="skip environment", action="store_true"
Expand All @@ -131,7 +135,10 @@ def use(self):
def diff(self):
parser = ExtendedHelpArgumentParser(usage="\n fy k8s diff [-h|--help]")
parser.add_argument(
"-s", "--skip-version-check", help="skip dependency version check", action="store_true"
"-s",
"--skip-version-check",
help="skip dependency version check",
action="store_true",
)
parser.add_argument(
"--skip-environment", help="skip environment", action="store_true"
Expand All @@ -148,11 +155,12 @@ def diff(self):
def apply(self):
parser = ExtendedHelpArgumentParser(usage="\n fy k8s apply [-h|--help]")
parser.add_argument(
"-s", "--skip-version-check", help="skip dependency version check", action="store_true"
)
parser.add_argument(
"--skip-diff", help="skip diff", action="store_true"
"-s",
"--skip-version-check",
help="skip dependency version check",
action="store_true",
)
parser.add_argument("--skip-diff", help="skip diff", action="store_true")
parser.add_argument(
"--skip-environment", help="skip environment", action="store_true"
)
Expand Down Expand Up @@ -257,14 +265,15 @@ def apply(self):
def plan(self):
parser = ExtendedHelpArgumentParser(usage="\n fy k8s plan [-h|--help]")
parser.add_argument(
"-s", "--skip-version-check", help="skip dependency version check", action="store_true"
"-s",
"--skip-version-check",
help="skip dependency version check",
action="store_true",
)
parser.add_argument(
"--skip-environment", help="skip environment", action="store_true"
)
parser.add_argument(
"--skip-diff", help="skip diff", action="store_true"
)
parser.add_argument("--skip-diff", help="skip diff", action="store_true")
parser.add_argument(
"--skip-kube-score", help="skip kube-score", action="store_true"
)
Expand Down Expand Up @@ -369,7 +378,10 @@ def plan(self):
def delete(self):
parser = ExtendedHelpArgumentParser(usage="\n fy k8s delete [-h|--help]")
parser.add_argument(
"-s", "--skip-version-check", help="skip dependency version check", action="store_true"
"-s",
"--skip-version-check",
help="skip dependency version check",
action="store_true",
)
parser.add_argument(
"--skip-environment", help="skip environment", action="store_true"
Expand Down Expand Up @@ -591,4 +603,3 @@ def _handle_error(self, error):
print("\n==> exception caught!")
print("\n==> stack trace\n")
raise

0 comments on commit b123ca9

Please sign in to comment.