Code Monkey home page Code Monkey logo

Comments (7)

jonmosco avatar jonmosco commented on August 17, 2024

if [[ -z $(${KUBE_BINARY} config view --minify --output 'jsonpath={..namespace}') ]]; then
KUBE_PS1_NAMESPACE="$(${KUBE_BINARY} config view --minify --output 'jsonpath={..namespace}')"
else
KUBE_PS1_NAMESPACE="default"
fi

I saw the same behavior as well, just was unsure that setting the default to 'default' was going to be accepted. Is there a case where its not default if undefined ?

from kube-ps1.

jonmosco avatar jonmosco commented on August 17, 2024

Remove the -z actually, just test it has output. Verified:

jmosco at jmosco-005715 in ~ (⎈ |minikube:)
$ prompt_k8s

jmosco at jmosco-005715 in ~ (⎈ |minikube:default)
$ kubens
default
kube-public
kube-system

jmosco at jmosco-005715 in ~ (⎈ |minikube:default)
$ kubens kube-public
Context "minikube" modified.
Active namespace is "kube-public".

from kube-ps1.

ahmetb avatar ahmetb commented on August 17, 2024

if [[ -z $(${KUBE_BINARY} config view --minify --output 'jsonpath={..namespace}') ]]; then
KUBE_PS1_NAMESPACE="$(${KUBE_BINARY} config view --minify --output 'jsonpath={..namespace}')"
else
KUBE_PS1_NAMESPACE="default"
fi

haha definitely don't do this, you 're calling kubectl twice just to get the same value :)

${VARIABLE:-default} should just work here.

from kube-ps1.

jonmosco avatar jonmosco commented on August 17, 2024

Yes, ok lol.

from kube-ps1.

jonmosco avatar jonmosco commented on August 17, 2024

KUBE_PS1_NAMESPACE="$(${KUBE_BINARY} config view --minify --output 'jsonpath={..namespace}')"
KUBE_PS1_NAMESPACE="${KUBE_PS1_NAMESPACE:-default}"

from kube-ps1.

ahmetb avatar ahmetb commented on August 17, 2024

yeah, but ideally I'd like to see #4 fixed :)

from kube-ps1.

jonmosco avatar jonmosco commented on August 17, 2024

Going to work on that one now. Thanks for all these fixes/suggestions!

from kube-ps1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.