Skip to content

Commit

Permalink
removal: new cmd for Helm projects
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed Jul 4, 2020
1 parent 19b21f9 commit 8b62c4d
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 353 deletions.
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ jobs:
services:
- docker

# Build and test helm
- <<: *test
name: Helm on Kubernetes
script: make test-e2e-helm

## Image deploy/push stage jobs ##

# Build and deploy arm64 ansible-operator docker image
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ test-subcommand-olm-install:
./hack/tests/subcommand-olm-install.sh

# E2E tests.
.PHONY: test-e2e test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm
.PHONY: test-e2e test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule

test-e2e: test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm ## Run the e2e tests
test-e2e: test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule ## Run the e2e tests

test-e2e-go:
./hack/tests/e2e-go.sh $(ARGS)
Expand All @@ -272,9 +272,6 @@ test-e2e-ansible: image-build-ansible
test-e2e-ansible-molecule: image-build-ansible
./hack/tests/e2e-ansible-molecule.sh

test-e2e-helm: image-build-helm
./hack/tests/e2e-helm.sh

# Integration tests.
.PHONY: test-integration

Expand Down
17 changes: 17 additions & 0 deletions changelog/fragments/remove-new-cmd-for-helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
The `operator-sdk new` command no longer supports scaffolding new Helm projects with the `--type=Helm` flag.
To scaffold new projects, users are expected to use `operator-sdk init --plugins=helm.operator-sdk.io/v1` as part of the
[new CLI]((https://sdk.operatorframework.io/docs/new-cli)) for Helm operators.
See `operator-sdk init --plugins=helm.operator-sdk.io/v1 -h` and the following doc on how to scaffold a new project
https://sdk.operatorframework.io/docs/helm/quickstart/. To migrate existing projects to the new layout see:
https://sdk.operatorframework.io/docs/helm/migration.
kind: "removal"
# Is this a breaking change?
breaking: false
11 changes: 11 additions & 0 deletions cmd/operator-sdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ func main() {
"https://sdk.operatorframework.io/docs/golang/migration/project_migration_guide/\n"
projutil.PrintDeprecationWarning(depMsg)
}

//nolint:lll
if operatorType == projutil.OperatorTypeHelm {
depMsg := "Operator SDK has a new CLI and project layout that is aligned with Kubebuilder.\n" +
"See `operator-sdk init --plugins=helm.operator-sdk.io/v1 -h` and the following doc on how to scaffold a new project:\n" +
"https://sdk.operatorframework.io/docs/helm/quickstart/\n" +
"To migrate existing projects to the new layout see:\n" +
"https://sdk.operatorframework.io/docs/helm/migration\n"
projutil.PrintDeprecationWarning(depMsg)
}

if err := cli.RunLegacy(); err != nil {
log.Fatal(err)
}
Expand Down
70 changes: 4 additions & 66 deletions cmd/operator-sdk/new/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/operator-framework/operator-sdk/internal/genutil"
"github.com/operator-framework/operator-sdk/internal/scaffold"
"github.com/operator-framework/operator-sdk/internal/scaffold/ansible"
"github.com/operator-framework/operator-sdk/internal/scaffold/helm"
"github.com/operator-framework/operator-sdk/internal/scaffold/input"
"github.com/operator-framework/operator-sdk/internal/util/projutil"
)
Expand Down Expand Up @@ -56,44 +55,12 @@ generates a default directory layout based on the input <project-name>.
$ operator-sdk new app-operator --type=ansible \
--api-version=app.example.com/v1alpha1 \
--kind=AppService
# Helm project
$ operator-sdk new app-operator --type=helm \
--api-version=app.example.com/v1alpha1 \
--kind=AppService
$ operator-sdk new app-operator --type=helm \
--api-version=app.example.com/v1alpha1 \
--kind=AppService \
--helm-chart=myrepo/app
$ operator-sdk new app-operator --type=helm \
--helm-chart=myrepo/app
$ operator-sdk new app-operator --type=helm \
--helm-chart=myrepo/app \
--helm-chart-version=1.2.3
$ operator-sdk new app-operator --type=helm \
--helm-chart=app \
--helm-chart-repo=https://charts.mycompany.com/
$ operator-sdk new app-operator --type=helm \
--helm-chart=app \
--helm-chart-repo=https://charts.mycompany.com/ \
--helm-chart-version=1.2.3
$ operator-sdk new app-operator --type=helm \
--helm-chart=/path/to/local/chart-directories/app/
$ operator-sdk new app-operator --type=helm \
--helm-chart=/path/to/local/chart-archives/app-1.2.3.tgz
`,
RunE: newFunc,
}

newCmd.Flags().StringVar(&operatorType, "type", "",
"Type of operator to initialize (choices: \"ansible\" or \"helm\")")
"Type of operator to initialize (choices: \"ansible\")")
if err := newCmd.MarkFlagRequired("type"); err != nil {
log.Fatalf("Failed to mark `type` flag for `new` subcommand as required")
}
Expand All @@ -111,7 +78,7 @@ generates a default directory layout based on the input <project-name>.
"Generate a playbook skeleton. (Only used for --type ansible)")

// Initialize flagSet struct with common flags
apiFlags.AddTo(newCmd.Flags())
apiFlags.AddToNew(newCmd.Flags())

return newCmd
}
Expand Down Expand Up @@ -140,35 +107,6 @@ func newFunc(cmd *cobra.Command, args []string) error {
if err := doAnsibleScaffold(); err != nil {
log.Fatal(err)
}
case projutil.OperatorTypeHelm:
// create the project dir
err := os.MkdirAll(projectName, 0755)
if err != nil {
log.Fatal(err)
}
// go inside of the project dir
err = os.Chdir(filepath.Join(projutil.MustGetwd(), projectName))
if err != nil {
log.Fatal(err)
}

cfg := input.Config{
AbsProjectPath: filepath.Join(projutil.MustGetwd()),
ProjectName: projectName,
}

createOpts := helm.CreateChartOptions{
ResourceAPIVersion: apiFlags.APIVersion,
ResourceKind: apiFlags.Kind,
Chart: apiFlags.HelmChartRef,
Version: apiFlags.HelmChartVersion,
Repo: apiFlags.HelmChartRepo,
CRDVersion: apiFlags.CrdVersion,
}

if err := helm.Init(cfg, createOpts); err != nil {
log.Fatal(err)
}
}
//todo: remove before 1.0.0
if gitInit {
Expand Down Expand Up @@ -303,8 +241,8 @@ func doAnsibleScaffold() error {
}

func verifyFlags() error {
if operatorType != projutil.OperatorTypeAnsible && operatorType != projutil.OperatorTypeHelm {
return fmt.Errorf("value of --type can only be `ansible`, or `helm`: %v",
if operatorType != projutil.OperatorTypeAnsible {
return fmt.Errorf("value of --type can only be `ansible`: %v",
projutil.ErrUnknownOperatorType{Type: operatorType})
}
if operatorType != projutil.OperatorTypeAnsible && generatePlaybook {
Expand Down
193 changes: 0 additions & 193 deletions hack/tests/e2e-helm.sh

This file was deleted.

17 changes: 17 additions & 0 deletions internal/flags/apiflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ type APIFlags struct {
HelmChartRepo string
}

// AddToNew - Add the reconcile period and watches file flags to the the flagset
// helpTextPrefix will allow you add a prefix to default help text. Joined by a space.
// It has just the flags valid for Ansible
func (f *APIFlags) AddToNew(flagSet *pflag.FlagSet) {
flagSet.StringVar(&f.APIVersion, "api-version", "",
"Kubernetes apiVersion and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)")

flagSet.StringVar(&f.Kind, "kind", "",
"Kubernetes resource Kind name. (e.g AppService)")

flagSet.BoolVar(&f.SkipGeneration, "skip-generation", false,
"Skip generation of deepcopy and OpenAPI code and OpenAPI CRD specs")

flagSet.StringVar(&f.CrdVersion, "crd-version", gencrd.DefaultCRDVersion,
"CRD version to generate")
}

// AddTo - Add the reconcile period and watches file flags to the the flagset
// helpTextPrefix will allow you add a prefix to default help text. Joined by a space.
func (f *APIFlags) AddTo(flagSet *pflag.FlagSet) {
Expand Down
Loading

0 comments on commit 8b62c4d

Please sign in to comment.