Skip to content

Commit

Permalink
(feat): Externalize the plugins package (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
  • Loading branch information
everettraven authored Jul 31, 2023
1 parent 54d3e49 commit ab43854
Show file tree
Hide file tree
Showing 61 changed files with 79 additions and 175 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ jobs:
with:
fetch-depth: 0
- run: make test-unit
- uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
30 changes: 24 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ SHELL = /bin/bash
# This value must be updated to the release tag of the most recent release, a change that must
# occur in the release commit. IMAGE_VERSION will be removed once each subproject that uses this
# version is moved to a separate repo and release process.
export IMAGE_VERSION = v1.30.0
export IMAGE_VERSION = v1.31.0
# Build-time variables to inject into binaries
export SIMPLE_VERSION = $(shell (test "$(shell git describe --tags)" = "$(shell git describe --tags --abbrev=0)" && echo $(shell git describe --tags)) || echo $(shell git describe --tags --abbrev=0)+git)
export GIT_VERSION = $(shell git describe --dirty --tags --always)
export GIT_COMMIT = $(shell git rev-parse HEAD)
export K8S_VERSION = 1.26.0

export OPERATOR_SDK_VERSION = $(IMAGE_VERSION)

# Build settings
export TOOLS_DIR = tools/bin
export SCRIPTS_DIR = tools/scripts
Expand All @@ -35,17 +37,17 @@ export PATH := $(PWD)/$(BUILD_DIR):$(PWD)/$(TOOLS_DIR):$(PATH)
##@ Development

.PHONY: generate
generate: build # Generate CLI docs and samples
generate: operator-sdk build # Generate CLI docs and samples
rm -rf testdata
go run ./hack/generate/samples/generate_testdata.go
go run ./hack/generate/samples/generate_testdata.go --bin $(OPERATOR_SDK)
go generate ./...

.PHONY: fix
fix: ## Fixup files in the repo.
go mod tidy
go fmt ./...
make setup-lint
$(TOOLS_DIR)/golangci-lint run --fix
$(TOOLS_DIR)/golangci-lint run --fix --timeout=2m

.PHONY: setup-lint
setup-lint: ## Setup the lint
Expand Down Expand Up @@ -140,7 +142,7 @@ e2e_targets := test-e2e $(e2e_tests)
export KIND_CLUSTER := osdk-test

KUBEBUILDER_ASSETS = $(PWD)/$(shell go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest && $(shell go env GOPATH)/bin/setup-envtest use $(K8S_VERSION) --bin-dir tools/bin/ -p path)
test-e2e-setup:: build dev-install cluster-create
test-e2e-setup:: operator-sdk build dev-install cluster-create

.PHONY: cluster-create
cluster-create::
Expand All @@ -162,13 +164,29 @@ test-e2e-teardown:
$(e2e_targets):: test-e2e-setup
test-e2e:: $(e2e_tests) ## Run e2e tests

test-e2e-ansible:: image/ansible-operator ## Run Ansible e2e tests
test-e2e-ansible:: operator-sdk image/ansible-operator ## Run Ansible e2e tests
go test -count=1 ./internal/ansible/proxy/...
go test ./test/e2e/ansible -v -ginkgo.v
test-e2e-ansible-molecule:: install dev-install image/ansible-operator ## Run molecule-based Ansible e2e tests
go run ./hack/generate/samples/molecule/generate.go
./hack/tests/e2e-ansible-molecule.sh

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

.PHONY: operator-sdk
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
operator-sdk: ## Download operator-sdk locally if necessary.
@{ \
set -e ;\
mkdir -p $(dir $(OPERATOR_SDK)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH} ;\
chmod +x $(OPERATOR_SDK) ;\
}

.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help screen.
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.10.0
github.com/stretchr/testify v1.8.2
github.com/thoas/go-funk v0.8.0
golang.org/x/text v0.9.0
k8s.io/api v0.26.2
k8s.io/apiextensions-apiserver v0.26.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,6 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/thoas/go-funk v0.8.0 h1:JP9tKSvnpFVclYgDM0Is7FD9M4fhPvqA0s0BsXmzSRQ=
github.com/thoas/go-funk v0.8.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
Expand Down
93 changes: 0 additions & 93 deletions internal/plugins/util/legacy_keys.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
kbtestutils "sigs.k8s.io/kubebuilder/v3/test/e2e/utils"
)

const BinaryName = "operator-sdk"
const BinaryName = "bin/operator-sdk"

// TestContext wraps kubebuilder's e2e TestContext.
type TestContext struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
pluginutil "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/util"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/util"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds"
sdkpluginutil "github.com/operator-framework/ansible-operator-plugins/internal/plugins/util"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds"
sdkpluginutil "github.com/operator-framework/ansible-operator-plugins/pkg/plugins/util"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins"
)

const pluginName = "base.ansible" + plugins.DefaultNameQualifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/config/crd"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/molecule/mdefault"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/playbooks"
ansibleroles "github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/roles"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/config/crd"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/config/rbac"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/molecule/mdefault"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/playbooks"
ansibleroles "github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/roles"
)

var _ plugins.Scaffolder = &apiScaffolder{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/plugins"
kustomizev2Alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/config/testing"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/config/testing/pullpolicy"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/molecule/mdefault"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/molecule/mkind"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/playbooks"
"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/scaffolds/internal/templates/roles"
"github.com/operator-framework/ansible-operator-plugins/internal/version"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/config/rbac"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/config/testing"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/config/testing/pullpolicy"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/molecule/mdefault"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/molecule/mkind"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/playbooks"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/scaffolds/internal/templates/roles"
)

const imageName = "controller:latest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &Dockerfile{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &DefaultsMain{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &RoleFiles{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &HandlersMain{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &MetaMain{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

const ReadmePath = "README.md"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &TasksMain{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &RoleTemplates{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/operator-framework/ansible-operator-plugins/internal/plugins/ansible/v1/constants"
"github.com/operator-framework/ansible-operator-plugins/pkg/plugins/ansible/v1/constants"
)

var _ machinery.Template = &VarsMain{}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions test/e2e/ansible/scorecard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

package e2e_ansible_test

import (
. "github.com/onsi/ginkgo/v2"
// import (
// . "github.com/onsi/ginkgo/v2"
// )

"github.com/operator-framework/ansible-operator-plugins/test/common"
)

var _ = Describe("scorecard", common.ScorecardSpec(&tc, "ansible"))
// For now don't run Scorecard tests
// var _ = Describe("scorecard", common.ScorecardSpec(&tc, "ansible"))
Loading

0 comments on commit ab43854

Please sign in to comment.