Skip to content

Commit cbe91a2

Browse files
ryanemersonperdasilva
authored andcommitted
Add skip-tls-verify and use-http flag support to opm render #908 (#909)
Signed-off-by: Ryan Emerson <[email protected]> Upstream-repository: operator-registry Upstream-commit: 9999f79682d0073bf9ed5edf2cca1476abf2fc9a
1 parent 63b1606 commit cbe91a2

File tree

2 files changed

+66
-0
lines changed
  • staging/operator-registry/cmd/opm/render
  • vendor/github.com/operator-framework/operator-registry/cmd/opm/render

2 files changed

+66
-0
lines changed

staging/operator-registry/cmd/opm/render/cmd.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111

1212
"github.com/operator-framework/operator-registry/alpha/action"
1313
"github.com/operator-framework/operator-registry/alpha/declcfg"
14+
"github.com/operator-framework/operator-registry/cmd/opm/internal/util"
15+
containerd "github.com/operator-framework/operator-registry/pkg/image/containerdregistry"
1416
"github.com/operator-framework/operator-registry/pkg/sqlite"
1517
)
1618

@@ -44,6 +46,29 @@ func NewCmd() *cobra.Command {
4446
// returned from render.Run and logged as fatal errors.
4547
logrus.SetOutput(ioutil.Discard)
4648

49+
skipTLSVerify, useHTTP, err := util.GetTLSOptions(cmd)
50+
if err != nil {
51+
log.Fatal(err)
52+
}
53+
54+
cacheDir, err := os.MkdirTemp("", "render-registry-")
55+
if err != nil {
56+
log.Fatal(err)
57+
}
58+
59+
reg, err := containerd.NewRegistry(
60+
containerd.WithCacheDir(cacheDir),
61+
containerd.SkipTLSVerify(skipTLSVerify),
62+
containerd.WithPlainHTTP(useHTTP),
63+
containerd.WithLog(nullLogger()),
64+
)
65+
if err != nil {
66+
log.Fatalf("creating containerd registry: %v", err)
67+
}
68+
defer reg.Destroy()
69+
70+
render.Registry = reg
71+
4772
cfg, err := render.Run(cmd.Context())
4873
if err != nil {
4974
log.Fatal(err)
@@ -55,5 +80,13 @@ func NewCmd() *cobra.Command {
5580
},
5681
}
5782
cmd.Flags().StringVarP(&output, "output", "o", "json", "Output format (json|yaml)")
83+
cmd.Flags().Bool("skip-tls-verify", false, "disable TLS verification")
84+
cmd.Flags().Bool("use-http", false, "use plain HTTP")
5885
return cmd
5986
}
87+
88+
func nullLogger() *logrus.Entry {
89+
logger := logrus.New()
90+
logger.SetOutput(ioutil.Discard)
91+
return logrus.NewEntry(logger)
92+
}

vendor/github.com/operator-framework/operator-registry/cmd/opm/render/cmd.go

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)