-
Notifications
You must be signed in to change notification settings - Fork 1.8k
cli (new): add run packagemanifests
#3253
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
|
|
||
| olmcatalog "github.com/operator-framework/operator-sdk/internal/generate/olm-catalog" | ||
| olmoperator "github.com/operator-framework/operator-sdk/internal/olm/operator" | ||
| kbutil "github.com/operator-framework/operator-sdk/internal/util/kubebuilder" | ||
| "github.com/operator-framework/operator-sdk/internal/util/projutil" | ||
| ) | ||
|
|
||
|
|
@@ -35,16 +36,23 @@ func NewCmd() *cobra.Command { | |
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "packagemanifests", | ||
| Short: "Run an Operator organized in the package manifests format with OLM", | ||
| Short: "Deploy an Operator in the package manifests format with OLM", | ||
| Long: `'run packagemanifests' deploys an Operator's package manifests with OLM. The command's argument | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we have a choice between
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tengqm the reason we're thinking of using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the info, @joelanford. I am just not a big fan of long commands, :).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @estroz Perhaps we could add a cobra alias for this (e.g.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM, I'll make a follow-up.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| must be set to a valid package manifests root directory, ex. '<project-root>/packagemanifests'.`, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| if len(args) > 0 { | ||
| if len(args) > 1 { | ||
| return fmt.Errorf("exactly one argument is required") | ||
| } | ||
| c.ManifestsDir = args[0] | ||
| } else { | ||
| operatorName := filepath.Base(projutil.MustGetwd()) | ||
| c.ManifestsDir = filepath.Join(olmcatalog.OLMCatalogDir, operatorName) | ||
| // Choose the default path depending on project configuration. | ||
| if kbutil.HasProjectFile() { | ||
| c.ManifestsDir = "packagemanifests" | ||
| } else { | ||
| operatorName := filepath.Base(projutil.MustGetwd()) | ||
| c.ManifestsDir = filepath.Join(olmcatalog.OLMCatalogDir, operatorName) | ||
| } | ||
| } | ||
|
|
||
| log.Infof("Running operator from directory %s", c.ManifestsDir) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright 2020 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 internal | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os/exec" | ||
|
|
||
| . "github.com/onsi/ginkgo" //nolint:golint | ||
|
|
||
| kbtestutils "sigs.k8s.io/kubebuilder/test/e2e/utils" | ||
| ) | ||
|
|
||
| // TestContext wraps kubebuilder's e2e TestContext. | ||
| type TestContext struct { | ||
| *kbtestutils.TestContext | ||
| } | ||
|
|
||
| // NewTestContext returns a TestContext containing a new kubebuilder TestContext. | ||
| func NewTestContext(env ...string) (tc TestContext, err error) { | ||
| tc.TestContext, err = kbtestutils.NewTestContext("operator-sdk", env...) | ||
| return tc, err | ||
| } | ||
|
|
||
| // InstallOLM runs 'operator-sdk olm install' and returns any errors emitted by that command. | ||
| func (tc TestContext) InstallOLM() error { | ||
| cmd := exec.Command(tc.BinaryName, "olm", "install", "--timeout", "4m") | ||
| _, err := tc.Run(cmd) | ||
| return err | ||
| } | ||
|
|
||
| // InstallOLM runs 'operator-sdk olm uninstall' and logs any errors emitted by that command. | ||
| func (tc TestContext) UninstallOLM() { | ||
| cmd := exec.Command(tc.BinaryName, "olm", "uninstall") | ||
| if _, err := tc.Run(cmd); err != nil { | ||
| fmt.Fprintln(GinkgoWriter, "warning: error when uninstalling OLM:", err) | ||
| } | ||
| } | ||
|
|
||
| // KustomizeBuild runs 'kustomize build <dir>' and returns its output and an error if any. | ||
| func (tc TestContext) KustomizeBuild(dir string) ([]byte, error) { | ||
| return tc.Run(exec.Command("kustomize", "build", dir)) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| title: "operator-sdk run" | ||
| --- | ||
| ## operator-sdk run | ||
|
|
||
| Run an Operator in a variety of environments | ||
|
|
||
| ### Synopsis | ||
|
|
||
| This command has subcommands that will deploy your Operator with OLM. | ||
| Currently only the package manifests format is supported via the 'packagemanifests' subcommand. | ||
| Run 'operator-sdk run --help' for more information. | ||
|
|
||
|
|
||
| ### Options | ||
|
|
||
| ``` | ||
| -h, --help help for run | ||
| ``` | ||
|
|
||
| ### Options inherited from parent commands | ||
|
|
||
| ``` | ||
| --verbose Enable verbose logging | ||
| ``` | ||
|
|
||
| ### SEE ALSO | ||
|
|
||
| * [operator-sdk](../operator-sdk) - Development kit for building Kubernetes extensions and tools. | ||
| * [operator-sdk run packagemanifests](../operator-sdk_run_packagemanifests) - Deploy an Operator in the package manifests format with OLM | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --- | ||
| title: "operator-sdk run packagemanifests" | ||
| --- | ||
| ## operator-sdk run packagemanifests | ||
|
|
||
| Deploy an Operator in the package manifests format with OLM | ||
|
|
||
| ### Synopsis | ||
|
|
||
| 'run packagemanifests' deploys an Operator's package manifests with OLM. The command's argument | ||
| must be set to a valid package manifests root directory, ex. '<project-root>/packagemanifests'. | ||
|
|
||
| ``` | ||
| operator-sdk run packagemanifests [flags] | ||
| ``` | ||
|
|
||
| ### Options | ||
|
|
||
| ``` | ||
| -h, --help help for packagemanifests | ||
| --include strings Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup | ||
| --install-mode string InstallMode to create OperatorGroup with. Format: InstallModeType[=ns1,ns2[, ...]] | ||
| --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set | ||
| --olm-namespace string The namespace where OLM is installed (default "olm") | ||
| --operator-namespace string The namespace where operator resources are created. It must already exist in the cluster or be defined in a manifest passed to --include | ||
| --operator-version string Version of operator to deploy | ||
| --timeout duration Time to wait for the command to complete before failing (default 2m0s) | ||
| ``` | ||
|
|
||
| ### Options inherited from parent commands | ||
|
|
||
| ``` | ||
| --verbose Enable verbose logging | ||
| ``` | ||
|
|
||
| ### SEE ALSO | ||
|
|
||
| * [operator-sdk run](../operator-sdk_run) - Run an Operator in a variety of environments | ||
|
|
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.
helm/Ansible still requiring run
operator-sdk run --localwith the new layout.