/ocp_pick

Primary LanguageJava

ocp_pick

1. Purpose

Do you often need to switch across many different OpenShift environments ?

In doing so, do you often struggle recollecting what user to log in as ? Or what the URL to the master node of your OCP environment is ? Or what version of oc utility to use ?

This utility provides assistance with login to one of many possible OpenShift Container Platform environments so that you can more easily switch between them.

2. Usage

  1. Install libxcrypt-compat package:

    $ sudo dnf install -y libxcrypt-compat
  2. Download the latest release of this utility and place in a location on your $PATH:

    $ release='v.2'
    
    $ curl -L https://github.com/jbride/ocp_pick/releases/download/$release/ocp_pick -o $HOME/bin/ocp_pick \
           && chmod 755 $HOME/bin/ocp_pick
  3. This ocp_pick utility reads a configuration file (in yaml format) of all of your OCP environments.

    Download an example config file :

    $ curl https://raw.githubusercontent.com/jbride/ocp_pick/$release/src/test/resources/ocp_env_details.yaml -o $HOME/.ocp_env_details.yml
  4. Edit this $HOME/.ocp_env_details.yml configuration file as necessary

  5. View the help:

    $ ocp_pick --help

3. Build and use from source

  1. Ensure GraalVM is installed and its java and javac utilities are on your $PATH

  2. Ensure Maven 3.5 (or more recent) is installed.

  3. Clone this git repo

  4. Change directory into this project

3.1. Native executable

3.1.1. Use Maven plugin to build native executable

  1. Build a java artifact and compile to a native executable:

    $ mvn clean package
  2. Execute this utility as a native executable:

    $ ./target/ocp_pick --help
  3. This maven project makes use of the com.oracle.substratevm:native-image-maven-plugin for compilation to a native binary. You can optionaly view the details of this plugin as follows:

    $ mvn help:describe -Dplugin=com.oracle.substratevm:native-image-maven-plugin -Ddetail
Use native-image utility to build native executable:
$ mvn clean package -Dnative.skip=true
$ native-image -cp /u02/maven/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/u02/maven/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar:/u02/maven/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/u01/other/ocp_pick/target/ocp_pick-1.0.jar -H:IncludeResources='.*.properties|.*META-INF/persistence.xml|.*.xsd' -H:ReflectionConfigurationFiles=target/classes/graal.json -H:Class=com.ratwater.jbride.OCPick -H:Name=target/ocp_pick

3.2. Java byecode executable:

$ mvn clean package -Dnative.skip=true
$ java -jar target/ocp_pick-1.0.jar