Skip to content

Remove legacy CLI, code, and scaffold templates #3385

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

Merged
merged 13 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 4 additions & 60 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ x_base_steps:
- make setup-k8s
- export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
after_success:
- echo "Build succeeded, operator was generated, memcached operator is running on $CLUSTER, and unit/integration tests pass"
- echo "Tests passed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great 👍

after_failure:
- echo "Build failed, operator failed to generate, memcached operator is not running on $CLUSTER, or unit/integration tests failed"
- echo "Tests failed"
- kubectl get all --all-namespaces
- kubectl get events --all-namespaces --field-selector=type=Warning
services:
Expand Down Expand Up @@ -132,9 +132,9 @@ jobs:
name: Subcommands on Kubernetes
script: make test-subcommand

# Build and test go for legacy project layouts
# Build and test go
- <<: *test
name: Go for legacy project layouts on Kubernetes
name: Go on Kubernetes
before_script:
- (cd / && go get github.com/mattn/goveralls)
script:
Expand All @@ -144,31 +144,13 @@ jobs:
after_success:
- $GOPATH/bin/goveralls -service=travis-ci -coverprofile=coverage.out -repotoken=$COVERALLS_TOKEN

# Build and test go for new project layouts
- name: Go e2e tests for new project layouts
before_install:
# hack/ci/check-doc-only-update.sh needs to be sourced so
# that it can properly exit the test early with success
- source hack/ci/check-doc-only-update.sh
script:
- make test-e2e-go-new
after_success:
- echo "E2E tests passed"
after_failure:
- echo "E2E tests failed"
- kubectl get all --all-namespaces
- kubectl get events --all-namespaces --field-selector=type=Warning
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
- stage: deploy
<<: *deploy
Expand Down Expand Up @@ -234,38 +216,6 @@ jobs:
- make image-build-helm
- make image-push-helm

# Build and deploy arm64 scorecard-proxy docker image
- <<: *deploy
name: Docker image for scorecard-proxy (arm64)
arch: arm64
script:
- make image-build-scorecard-proxy
- make image-push-scorecard-proxy

# Build and deploy amd64 scorecard-proxy docker image
- <<: *deploy
name: Docker image for scorecard-proxy (amd64)
arch: amd64
script:
- make image-build-scorecard-proxy
- make image-push-scorecard-proxy

# Build and deploy ppc64le scorecard-proxy docker image
- <<: *deploy
name: Docker image for scorecard-proxy (ppc64le)
arch: ppc64le
script:
- make image-build-scorecard-proxy
- make image-push-scorecard-proxy

# Build and deploy s390x scorecard-proxy docker image
- <<: *deploy
name: Docker image for scorecard-proxy (s390x)
arch: s390x
script:
- make image-build-scorecard-proxy
- make image-push-scorecard-proxy

Comment on lines -237 to -268
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ That's one less set of images to fail during a build :)

Copy link
Contributor

@camilamacedo86 camilamacedo86 Jul 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but do you not need these images? Pinging @jmccormick2001 who is their father just for we sure if it is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the scorecard-proxy is not used in the new scorecard so its fine to remove.

# Build and deploy arm64 scorecard-test docker image
- <<: *deploy
name: Docker image for scorecard-test (arm64)
Expand Down Expand Up @@ -319,12 +269,6 @@ jobs:
script:
- make image-push-helm-multiarch

# Build and deploy scorecard-proxy multi-arch manifest list
- <<: *manifest-deploy
name: Manifest list for scorecard-proxy
script:
- make image-push-scorecard-proxy-multiarch

# Build and deploy scorecard-test multi-arch manifest list
- <<: *manifest-deploy
name: Manifest list for scorecard-test
Expand Down
35 changes: 7 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ GO_BUILD_ARGS = \

