mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
Adds build/commands package to expose which commands should be
registered. Gates the completion command which is disabled by defualt. Can be configured at build time. Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["commands.go"],
|
||||
importpath = "github.com/jetstack/cert-manager/cmd/ctl/pkg/build/commands",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//cmd/ctl/pkg/approve:go_default_library",
|
||||
"//cmd/ctl/pkg/check:go_default_library",
|
||||
"//cmd/ctl/pkg/completion:go_default_library",
|
||||
"//cmd/ctl/pkg/convert:go_default_library",
|
||||
"//cmd/ctl/pkg/create:go_default_library",
|
||||
"//cmd/ctl/pkg/deny:go_default_library",
|
||||
"//cmd/ctl/pkg/experimental:go_default_library",
|
||||
"//cmd/ctl/pkg/inspect:go_default_library",
|
||||
"//cmd/ctl/pkg/renew:go_default_library",
|
||||
"//cmd/ctl/pkg/status:go_default_library",
|
||||
"//cmd/ctl/pkg/version:go_default_library",
|
||||
"@com_github_spf13_cobra//:go_default_library",
|
||||
"@io_k8s_cli_runtime//pkg/genericclioptions:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright 2020 The cert-manager Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/approve"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/check"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/completion"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/convert"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/create"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/deny"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/experimental"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/inspect"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/renew"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/status"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/version"
|
||||
)
|
||||
|
||||
// registerCompletion gates whether the completion command is registered.
|
||||
// Specifically useful when building the CLI as a kubectl plugin which does not
|
||||
// support completion.
|
||||
var registerCompletion = "false"
|
||||
|
||||
type RegisterCommandFunc func(context.Context, genericclioptions.IOStreams) *cobra.Command
|
||||
|
||||
// Commands returns the cobra Commands that should be registered for the CLI
|
||||
// build.
|
||||
func Commands() []RegisterCommandFunc {
|
||||
cmds := []RegisterCommandFunc{
|
||||
version.NewCmdVersion,
|
||||
convert.NewCmdConvert,
|
||||
create.NewCmdCreate,
|
||||
renew.NewCmdRenew,
|
||||
status.NewCmdStatus,
|
||||
inspect.NewCmdInspect,
|
||||
approve.NewCmdApprove,
|
||||
deny.NewCmdDeny,
|
||||
check.NewCmdCheck,
|
||||
|
||||
// Experimental features
|
||||
experimental.NewCmdExperimental,
|
||||
}
|
||||
|
||||
if strings.ToLower(registerCompletion) == "true" {
|
||||
cmds = append(cmds, completion.NewCmdCompletion)
|
||||
}
|
||||
|
||||
return cmds
|
||||
}
|
||||
Reference in New Issue
Block a user