Skip to content

Need a KN_NAMESPACE env variable to avoid repeating same namespace #184

@maximilien

Description

@maximilien

While restoring the e2e tests that use bash I realize that a pain point that users of kn will experience is having to repeat the same namespace when issuing many commands in a row---If that namespace is not the default namespace.

See the PR #183 or sample snippet here to illustrate:

# Listing 1
# Will create and delete this namespace and use it for smoke tests
export KN_E2E_SMOKE_TESTS_NAMESPACE=kne2esmoketests

kubectl create ns $KN_E2E_SMOKE_TESTS_NAMESPACE

./kn service create hello --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative -n $KN_E2E_SMOKE_TESTS_NAMESPACE
sleep 5
./kn service get -n $KN_E2E_SMOKE_TESTS_NAMESPACE -n $KN_E2E_SMOKE_TESTS_NAMESPACE
./kn service update hello --env TARGET=kn -n $KN_E2E_SMOKE_TESTS_NAMESPACE
sleep 3
./kn revision get -n $KN_E2E_SMOKE_TESTS_NAMESPACE
./kn service get -n $KN_E2E_SMOKE_TESTS_NAMESPACE
...

A better option would be to have kn use KN_NAMESPACE env value as the namespace for commands if that's defined.

So above becomes cleanly:

# Listing 2
# Will create and delete this namespace and use it for smoke tests
export KN_NAMESPACE=kne2esmoketests

./kn service create hello --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative
sleep 5
./kn service get
./kn service update hello --env TARGET=kn
sleep 3
./kn revision get
./kn service get
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureNew feature or requestlifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions