MCPcopy Create free account
hub / github.com/ForgeRock/forgeops / get_namespace

Function get_namespace

lib/python/utils.py:460–466  ·  view source on GitHub ↗

Get the default namespace from the active kubectl context

(ns=None)

Source from the content-addressed store, hash-verified

458
459# IF ns is not None, then return it, otherwise lookup the current namespace context
460def get_namespace(ns=None):
461 """Get the default namespace from the active kubectl context"""
462 if ns != None:
463 return ns
464 get_context() # Ensure k8s context is set/exists
465 _, ctx_namespace, _ = run('kubectl', 'config view --minify --output=jsonpath={..namespace}', cstdout=True)
466 return ctx_namespace.decode('ascii') if ctx_namespace else 'default'
467
468def get_context():
469 """Get the active kubectl context name"""

Callers

nothing calls this directly

Calls 2

get_contextFunction · 0.85
runFunction · 0.70

Tested by

no test coverage detected