ANSIBLE_BASE_IMAGE = quay.io/operator-framework/ansible-operator
HELM_BASE_IMAGE = quay.io/operator-framework/helm-operator
SCORECARD_PROXY_BASE_IMAGE = quay.io/operator-framework/scorecard-proxy
SCORECARD_TEST_BASE_IMAGE = quay.io/operator-framework/scorecard-test
SCORECARD_TEST_KUTTL_BASE_IMAGE = quay.io/operator-framework/scorecard-test-kuttl

ANSIBLE_IMAGE ?= $(ANSIBLE_BASE_IMAGE)
HELM_IMAGE ?= $(HELM_BASE_IMAGE)
SCORECARD_PROXY_IMAGE ?= $(SCORECARD_PROXY_BASE_IMAGE)
SCORECARD_TEST_IMAGE ?= $(SCORECARD_TEST_BASE_IMAGE)
SCORECARD_TEST_KUTTL_IMAGE ?= $(SCORECARD_TEST_KUTTL_BASE_IMAGE)

ANSIBLE_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
HELM_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
SCORECARD_PROXY_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
SCORECARD_TEST_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
SCORECARD_TEST_KUTTL_ARCHES:="amd64" "ppc64le" "s390x" "arm64"

Expand Down Expand Up @@ -185,9 +182,9 @@ build/%.asc: ## Create release signatures for operator-sdk release binaries

image: image-build image-push ## Build and push all images

image-build: image-build-ansible image-build-helm image-build-scorecard-proxy image-build-scorecard-test image-build-scorecard-test-kuttl## Build all images
image-build: image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl## Build all images

image-push: image-push-ansible image-push-helm image-push-scorecard-proxy image-push-scorecard-test ## Push all images
image-push: image-push-ansible image-push-helm image-push-scorecard-test ## Push all images

# Ansible operator image scaffold/build/push.
.PHONY: image-scaffold-ansible image-build-ansible image-push-ansible image-push-ansible-multiarch
Expand Down Expand Up @@ -219,18 +216,6 @@ image-push-helm:
image-push-helm-multiarch:
./hack/image/push-manifest-list.sh $(HELM_IMAGE) ${HELM_ARCHES}

# Scorecard proxy image scaffold/build/push.
.PHONY: image-build-scorecard-proxy image-push-scorecard-proxy image-push-scorecard-proxy-multiarch

image-build-scorecard-proxy:
./hack/image/build-scorecard-proxy-image.sh $(SCORECARD_PROXY_BASE_IMAGE):dev

image-push-scorecard-proxy:
./hack/image/push-image-tags.sh $(SCORECARD_PROXY_BASE_IMAGE):dev $(SCORECARD_PROXY_IMAGE)-$(shell go env GOARCH)

image-push-scorecard-proxy-multiarch:
./hack/image/push-manifest-list.sh $(SCORECARD_PROXY_IMAGE) ${SCORECARD_PROXY_ARCHES}

# Scorecard test image scaffold/build/push.
.PHONY: image-build-scorecard-test image-push-scorecard-test image-push-scorecard-test-multiarch

Expand Down Expand Up @@ -281,31 +266,25 @@ test-links:
test-ci: test-sanity test-unit install test-subcommand test-e2e ## Run the CI test suite

# Subcommand tests.
.PHONY: test-subcommand test-subcommand-local test-subcommand-scorecard test-subcommand-olm-install
.PHONY: test-subcommand test-subcommand-local test-subcommand-olm-install

test-subcommand: test-subcommand-local test-subcommand-scorecard test-subcommand-olm-install
test-subcommand: test-subcommand-local test-subcommand-olm-install
./hack/tests/subcommand-bundle.sh
./hack/tests/subcommand-generate-csv.sh

test-subcommand-local:
./hack/tests/subcommand.sh

test-subcommand-scorecard:
./hack/tests/subcommand-scorecard.sh

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-ansible test-e2e-ansible-molecule test-e2e-helm

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-ansible test-e2e-ansible-molecule test-e2e-helm ## Run the e2e tests

