-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPCT-242: Introduce command 'get images' (#83)
Introduce `opct get images` to export all images used by OPCT (not for OCP cluster). It includes the flag `--to-repository` to export in the mirror format: - [x] create `get images` command - [x] update documentation - [x] patch plugins to support mirrors on etcdfio and MGM redhat-openshift-ecosystem/provider-certification-plugins#48 Default: ```sh $ ./build/opct-linux-amd64 get images quay.io/ocp-cert/sonobuoy:v0.56.10 quay.io/ocp-cert/openshift-tests-provider-cert:v0.4.1 quay.io/opct/must-gather-monitoring:v0.1.0 quay.io/openshift-scale/etcd-perf:latest registry.k8s.io/pause:3.8 ``` - with mirror flag `--to-repository` ```sh $ ./build/opct-linux-amd64 get images --to-repository registry.example.com/validation quay.io/ocp-cert/sonobuoy:v0.56.10 registry.example.com/validation/sonobuoy:v0.56.10 quay.io/ocp-cert/openshift-tests-provider-cert:v0.4.1 registry.example.com/validation/openshift-tests-provider-cert:v0.4.1 quay.io/opct/must-gather-monitoring:v0.1.0 registry.example.com/validation/must-gather-monitoring:v0.1.0 quay.io/openshift-scale/etcd-perf:latest registry.example.com/validation/etcd-perf:latest registry.k8s.io/pause:3.8 registry.example.com/validation/ocp-cert:e2e-28-registry-k8s-io-pause-3-8-aP7uYsw5XCmoDy5W ```
- Loading branch information
Showing
5 changed files
with
133 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package get | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg" | ||
"github.com/spf13/cobra" | ||
"github.com/vmware-tanzu/sonobuoy/pkg/buildinfo" | ||
) | ||
|
||
type imageOptions struct { | ||
ToRepository string | ||
} | ||
|
||
var options *imageOptions | ||
|
||
var imagesCmd = &cobra.Command{ | ||
Use: "images", | ||
Short: "Print images used by OPCT.", | ||
Run: runGetImages, | ||
} | ||
|
||
func init() { | ||
options = new(imageOptions) | ||
imagesCmd.Flags().StringVar(&options.ToRepository, "to-repository", "", "Show images with format to mirror to repository. Example: registry.example.io:5000") | ||
} | ||
|
||
func generateImage(repo, name string) string { | ||
if options.ToRepository == "" { | ||
return fmt.Sprintf("%s/%s", repo, name) | ||
} else { | ||
from := fmt.Sprintf("%s/%s", repo, name) | ||
to := fmt.Sprintf("%s/%s", options.ToRepository, name) | ||
return fmt.Sprintf("%s %s", from, to) | ||
} | ||
} | ||
|
||
func runGetImages(cmd *cobra.Command, args []string) { | ||
|
||
images := []string{} | ||
|
||
// Sonobuoy | ||
images = append(images, generateImage("quay.io/ocp-cert", fmt.Sprintf("sonobuoy:%s", buildinfo.Version))) | ||
|
||
// Plugins | ||
images = append(images, generateImage("quay.io/ocp-cert", pkg.PluginsImage)) | ||
images = append(images, generateImage("quay.io/opct", "must-gather-monitoring:v0.1.0")) | ||
|
||
// etcdfio | ||
img_etcdfio := "quay.io/openshift-scale/etcd-perf:latest" | ||
if options.ToRepository == "" { | ||
images = append(images, img_etcdfio) | ||
} else { | ||
to := fmt.Sprintf("%s/%s", options.ToRepository, "etcd-perf:latest") | ||
images = append(images, fmt.Sprintf("%s %s", img_etcdfio, to)) | ||
} | ||
|
||
// test's specific images (not related with OPCT) | ||
img_e2epause := "registry.k8s.io/pause:3.8" | ||
if options.ToRepository == "" { | ||
images = append(images, img_e2epause) | ||
} else { | ||
to := fmt.Sprintf("%s/%s", options.ToRepository, "ocp-cert:e2e-28-registry-k8s-io-pause-3-8-aP7uYsw5XCmoDy5W") | ||
images = append(images, fmt.Sprintf("%s %s", img_e2epause, to)) | ||
} | ||
|
||
for _, image := range images { | ||
fmt.Println(image) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package get | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var getCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "Get tool information.", | ||
Run: runGet, | ||
} | ||
|
||
func init() { | ||
getCmd.AddCommand(imagesCmd) | ||
} | ||
|
||
func NewCmdGet() *cobra.Command { | ||
return getCmd | ||
} | ||
|
||
func runGet(cmd *cobra.Command, args []string) { | ||
fmt.Println("Nothing to do. See -h for more options.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters