From c0b4a029123269565cc24676eeec905fedc3c0c8 Mon Sep 17 00:00:00 2001 From: Martin Maly Date: Wed, 23 Feb 2022 19:07:05 +0000 Subject: [PATCH] Add `alpha` command group (#2820) Add `alpha` command group to enable iterating on early stage features. --- commands/alphacmd.go | 45 +++++++++++++++++++++++ commands/commands.go | 3 +- internal/docs/generated/alphadocs/docs.go | 7 ++++ internal/docs/generated/overview/docs.go | 13 ++++--- main.go | 1 + site/reference/cli/README.md | 14 ++++--- site/reference/cli/alpha/README.md | 16 ++++++++ 7 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 commands/alphacmd.go create mode 100644 internal/docs/generated/alphadocs/docs.go create mode 100644 site/reference/cli/alpha/README.md diff --git a/commands/alphacmd.go b/commands/alphacmd.go new file mode 100644 index 0000000000..399017bcb2 --- /dev/null +++ b/commands/alphacmd.go @@ -0,0 +1,45 @@ +// Copyright 2022 Google LLC +// +// 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" + + "github.com/GoogleContainerTools/kpt/internal/docs/generated/alphadocs" + "github.com/spf13/cobra" +) + +func GetAlphaCommand(ctx context.Context, name string) *cobra.Command { + alpha := &cobra.Command{ + Use: "alpha", + Short: alphadocs.AlphaShort, + Long: alphadocs.AlphaLong, + RunE: func(cmd *cobra.Command, args []string) error { + h, err := cmd.Flags().GetBool("help") + if err != nil { + return err + } + if h { + return cmd.Help() + } + return cmd.Usage() + }, + Hidden: true, + } + + // TODO: add individual commands + + return alpha +} diff --git a/commands/commands.go b/commands/commands.go index cc9cb0e53a..7eb75274eb 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -35,8 +35,9 @@ func GetKptCommands(ctx context.Context, name, version string) []*cobra.Command fnCmd := GetFnCommand(ctx, name) pkgCmd := GetPkgCommand(ctx, name) liveCmd := GetLiveCommand(ctx, name, version) + alphaCmd := GetAlphaCommand(ctx, name) - c = append(c, pkgCmd, fnCmd, liveCmd) + c = append(c, pkgCmd, fnCmd, liveCmd, alphaCmd) // apply cross-cutting issues to commands NormalizeCommand(c...) diff --git a/internal/docs/generated/alphadocs/docs.go b/internal/docs/generated/alphadocs/docs.go new file mode 100644 index 0000000000..d9ec506faf --- /dev/null +++ b/internal/docs/generated/alphadocs/docs.go @@ -0,0 +1,7 @@ +// Code generated by "mdtogo"; DO NOT EDIT. +package alphadocs + +var AlphaShort = `This command is currently in alpha and might change without notice.` +var AlphaLong = ` +The ` + "`" + `alpha` + "`" + ` command group contains subcommands which are in alpha and might change without notice. +` diff --git a/internal/docs/generated/overview/docs.go b/internal/docs/generated/overview/docs.go index 2c045b2be4..ad20b3b014 100644 --- a/internal/docs/generated/overview/docs.go +++ b/internal/docs/generated/overview/docs.go @@ -7,11 +7,12 @@ All kpt commands follow this general synopsis: kpt [PKG_PATH] [flags] -kpt functionality is divided into three command groups: +kpt functionality is divided into following command groups: -| Group | Description | -| ------ | --------------------------------------------------------------------- | -| [pkg] | get, update, and describe packages with resources. | -| [fn] | generate, transform, validate packages using containerized functions. | -| [live] | deploy local configuration packages to a cluster. | +| Group | Description | +| ------- | --------------------------------------------------------------------- | +| [pkg] | get, update, and describe packages with resources. | +| [fn] | generate, transform, validate packages using containerized functions. | +| [live] | deploy local configuration packages to a cluster. | +| [alpha] | commands currently in alpha and might change without notice. | ` diff --git a/main.go b/main.go index 0ecaeb7900..b45b40a511 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ //go:generate $GOBIN/mdtogo site/reference/cli/live internal/docs/generated/livedocs --license=none --recursive=true --strategy=cmdDocs //go:generate $GOBIN/mdtogo site/reference/cli/pkg internal/docs/generated/pkgdocs --license=none --recursive=true --strategy=cmdDocs //go:generate $GOBIN/mdtogo site/reference/cli/fn internal/docs/generated/fndocs --license=none --recursive=true --strategy=cmdDocs +//go:generate $GOBIN/mdtogo site/reference/cli/alpha internal/docs/generated/alphadocs --license=none --recursive=true --strategy=cmdDocs //go:generate $GOBIN/mdtogo site/reference/cli/README.md internal/docs/generated/overview --license=none --strategy=cmdDocs package main diff --git a/site/reference/cli/README.md b/site/reference/cli/README.md index c97643c705..656b06d45b 100755 --- a/site/reference/cli/README.md +++ b/site/reference/cli/README.md @@ -12,16 +12,18 @@ All kpt commands follow this general synopsis: kpt [PKG_PATH] [flags] ``` -kpt functionality is divided into three command groups: +kpt functionality is divided into following command groups: -| Group | Description | -| ------ | --------------------------------------------------------------------- | -| [pkg] | get, update, and describe packages with resources. | -| [fn] | generate, transform, validate packages using containerized functions. | -| [live] | deploy local configuration packages to a cluster. | +| Group | Description | +| ------- | --------------------------------------------------------------------- | +| [pkg] | get, update, and describe packages with resources. | +| [fn] | generate, transform, validate packages using containerized functions. | +| [live] | deploy local configuration packages to a cluster. | +| [alpha] | commands currently in alpha and might change without notice. | [pkg]: /reference/cli/pkg/ [fn]: /reference/cli/fn/ [live]: /reference/cli/live/ +[alpha]: /reference/cli/alpha/ \ No newline at end of file diff --git a/site/reference/cli/alpha/README.md b/site/reference/cli/alpha/README.md new file mode 100644 index 0000000000..5bd43b690d --- /dev/null +++ b/site/reference/cli/alpha/README.md @@ -0,0 +1,16 @@ +--- +title: "`alpha`" +linkTitle: "alpha" +type: docs +weight: 4 +description: > + This command is currently in alpha and might change without notice. +--- + + + + +The `alpha` command group contains subcommands which are in alpha and might change without notice. +