-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hack/doc: Autogen CLI Documentation #2099
Merged
theishshah
merged 28 commits into
operator-framework:master
from
theishshah:autogen-cli-docs
Nov 7, 2019
Merged
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
2295b20
init structure
cea6def
makefile updates, compiling
bff365b
working file tree
a9a2168
updated dir
068022d
initial draft of generated docs
dd162ff
update changelog
b403140
go mod tidy
9ae21b2
Merge branch 'master' into autogen-cli-docs
e66b57e
add hugo headers to docs
5e0861a
merge conflicts
c474c3f
more merge confs
150b2ec
fix md block tree formatting
7404e4c
remove header logic
db0d64b
updated docs
fdba426
add sanity test
8e62f6e
add script
ac98d00
update path
5c26d2a
path re-fix
80135fe
tidy
c39a115
mod tidy
30d7118
updated docs
fd45d32
changlog command update
8065f19
Update hack/doc/gen-cli-doc.go
7e2d365
Update hack/doc/gen-cli-doc.go
aa0e9a1
Update hack/doc/gen-cli-doc.go
e6d595a
format nits
4fed398
Merge branch 'autogen-cli-docs' of github.com:theishshah/operator-sdk…
8c45788
fmt fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,126 @@ | ||
// Copyright 2019 The Operator-SDK 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 cli | ||
|
||
import ( | ||
|
||
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) | ||
// to ensure that `run` and `up local` can make use of them. | ||
_ "k8s.io/client-go/plugin/pkg/client/auth" | ||
|
||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/add" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/build" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/migrate" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/new" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/olmcatalog" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/printdeps" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/run" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/scorecard" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/test" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/up" | ||
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/version" | ||
"github.com/operator-framework/operator-sdk/internal/flags" | ||
"github.com/operator-framework/operator-sdk/internal/util/projutil" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// GetCLIRoot is intended to creeate the base command structure for the OSDK for use in CLI and documentation | ||
func GetCLIRoot() *cobra.Command { | ||
root := &cobra.Command{ | ||
Use: "operator-sdk", | ||
Short: "An SDK for building operators with ease", | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
if viper.GetBool(flags.VerboseOpt) { | ||
if err := projutil.SetGoVerbose(); err != nil { | ||
log.Fatalf("Could not set GOFLAGS: (%v)", err) | ||
} | ||
log.SetLevel(log.DebugLevel) | ||
log.Debug("Debug logging is set") | ||
} | ||
if err := checkGoModulesForCmd(cmd); err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
root.AddCommand(add.NewCmd()) | ||
root.AddCommand(alpha.NewCmd()) | ||
root.AddCommand(build.NewCmd()) | ||
root.AddCommand(completion.NewCmd()) | ||
root.AddCommand(generate.NewCmd()) | ||
root.AddCommand(migrate.NewCmd()) | ||
root.AddCommand(new.NewCmd()) | ||
root.AddCommand(olmcatalog.NewCmd()) | ||
root.AddCommand(printdeps.NewCmd()) | ||
root.AddCommand(run.NewCmd()) | ||
root.AddCommand(scorecard.NewCmd()) | ||
root.AddCommand(test.NewCmd()) | ||
root.AddCommand(up.NewCmd()) | ||
root.AddCommand(version.NewCmd()) | ||
|
||
return root | ||
} | ||
|
||
func checkGoModulesForCmd(cmd *cobra.Command) (err error) { | ||
// Certain commands are able to be run anywhere or handle this check | ||
// differently in their CLI code. | ||
if skipCheckForCmd(cmd) { | ||
return nil | ||
} | ||
// Do not perform this check if the project is non-Go, as they will not | ||
// be using go modules. | ||
if !projutil.IsOperatorGo() { | ||
return nil | ||
} | ||
// Do not perform a go modules check if the working directory is not in | ||
// the project root, as some sub-commands might not require project root. | ||
// Individual subcommands will perform this check as needed. | ||
if err := projutil.CheckProjectRoot(); err != nil { | ||
return nil | ||
} | ||
|
||
return projutil.CheckGoModules() | ||
} | ||
|
||
var commandsToSkip = map[string]struct{}{ | ||
"new": struct{}{}, // Handles this logic in cmd/operator-sdk/new | ||
"migrate": struct{}{}, // Handles this logic in cmd/operator-sdk/migrate | ||
"operator-sdk": struct{}{}, // Alias for "help" | ||
"help": struct{}{}, | ||
"completion": struct{}{}, | ||
"version": struct{}{}, | ||
"print-deps": struct{}{}, // Does not require this logic | ||
} | ||
|
||
func skipCheckForCmd(cmd *cobra.Command) (skip bool) { | ||
if _, ok := commandsToSkip[cmd.Name()]; ok { | ||
return true | ||
} | ||
cmd.VisitParents(func(pc *cobra.Command) { | ||
if _, ok := commandsToSkip[pc.Name()]; ok { | ||
// The bare "operator-sdk" command will be checked above. | ||
if pc.Name() != "operator-sdk" { | ||
skip = true | ||
} | ||
} | ||
}) | ||
return skip | ||
} |
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,32 @@ | ||
## operator-sdk | ||
|
||
An SDK for building operators with ease | ||
|
||
### Synopsis | ||
|
||
An SDK for building operators with ease | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for operator-sdk | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [operator-sdk add](operator-sdk_add.md) - Adds a controller or resource to the project | ||
* [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand | ||
* [operator-sdk build](operator-sdk_build.md) - Compiles code and builds artifacts | ||
* [operator-sdk completion](operator-sdk_completion.md) - Generators for shell completions | ||
* [operator-sdk generate](operator-sdk_generate.md) - Invokes specific generator | ||
* [operator-sdk migrate](operator-sdk_migrate.md) - Adds source code to an operator | ||
* [operator-sdk new](operator-sdk_new.md) - Creates a new operator application | ||
* [operator-sdk olm-catalog](operator-sdk_olm-catalog.md) - Invokes a olm-catalog command | ||
* [operator-sdk print-deps](operator-sdk_print-deps.md) - Print Golang packages and versions required to run the operator | ||
* [operator-sdk run](operator-sdk_run.md) - Runs a generic operator | ||
* [operator-sdk scorecard](operator-sdk_scorecard.md) - Run scorecard tests | ||
* [operator-sdk test](operator-sdk_test.md) - Tests the operator | ||
* [operator-sdk up](operator-sdk_up.md) - Launches the operator | ||
* [operator-sdk version](operator-sdk_version.md) - Prints the version of operator-sdk | ||
|
||
###### Auto generated by spf13/cobra on 23-Oct-2019 |
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,22 @@ | ||
## operator-sdk add | ||
|
||
Adds a controller or resource to the project | ||
|
||
### Synopsis | ||
|
||
Adds a controller or resource to the project | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for add | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [operator-sdk](operator-sdk.md) - An SDK for building operators with ease | ||
* [operator-sdk add api](operator-sdk_add_api.md) - Adds a new api definition under pkg/apis | ||
* [operator-sdk add controller](operator-sdk_add_controller.md) - Adds a new controller pkg | ||
* [operator-sdk add crd](operator-sdk_add_crd.md) - Adds a Custom Resource Definition (CRD) and the Custom Resource (CR) files | ||
|
||
###### Auto generated by spf13/cobra on 23-Oct-2019 |
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,56 @@ | ||
## operator-sdk add api | ||
|
||
Adds a new api definition under pkg/apis | ||
|
||
### Synopsis | ||
|
||
operator-sdk add api --kind=<kind> --api-version=<group/version> creates the | ||
api definition for a new custom resource under pkg/apis. This command must be | ||
run from the project root directory. If the api already exists at | ||
pkg/apis/<group>/<version> then the command will not overwrite and return an | ||
error. | ||
|
||
By default, this command runs Kubernetes deepcopy and OpenAPI V3 generators on | ||
tagged types in all paths under pkg/apis. Go code is generated under | ||
pkg/apis/<group>/<version>/zz_generated.{deepcopy,openapi}.go. CRD's are | ||
generated, or updated if they exist for a particular group + version + kind, | ||
under deploy/crds/<full group>_<resource>_crd.yaml; OpenAPI V3 validation YAML | ||
is generated as a 'validation' object. Generation can be disabled with the | ||
--skip-generation flag. | ||
|
||
Example: | ||
estroz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$ operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=AppService | ||
$ tree pkg/apis | ||
pkg/apis/ | ||
├── addtoscheme_app_appservice.go | ||
├── apis.go | ||
└── app | ||
└── v1alpha1 | ||
├── doc.go | ||
├── register.go | ||
├── appservice_types.go | ||
├── zz_generated.deepcopy.go | ||
├── zz_generated.openapi.go | ||
$ tree deploy/crds | ||
├── deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml | ||
├── deploy/crds/app.example.com_appservices_crd.yaml | ||
|
||
|
||
``` | ||
operator-sdk add api [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
--api-version string Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1) | ||
-h, --help help for api | ||
--kind string Kubernetes resource Kind name. (e.g AppService) | ||
--skip-generation Skip generation of deepcopy and OpenAPI code and OpenAPI CRD specs | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [operator-sdk add](operator-sdk_add.md) - Adds a controller or resource to the project | ||
|
||
###### Auto generated by spf13/cobra on 23-Oct-2019 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Optional] Could this be
cli-doc
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, done.