Skip to content

Commit cfead21

Browse files
Merge pull request openshift#161 from njhale/fix-catalog-build
Bug 1771329: only build adm catalog command for linux
2 parents 1cfe371 + 8f04216 commit cfead21

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

pkg/cli/admin/admin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericc
126126
release.NewCmd(f, fullName, streams),
127127
buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, streams),
128128
verifyimagesignature.NewCmdVerifyImageSignature(name, fullName+" "+verifyimagesignature.VerifyRecommendedName, f, streams),
129-
catalog.NewCmd(streams),
130129

131130
// part of every root command
132131
kubectlwrappers.NewCmdConfig(fullName, "config", f, streams),
@@ -135,6 +134,7 @@ func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericc
135134
// hidden
136135
options.NewCmdOptions(streams),
137136
)
137+
catalog.AddCommand(streams, cmds)
138138

139139
return cmds
140140
}

pkg/cli/admin/catalog/catalog.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build linux
2+
13
package catalog
24

35
import (
@@ -8,7 +10,13 @@ import (
810
"k8s.io/kubectl/pkg/util/templates"
911
)
1012

11-
func NewCmd(streams genericclioptions.IOStreams) *cobra.Command {
13+
func init() {
14+
addCommand = func(streams genericclioptions.IOStreams, cmd *cobra.Command) {
15+
cmd.AddCommand(newCmd(streams))
16+
}
17+
}
18+
19+
func newCmd(streams genericclioptions.IOStreams) *cobra.Command {
1220
cmd := &cobra.Command{
1321
Use: "catalog",
1422
Short: "Tools for managing the OpenShift OLM Catalogs",

pkg/cli/admin/catalog/cmd.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package catalog
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"k8s.io/cli-runtime/pkg/genericclioptions"
7+
)
8+
9+
var addCommand func(streams genericclioptions.IOStreams, cmd *cobra.Command)
10+
11+
// AddCommand adds the catalog subcommand to the given command.
12+
// The subcommand is only added when built on supporting OSes (linux).
13+
func AddCommand(streams genericclioptions.IOStreams, cmd *cobra.Command) {
14+
if addCommand == nil {
15+
return
16+
}
17+
18+
addCommand(streams, cmd)
19+
}

0 commit comments

Comments
 (0)