From e214200f8450cbe3a1fa5eee9a348d60bbbccb03 Mon Sep 17 00:00:00 2001 From: Andrea Hoffer Date: Wed, 25 Feb 2026 15:21:33 -0500 Subject: [PATCH] OSDOCS#16913: CQA for next set of CLI assemblies --- .../administrator-cli-commands.adoc | 5 +- .../openshift_cli/configuring-cli.adoc | 4 + .../openshift_cli/developer-cli-commands.adoc | 6 +- .../openshift_cli/extending-cli-plugins.adoc | 4 +- .../openshift_cli/managing-cli-profiles.adoc | 24 +++--- modules/about-cli-profiles-switch.adoc | 30 ++++---- .../cli-configuring-kubeconfig-using-cli.adoc | 21 ++--- modules/cli-extending-plugins-installing.adoc | 14 ++-- modules/cli-extending-plugins-writing.adoc | 26 +++---- modules/load-and-merge-rules.adoc | 9 ++- ...configuration-of-cli-profiles-example.adoc | 73 ++++++++++++++++++ .../manual-configuration-of-cli-profiles.adoc | 77 +++---------------- 12 files changed, 154 insertions(+), 139 deletions(-) create mode 100644 modules/manual-configuration-of-cli-profiles-example.adoc diff --git a/cli_reference/openshift_cli/administrator-cli-commands.adoc b/cli_reference/openshift_cli/administrator-cli-commands.adoc index 45dddfd10f03..ecb1b2061d7d 100644 --- a/cli_reference/openshift_cli/administrator-cli-commands.adoc +++ b/cli_reference/openshift_cli/administrator-cli-commands.adoc @@ -6,9 +6,10 @@ include::_attributes/common-attributes.adoc[] toc::[] -This reference provides descriptions and example commands for OpenShift CLI (`oc`) administrator commands. You must have `cluster-admin` or equivalent permissions to use these commands. +[role="_abstract"] +To learn more about the {oc-first} administrator commands, review their descriptions and example commands. You must have `cluster-admin` or equivalent permissions to use these commands. -For developer commands, see the xref:../../cli_reference/openshift_cli/developer-cli-commands.adoc#cli-developer-commands[OpenShift CLI developer command reference]. +For developer commands, see the "OpenShift CLI developer command reference". Run `oc adm -h` to list all administrator commands or run `oc --help` to get additional details for a specific command. diff --git a/cli_reference/openshift_cli/configuring-cli.adoc b/cli_reference/openshift_cli/configuring-cli.adoc index 1ff8e0ba6011..625bda3502d5 100644 --- a/cli_reference/openshift_cli/configuring-cli.adoc +++ b/cli_reference/openshift_cli/configuring-cli.adoc @@ -6,6 +6,10 @@ include::_attributes/common-attributes.adoc[] toc::[] +[role="_abstract"] +TODO + +// TODO move this below to module? so small though. Maybe just consider removing the umbrella heading [id="cli-enabling-tab-completion"] == Enabling tab completion diff --git a/cli_reference/openshift_cli/developer-cli-commands.adoc b/cli_reference/openshift_cli/developer-cli-commands.adoc index 4d9a991d2674..1da707496fb7 100644 --- a/cli_reference/openshift_cli/developer-cli-commands.adoc +++ b/cli_reference/openshift_cli/developer-cli-commands.adoc @@ -6,9 +6,11 @@ include::_attributes/common-attributes.adoc[] toc::[] -This reference provides descriptions and example commands for OpenShift CLI (`oc`) developer commands. +[role="_abstract"] +To learn more about the {oc-first} developer commands, review their descriptions and example commands. + ifdef::openshift-enterprise,openshift-origin[] -For administrator commands, see the xref:../../cli_reference/openshift_cli/administrator-cli-commands.adoc#cli-administrator-commands[OpenShift CLI administrator command reference]. +For administrator commands, see the "OpenShift CLI administrator command reference". endif::openshift-enterprise,openshift-origin[] Run `oc help` to list all commands or run `oc --help` to get additional details for a specific command. diff --git a/cli_reference/openshift_cli/extending-cli-plugins.adoc b/cli_reference/openshift_cli/extending-cli-plugins.adoc index 6349032ce1b3..ad1f518bba84 100644 --- a/cli_reference/openshift_cli/extending-cli-plugins.adoc +++ b/cli_reference/openshift_cli/extending-cli-plugins.adoc @@ -6,8 +6,8 @@ include::_attributes/common-attributes.adoc[] toc::[] -You can write and install plugins to build on the default `oc` commands, -allowing you to perform new and more complex tasks with the +[role="_abstract"] +You can write and install plugins to build on the default `oc` commands, allowing you to perform new and more complex tasks with the ifndef::openshift-dedicated,openshift-rosa,openshift-rosa-hcp[] {product-title} endif::openshift-dedicated,openshift-rosa,openshift-rosa-hcp[] diff --git a/cli_reference/openshift_cli/managing-cli-profiles.adoc b/cli_reference/openshift_cli/managing-cli-profiles.adoc index ab122c7ebccc..4a063e6d1e71 100644 --- a/cli_reference/openshift_cli/managing-cli-profiles.adoc +++ b/cli_reference/openshift_cli/managing-cli-profiles.adoc @@ -6,18 +6,22 @@ include::_attributes/common-attributes.adoc[] toc::[] -A CLI configuration file allows you to configure different profiles, or contexts, for use with the xref:../../cli_reference/index.adoc#cli-tools-overview[CLI tools overview]. A context consists of -ifndef::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[] -xref:../../authentication/understanding-authentication.adoc#understanding-authentication[user authentication] -endif::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[] -ifdef::microshift[] -user authentication -endif::[] -a {product-title} -server information associated with a _nickname_. +[role="_abstract"] +You can use a CLI configuration file to create different profiles, or contexts, for use with the {oc-first}. A context consists of user authentication and a {product-title} server information associated with a _nickname_. include::modules/about-cli-profiles-switch.adoc[leveloffset=+1] -include::modules/manual-configuration-of-cli-profiles.adoc[leveloffset=+1] +include::modules/manual-configuration-of-cli-profiles-example.adoc[leveloffset=+1] + +include::modules/manual-configuration-of-cli-profiles.adoc[leveloffset=+2] include::modules/load-and-merge-rules.adoc[leveloffset=+1] + +[role="_additional-resources"] +[id="additional-resources_managing-cli-profiles"] +== Additional resources + +* xref:../../cli_reference/index.adoc#cli-tools-overview[CLI tools overview] +ifndef::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[] +* xref:../../authentication/understanding-authentication.adoc#understanding-authentication[user authentication] +endif::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[] diff --git a/modules/about-cli-profiles-switch.adoc b/modules/about-cli-profiles-switch.adoc index 9d71c914edff..402dbb7b3f41 100644 --- a/modules/about-cli-profiles-switch.adoc +++ b/modules/about-cli-profiles-switch.adoc @@ -4,18 +4,18 @@ :_mod-docs-content-type: CONCEPT [id="about-switches-between-cli-profiles_{context}"] -= About switches between CLI profiles += About switching between CLI profiles -Contexts allow you to easily switch between multiple users across multiple {product-title} servers, or clusters, when using CLI operations. Nicknames make managing CLI configurations easier by providing short-hand references to contexts, user credentials, and cluster details. -After a user logs in with the `oc` CLI for the first time, -{product-title} creates a `~/.kube/config` file if one does not already exist. As more authentication and connection details are provided to the CLI, either automatically during an `oc login` operation or by manually configuring CLI profiles, the updated information is stored in the configuration file: +[role="_abstract"] +You can use contexts to easily switch between users across multiple {product-title} clusters when using the {oc-first}. You specify a nickname to make managing CLI configurations easier by providing short-hand references to contexts, user credentials, and cluster details. -.CLI config file +After a user logs in with the `oc` CLI for the first time, {product-title} creates a `~/.kube/config` file if one does not already exist. As more authentication and connection details are provided to the CLI, either automatically during an `oc login` operation or by manually configuring CLI profiles, the updated information is stored in the configuration file: +.CLI configuration file [source,yaml] ---- apiVersion: v1 -clusters: <1> +clusters: - cluster: insecure-skip-tls-verify: true server: https://openshift1.example.com:8443 @@ -24,7 +24,7 @@ clusters: <1> insecure-skip-tls-verify: true server: https://openshift2.example.com:8443 name: openshift2.example.com:8443 -contexts: <2> +contexts: - context: cluster: openshift1.example.com:8443 namespace: alice-project @@ -35,7 +35,7 @@ contexts: <2> namespace: joe-project user: alice/openshift1.example.com:8443 name: joe-project/openshift1/alice -current-context: joe-project/openshift1.example.com:8443/alice <3> +current-context: joe-project/openshift1.example.com:8443/alice kind: Config preferences: {} users: <4> @@ -43,17 +43,16 @@ users: <4> user: token: xZHd2piv5_9vQrg-SKXRJ2Dsl9SceNJdhNTljEKTb8k ---- +where: -<1> The `clusters` section defines connection details for -{product-title} clusters, including the address for their master server. In this example, one cluster is nicknamed `openshift1.example.com:8443` and another is nicknamed `openshift2.example.com:8443`. -<2> This `contexts` section defines two contexts: one nicknamed `alice-project/openshift1.example.com:8443/alice`, using the `alice-project` project, `openshift1.example.com:8443` cluster, and `alice` user, and another nicknamed `joe-project/openshift1.example.com:8443/alice`, using the `joe-project` project, `openshift1.example.com:8443` cluster and `alice` user. -<3> The `current-context` parameter shows that the `joe-project/openshift1.example.com:8443/alice` context is currently in use, allowing the `alice` user to work in the `joe-project` project on the `openshift1.example.com:8443` cluster. -<4> The `users` section defines user credentials. In this example, the user nickname `alice/openshift1.example.com:8443` uses an access token. +`clusters`:: Specifies connection details for {product-title} clusters, including the address for their master server. In this example, one cluster is nicknamed `openshift1.example.com:8443` and another is nicknamed `openshift2.example.com:8443`. +`contexts`:: Specifies two contexts: one nicknamed `alice-project/openshift1.example.com:8443/alice`, using the `alice-project` project, `openshift1.example.com:8443` cluster, and `alice` user, and another nicknamed `joe-project/openshift1.example.com:8443/alice`, using the `joe-project` project, `openshift1.example.com:8443` cluster and `alice` user. +`current-context`:: Specifies that the `joe-project/openshift1.example.com:8443/alice` context is currently in use, allowing the `alice` user to work in the `joe-project` project on the `openshift1.example.com:8443` cluster. +`users`:: Specifies user credentials. In this example, the user nickname `alice/openshift1.example.com:8443` uses an access token. The CLI can support multiple configuration files which are loaded at runtime and merged together along with any override options specified from the command line. After you are logged in, you can use the `oc status` or `oc project` command to verify your current working environment: .Verify the current working environment - [source,terminal,options="nowrap"] ---- $ oc status @@ -62,7 +61,6 @@ $ oc status .Example output [source,terminal] ---- -oc status In project Joe's Project (joe-project) service database (172.30.43.12:5434 -> 3306) @@ -107,7 +105,7 @@ At any time, you can use the `oc config view` command to view your current CLI c [NOTE] ==== -If you have access to administrator credentials but are no longer logged in as the default system user `system:admin`, you can log back in as this user at any time as long as the credentials are still present in your CLI config file. The following command logs in and switches to the default project: +If you have access to administrator credentials but are no longer logged in as the default system user `system:admin`, you can log back in as this user at any time as long as the credentials are still present in your CLI configuration file. The following command logs in and switches to the default project: [source,terminal] ---- diff --git a/modules/cli-configuring-kubeconfig-using-cli.adoc b/modules/cli-configuring-kubeconfig-using-cli.adoc index e1fd4c465b0c..ebc04690c6c3 100644 --- a/modules/cli-configuring-kubeconfig-using-cli.adoc +++ b/modules/cli-configuring-kubeconfig-using-cli.adoc @@ -6,8 +6,14 @@ [id="cli-accessing-kubeconfig-using-cli_{context}"] = Accessing kubeconfig by using the oc CLI +[role="_abstract"] You can use the `oc` CLI to log in to your OpenShift cluster and retrieve a kubeconfig file for accessing the cluster from the command line. +[IMPORTANT] +==== +If you plan to reuse the exported `kubeconfig` file across sessions or machines, store it securely and avoid committing it to source control. +==== + .Prerequisites * You have access to the {product-title} web console or API server endpoint. @@ -18,12 +24,14 @@ You can use the `oc` CLI to log in to your OpenShift cluster and retrieve a kube + [source,terminal] ---- -$ oc login -u -p <1><2><3> +$ oc login -u -p ---- + -<1> Specify the full API server URL. For example: `https://api.my-cluster.example.com:6443`. -<2> Specify a valid username. For example: `kubeadmin`. -<3> Provide the password for the specified user. For example, the `kubeadmin` password generated during cluster installation. +where: + +``:: Specifies the full API server URL; for example, `https://api.my-cluster.example.com:6443`. +``:: Specifies a valid username; for example, `kubeadmin`. +``:: Specifies the password for the specified user; for example, the `kubeadmin` password generated during cluster installation. . Save the cluster configuration to a local file by running the following command: + @@ -45,8 +53,3 @@ $ export KUBECONFIG=./kubeconfig ---- $ oc get nodes ---- - -[NOTE] -==== -If you plan to reuse the exported `kubeconfig` file across sessions or machines, store it securely and avoid committing it to source control. -==== \ No newline at end of file diff --git a/modules/cli-extending-plugins-installing.adoc b/modules/cli-extending-plugins-installing.adoc index cc31faadcf29..ab2232328a7d 100644 --- a/modules/cli-extending-plugins-installing.adoc +++ b/modules/cli-extending-plugins-installing.adoc @@ -6,6 +6,7 @@ [id="cli-installing-plugins_{context}"] = Installing and using CLI plugins +[role="_abstract"] After you write a custom plugin for the ifndef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] {product-title} @@ -13,8 +14,7 @@ endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] ifdef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] OpenShift endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] -CLI, you must install -the plugin before use. +CLI, you must install the plugin before use. .Prerequisites @@ -50,13 +50,10 @@ The following compatible plugins are available: /usr/local/bin/ ---- + -If your plugin is not listed here, verify that the file begins with `oc-` -or `kubectl-`, is executable, and is on your `PATH`. +If your plugin is not listed here, verify that the file begins with `oc-` or `kubectl-`, is executable, and is on your `PATH`. . Invoke the new command or option introduced by the plugin. + -For example, if you built and installed the `kubectl-ns` plugin from the - link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository], - you can use the following command to view the current namespace. +For example, if you built and installed the `kubectl-ns` plugin from the link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository], you can use the following command to view the current namespace. + [source,terminal] ---- @@ -64,5 +61,4 @@ $ oc ns ---- + Note that the command to invoke the plugin depends on the plugin file name. -For example, a plugin with the file name of `oc-foo-bar` is invoked by the `oc foo bar` -command. +For example, a plugin with the file name of `oc-foo-bar` is invoked by the `oc foo bar` command. diff --git a/modules/cli-extending-plugins-writing.adoc b/modules/cli-extending-plugins-writing.adoc index 628ae774fc4c..f18cfe92887e 100644 --- a/modules/cli-extending-plugins-writing.adoc +++ b/modules/cli-extending-plugins-writing.adoc @@ -6,6 +6,7 @@ [id="cli-writing-plugins_{context}"] = Writing CLI plugins +[role="_abstract"] You can write a plugin for the ifndef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] {product-title} @@ -13,14 +14,11 @@ endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] ifdef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] OpenShift endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] -CLI in any programming language -or script that allows you to write command-line commands. Note that you can not -use a plugin to overwrite an existing `oc` command. +CLI in any programming language or script that allows you to write command-line commands. Note that you cannot use a plugin to overwrite an existing `oc` command. -.Procedure +This procedure creates a simple Bash plugin that prints a message to the terminal when the `oc foo` command is issued. -This procedure creates a simple Bash plugin that prints a message to the -terminal when the `oc foo` command is issued. +.Procedure . Create a file called `oc-foo`. + @@ -28,11 +26,7 @@ When naming your plugin file, keep the following in mind: * The file must begin with `oc-` or `kubectl-` to be recognized as a plugin. -* The file name determines the command that invokes the plugin. For example, a -plugin with the file name `oc-foo-bar` can be invoked by a command of -`oc foo bar`. You can also use underscores if you want the command to contain -dashes. For example, a plugin with the file name `oc-foo_bar` can be invoked -by a command of `oc foo-bar`. +* The file name determines the command that invokes the plugin. For example, a plugin with the file name `oc-foo-bar` can be invoked by a command of `oc foo bar`. You can also use underscores if you want the command to contain dashes. For example, a plugin with the file name `oc-foo_bar` can be invoked by a command of `oc foo-bar`. . Add the following contents to the file. + @@ -56,7 +50,7 @@ fi echo "I am a plugin named kubectl-foo" ---- - ++ After you install this plugin for the ifndef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] {product-title} @@ -64,12 +58,10 @@ endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[] ifdef::openshift-rosa,openshift-rosa-hcp[] OpenShift endif::openshift-rosa,openshift-rosa-hcp[] -CLI, it can be invoked -using the `oc foo` command. +CLI, it can be invoked using the `oc foo` command. [role="_additional-resources"] .Additional resources -* Review the link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository] -for an example of a plugin written in Go. -* Review the link:https://github.com/kubernetes/cli-runtime/[CLI runtime repository] for a set of utilities to assist in writing plugins in Go. +* link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository] +* link:https://github.com/kubernetes/cli-runtime/[CLI runtime repository] diff --git a/modules/load-and-merge-rules.adoc b/modules/load-and-merge-rules.adoc index 3c3802fad749..f49bc2b8d58c 100644 --- a/modules/load-and-merge-rules.adoc +++ b/modules/load-and-merge-rules.adoc @@ -6,9 +6,10 @@ [id="load-and-merge-rules_{context}"] = Load and merge rules -You can follow these rules, when issuing CLI operations for the loading and merging order for the CLI configuration: +[role="_abstract"] +Review the rules that {oc-first} uses for the loading and merging order for the CLI configuration. -* CLI config files are retrieved from your workstation, using the following hierarchy and merge rules: +* CLI configuration files are retrieved from your workstation, using the following hierarchy and merge rules: ** If the `--config` option is set, then only that file is loaded. The flag is set once and no merging takes place. ** If the `$KUBECONFIG` environment variable is set, then it is used. The variable can be a list of paths, and if so the paths are merged together. When a value is modified, it is modified in the file that defines the stanza. When a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the last file in the list. @@ -17,7 +18,7 @@ You can follow these rules, when issuing CLI operations for the loading and merg * The context to use is determined based on the first match in the following flow: ** The value of the `--context` option. -** The `current-context` value from the CLI config file. +** The `current-context` value from the CLI configuration file. ** An empty value is allowed at this stage. * The user and cluster to use is determined. At this point, you may or may not have a context; they are built based on the first match in the following flow, which is run once for the user and once for the cluster: @@ -33,7 +34,7 @@ cluster name. *** `--insecure-skip-tls-verify` ** If cluster information and a value for the attribute is present, then use it. ** If you do not have a server location, then there is an error. -* The actual user information to use is determined. Users are built using the same rules as clusters, except that you can only have one authentication technique per user; conflicting techniques cause the operation to fail. Command-line options take precedence over config file values. Valid command-line options are: +* The actual user information to use is determined. Users are built using the same rules as clusters, except that you can only have one authentication technique per user; conflicting techniques cause the operation to fail. Command-line options take precedence over configuration file values. Valid command-line options are: ** `--auth-path` ** `--client-certificate` ** `--client-key` diff --git a/modules/manual-configuration-of-cli-profiles-example.adoc b/modules/manual-configuration-of-cli-profiles-example.adoc new file mode 100644 index 000000000000..b1b46cf8aefa --- /dev/null +++ b/modules/manual-configuration-of-cli-profiles-example.adoc @@ -0,0 +1,73 @@ +// Module included in the following assemblies: +// +// * cli_reference/openshift_cli/managing-cli-profiles.adoc + +:_mod-docs-content-type: PROCEDURE +[id="manual-configuration-of-cli-profiles-example_{context}"] += Manually configuring CLI profiles + +[role="_abstract"] +If you want to manually configure your CLI configuration files, you can use the `oc config` command instead of directly modifying the files. + +[NOTE] +==== +This section covers more advanced usage of CLI configurations. In most situations, you can use the `oc login` and `oc project` commands to log in and switch between contexts and projects. +==== + +// TODO, Add a non-xref reference to the reference table. no need to additional resources i think, since it'll be right after + +.Procedure + +. Log in as a user that uses an access token. This token is used by the `alice` user: ++ +[source,terminal,options="nowrap"] +---- +$ oc login https://openshift1.example.com --token=ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0 +---- + +. View the cluster entry automatically created: ++ +[source,terminal,options="nowrap"] +---- +$ oc config view +---- ++ +.Example output +[source,terminal] +---- +apiVersion: v1 +clusters: +- cluster: + insecure-skip-tls-verify: true + server: https://openshift1.example.com + name: openshift1-example-com +contexts: +- context: + cluster: openshift1-example-com + namespace: default + user: alice/openshift1-example-com + name: default/openshift1-example-com/alice +current-context: default/openshift1-example-com/alice +kind: Config +preferences: {} +users: +- name: alice/openshift1.example.com + user: + token: ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0 +---- + +. Update the current context to have users log in to the desired namespace: ++ +[source,terminal] +---- +$ oc config set-context `oc config current-context` --namespace= +---- + +. Examine the current context, to confirm that the changes are implemented: ++ +[source,terminal] +---- +$ oc whoami -c +---- ++ +All subsequent CLI operations uses the new context, unless otherwise specified by overriding CLI options or until the context is switched. diff --git a/modules/manual-configuration-of-cli-profiles.adoc b/modules/manual-configuration-of-cli-profiles.adoc index 3d68804f6c5e..ef4c686af186 100644 --- a/modules/manual-configuration-of-cli-profiles.adoc +++ b/modules/manual-configuration-of-cli-profiles.adoc @@ -2,16 +2,14 @@ // // * cli_reference/openshift_cli/managing-cli-profiles.adoc -:_mod-docs-content-type: CONCEPT +:_mod-docs-content-type: REFERENCE [id="manual-configuration-of-cli-profiles_{context}"] = Manual configuration of CLI profiles -[NOTE] -==== -This section covers more advanced usage of CLI configurations. In most situations, you can use the `oc login` and `oc project` commands to log in and switch between contexts and projects. -==== +[role="_abstract"] +TODO -If you want to manually configure your CLI config files, you can use the `oc config` command instead of directly modifying the files. The `oc config` command includes a number of helpful sub-commands for this purpose: +The `oc config` command includes several helpful sub-commands for this purpose: .CLI configuration subcommands [cols="1,8",options="header"] @@ -20,7 +18,7 @@ If you want to manually configure your CLI config files, you can use the `oc con |Subcommand |Usage a|`set-cluster` -a|Sets a cluster entry in the CLI config file. If the referenced cluster +a|Sets a cluster entry in the CLI configuration file. If the referenced cluster nickname already exists, the specified information is merged in. [source,terminal,options="nowrap"] ---- @@ -30,7 +28,7 @@ $ oc config set-cluster [--server=] ---- a|`set-context` -a|Sets a context entry in the CLI config file. If the referenced context +a|Sets a context entry in the CLI configuration file. If the referenced context nickname already exists, the specified information is merged in. [source,terminal,options="nowrap"] ---- @@ -46,7 +44,7 @@ $ oc config use-context ---- a|`set` -a|Sets an individual value in the CLI config file. +a|Sets an individual value in the CLI configuration file. [source,terminal,options="nowrap"] ---- $ oc config set @@ -54,7 +52,7 @@ $ oc config set The `` is a dot-delimited name where each token represents either an attribute name or a map key. The `` is the new value being set. a|`unset` -a|Unsets individual values in the CLI config file. +a|Unsets individual values in the CLI configuration file. [source,terminal,options="nowrap"] ---- $ oc config unset @@ -68,66 +66,9 @@ a|Displays the merged CLI configuration currently in use. $ oc config view ---- -Displays the result of the specified CLI config file. +Displays the result of the specified CLI configuration file. [source,terminal,options="nowrap"] ---- $ oc config view --config= ---- |=== - -.Example usage - -* Log in as a user that uses an access token. -This token is used by the `alice` user: - -[source,terminal,options="nowrap"] ----- -$ oc login https://openshift1.example.com --token=ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0 ----- - -* View the cluster entry automatically created: - -[source,terminal,options="nowrap"] ----- -$ oc config view ----- - -.Example output -[source,terminal] ----- -apiVersion: v1 -clusters: -- cluster: - insecure-skip-tls-verify: true - server: https://openshift1.example.com - name: openshift1-example-com -contexts: -- context: - cluster: openshift1-example-com - namespace: default - user: alice/openshift1-example-com - name: default/openshift1-example-com/alice -current-context: default/openshift1-example-com/alice -kind: Config -preferences: {} -users: -- name: alice/openshift1.example.com - user: - token: ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0 ----- - -* Update the current context to have users log in to the desired namespace: - -[source,terminal] ----- -$ oc config set-context `oc config current-context` --namespace= ----- - -* Examine the current context, to confirm that the changes are implemented: - -[source,terminal] ----- -$ oc whoami -c ----- - -All subsequent CLI operations uses the new context, unless otherwise specified by overriding CLI options or until the context is switched.