test-e2e-go:
./hack/tests/e2e-go.sh $(ARGS)

test-e2e-go-new:
K8S_VERSION=$(K8S_VERSION) ./hack/tests/e2e-go-new.sh
./hack/tests/e2e-go.sh

test-e2e-ansible: image-build-ansible
./hack/tests/e2e-ansible.sh
Expand Down
86 changes: 1 addition & 85 deletions cmd/operator-sdk/add/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package add

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -131,9 +130,7 @@ func apiRun(cmd *cobra.Command, args []string) error {

switch operatorType {
case projutil.OperatorTypeGo:
if err := doGoAPIScaffold(); err != nil {
return err
}
return fmt.Errorf("the `add api` command is not supported for Go operators")
case projutil.OperatorTypeAnsible:
if err := doAnsibleAPIScaffold(); err != nil {
return err
Expand Down Expand Up @@ -218,84 +215,3 @@ func doAnsibleAPIScaffold() error {
}
return nil
}

// TODO
// Consolidate scaffold func to be used by both "new" and "add api" commands.
func doGoAPIScaffold() error {

// Create and validate new resource.
r, err := scaffold.NewResource(apiFlags.APIVersion, apiFlags.Kind)
if err != nil {
return err
}

absProjectPath := projutil.MustGetwd()

cfg := &input.Config{
Repo: projutil.GetGoPkg(),
AbsProjectPath: absProjectPath,
}
s := &scaffold.Scaffold{}

// Check if any package files for this API group dir exist, and if not
// scaffold a group.go to prevent erroneous gengo parse errors.
group := &scaffold.Group{Resource: r}
if err := scaffoldIfNoPkgFileExists(s, cfg, group); err != nil {
log.Fatalf("Failed to scaffold group file: %v", err)
}

err = s.Execute(cfg,
&scaffold.Types{Resource: r},
&scaffold.AddToScheme{Resource: r},
&scaffold.Register{Resource: r},
&scaffold.Doc{Resource: r},
&scaffold.CR{Resource: r},
)
if err != nil {
log.Fatalf("API scaffold failed: %v", err)
}

// update deploy/role.yaml for the given resource r.
if err := scaffold.UpdateRoleForResource(r, absProjectPath); err != nil {
log.Fatalf("Failed to update the RBAC manifest for the resource (%v, %v): (%v)",
r.APIVersion, r.Kind, err)
}

if !apiFlags.SkipGeneration {
// Run k8s codegen for deepcopy
if err := genutil.K8sCodegen(); err != nil {
log.Fatal(err)
}

// Generate a validation spec for the new CRD.
if err := genutil.CRDGen(apiFlags.CrdVersion); err != nil {
log.Fatal(err)
}
}

log.Info("API generation complete.")
return nil
}

// scaffoldIfNoPkgFileExists executes f using s and cfg if no go files
// in f's directory exist.
func scaffoldIfNoPkgFileExists(s *scaffold.Scaffold, cfg *input.Config, f input.File) error {
i, err := f.GetInput()
if err != nil {
return fmt.Errorf("error getting file %s input: %v", i.Path, err)
}
groupDir := filepath.Dir(i.Path)
gdInfos, err := ioutil.ReadDir(groupDir)
if err != nil && !os.IsNotExist(err) {
return fmt.Errorf("error reading dir %s: %v", groupDir, err)
}
if err == nil {
for _, info := range gdInfos {
if !info.IsDir() && filepath.Ext(info.Name()) == ".go" {
return nil
}
}
}
// err must be a non-existence error or no go files exist, so execute f.
return s.Execute(cfg, f)
}
1 change: 0 additions & 1 deletion cmd/operator-sdk/add/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func NewCmd() *cobra.Command {
}

cmd.AddCommand(newAddAPICmd())
cmd.AddCommand(newAddControllerCmd())
cmd.AddCommand(newAddCRDCmd())
return cmd
}
Loading