From 5c29eb13bb373e1fbd5f2e205a533042db403e34 Mon Sep 17 00:00:00 2001 From: OpenShift Cherrypick Robot Date: Tue, 8 Mar 2022 12:42:18 -0800 Subject: [PATCH] Add --version command (#57) Co-authored-by: Dave O'Connor --- Dockerfile | 5 ++++- Dockerfile.online | 5 ++++- Makefile | 2 ++ README.md | 14 ++++++++++++++ cmd/install.go | 2 +- cmd/root.go | 6 +++++- cmd/upgrade.go | 2 +- 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index a60dcc8b..60247b97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +ARG RELEASE_VERSION=${RELEASE_VERSION} ARG QUAY_IMAGE=${QUAY_IMAGE} ARG EE_IMAGE=${EE_IMAGE} ARG EE_BASE_IMAGE=${EE_BASE_IMAGE} @@ -10,6 +11,7 @@ ARG PAUSE_IMAGE=${PAUSE_IMAGE} FROM registry.redhat.io/ubi8:latest AS cli # Need to duplicate these, otherwise they won't be available to the stage +ARG RELEASE_VERSION=${RELEASE_VERSION} ARG QUAY_IMAGE=${QUAY_IMAGE} ARG EE_IMAGE=${EE_IMAGE} ARG POSTGRES_IMAGE=${POSTGRES_IMAGE} @@ -28,6 +30,7 @@ COPY . /cli WORKDIR /cli # Create CLI +ENV RELEASE_VERSION=${RELEASE_VERSION} ENV EE_IMAGE=${EE_IMAGE} ENV QUAY_IMAGE=${QUAY_IMAGE} ENV REDIS_IMAGE=${REDIS_IMAGE} @@ -35,7 +38,7 @@ ENV POSTGRES_IMAGE=${POSTGRES_IMAGE} ENV PAUSE_IMAGE=${PAUSE_IMAGE} RUN go build -v \ - -ldflags "-X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE} -X github.com/quay/mirror-registry/cmd.postgresImage=${POSTGRES_IMAGE}" \ + -ldflags "-X github.com/quay/mirror-registry/cmd.releaseVersion=${RELEASE_VERSION} -X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE} -X github.com/quay/mirror-registry/cmd.postgresImage=${POSTGRES_IMAGE}" \ -o mirror-registry # Create Ansible Execution Environment diff --git a/Dockerfile.online b/Dockerfile.online index 17a585bf..6b2f9857 100644 --- a/Dockerfile.online +++ b/Dockerfile.online @@ -1,3 +1,4 @@ +ARG RELEASE_VERSION=${RELEASE_VERSION} ARG EE_BASE_IMAGE=${EE_BASE_IMAGE} ARG EE_BUILDER_IMAGE=${EE_BUILDER_IMAGE} @@ -5,6 +6,7 @@ ARG EE_BUILDER_IMAGE=${EE_BUILDER_IMAGE} FROM registry.redhat.io/ubi8:latest AS cli # Need to duplicate these, otherwise they won't be available to the stage +ARG RELEASE_VERSION=${RELEASE_VERSION} ARG QUAY_IMAGE=${QUAY_IMAGE} ARG EE_IMAGE=${EE_IMAGE} ARG POSTGRES_IMAGE=${POSTGRES_IMAGE} @@ -23,6 +25,7 @@ COPY . /cli WORKDIR /cli # Create CLI +ENV RELEASE_VERSION=${RELEASE_VERSION} ENV EE_IMAGE=${EE_IMAGE} ENV QUAY_IMAGE=${QUAY_IMAGE} ENV REDIS_IMAGE=${REDIS_IMAGE} @@ -30,7 +33,7 @@ ENV POSTGRES_IMAGE=${POSTGRES_IMAGE} ENV PAUSE_IMAGE=${PAUSE_IMAGE} RUN go build -v \ - -ldflags "-X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE} -X github.com/quay/mirror-registry/cmd.postgresImage=${POSTGRES_IMAGE}" \ + -ldflags "-X github.com/quay/mirror-registry/cmd.releaseVersion=${RELEASE_VERSION} -X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE} -X github.com/quay/mirror-registry/cmd.postgresImage=${POSTGRES_IMAGE}" \ -o mirror-registry # Create Ansible Execution Environment diff --git a/Makefile b/Makefile index 27a50001..27395a23 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ build-golang-executable: build-online-zip: sudo podman build \ -t mirror-registry-online:${RELEASE_VERSION} \ + --build-arg RELEASE_VERSION=${RELEASE_VERSION} \ --build-arg QUAY_IMAGE=${QUAY_IMAGE} \ --build-arg EE_IMAGE=${EE_IMAGE} \ --build-arg EE_BASE_IMAGE=${EE_BASE_IMAGE} \ @@ -24,6 +25,7 @@ build-online-zip: build-offline-zip: sudo podman build \ -t mirror-registry-offline:${RELEASE_VERSION} \ + --build-arg RELEASE_VERSION=${RELEASE_VERSION} \ --build-arg QUAY_IMAGE=${QUAY_IMAGE} \ --build-arg EE_IMAGE=${EE_IMAGE} \ --build-arg EE_BASE_IMAGE=${EE_BASE_IMAGE} \ diff --git a/README.md b/README.md index a3e38e81..aae50ba6 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,20 @@ $ podman pull quay:8443/init/busybox:latest --tls-verify=false Prior to pushing quay:8443/init/busybox, you must create the repository "busybox" in the Quay console. In future versions of mirror registry this will be created automatically. +## Upgrade + +To upgrade Quay from localhost, run the following command: + +```console +$ sudo ./mirror-registry upgrade -v +``` + +To upgrade Quay from a remote host, run the following command: + +```console +$ ./mirror-registry upgrade -v --targetHostname some.remote.host.com --targetUsername someuser -k ~/.ssh/my_ssh_key +``` + ## Uninstall To uninstall Quay from localhost, run the following command: diff --git a/cmd/install.go b/cmd/install.go index 081aea1a..42a7f812 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -64,7 +64,7 @@ var quayRoot string // additionalArgs are arguments that you would like to append to the end of the ansible-playbook call (used mostly for development) var additionalArgs string -// installCmd represents the validate command +// installCmd represents the install command var installCmd = &cobra.Command{ Use: "install", Short: "Install Quay and its required dependencies.", diff --git a/cmd/root.go b/cmd/root.go index 472a47bf..eb502fe7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,13 +17,17 @@ var log = &logrus.Logger{ // verbose is the optional command that will display INFO logs var verbose bool +// version is an optional command that will display the current release version +var releaseVersion string + func init() { rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Display verbose logs") } var ( rootCmd = &cobra.Command{ - Use: "mirror-registry", + Use: "mirror-registry", + Version: releaseVersion, PersistentPreRun: func(cmd *cobra.Command, args []string) { if verbose { log.SetLevel(logrus.DebugLevel) diff --git a/cmd/upgrade.go b/cmd/upgrade.go index 06096664..9ff0b407 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -13,7 +13,7 @@ import ( "github.com/spf13/cobra" ) -// upgradeCmd represents the validate command +// upgradeCmd represents the upgrade command var upgradeCmd = &cobra.Command{ Use: "upgrade", Short: "Upgrade all mirror registry images.",