Skip to content

Commit

Permalink
*: make go/v3 the default plugin (#4307)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Stroczynski authored Dec 16, 2020
1 parent 6a9c7b3 commit f89a2c3
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 31 deletions.
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# Build artifacts
/build
/dist
/tools/bin
/images/*/bin
**/bin/

# Test artifacts
**/testbin/

# CI GPG keyring
/.ci/gpg/keyring
Expand All @@ -16,12 +18,6 @@ website/resources/
website/node_modules/
website/tech-doc-hugo

# Ensure that will not commit the bin gen in the go sample
testdata/go/v2/memcached-operator/bin/*
testdata/go/v3/memcached-operator/bin/*
testdata/ansible/memcached-operator/bin/*
testdata/helm/memcached-operator/bin/*

# Ignore molecule samples testdata if it be generated in the testdata/ diretory
testdata/ansible/memcached-molecule-operator

Expand Down
28 changes: 28 additions & 0 deletions changelog/fragments/go-v3-default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
entries:
- description: >
Go CLI plugin go/v3 is now the default.
kind: change
breaking: false
migration:
header: Upgrade your Go project from "go.kubebuilder.io/v2" to "go.kubebuilder.io/v3"
body: >
The newly released go/v3 plugin has many new features and (breaking) changes
incompatible with projects created by go/v2. You are not required to upgrade
and your go/v2 project will continue to work with new operator-sdk versions.
If you wish to upgrade, check out the upstream
[migration guide](https://master.book.kubebuilder.io/migration/plugin/plugins.html).
Additionally, if using project version "3-alpha", you must update your "plugins" config field:
Old:
```yaml
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
```
New:
```yaml
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
rsc.io/letsencrypt v0.0.3 // indirect
sigs.k8s.io/controller-runtime v0.7.0
sigs.k8s.io/controller-tools v0.4.1
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201211222127-503ba3b7e4ad
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201214213149-0a807f4e9428
sigs.k8s.io/yaml v1.2.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,8 @@ sigs.k8s.io/controller-tools v0.3.0 h1:y3YD99XOyWaXkiF1kd41uRvfp/64teWcrEZFuHxPh
sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI=
sigs.k8s.io/controller-tools v0.4.1 h1:VkuV0MxlRPmRu5iTgBZU4UxUX2LiR99n3sdQGRxZF4w=
sigs.k8s.io/controller-tools v0.4.1/go.mod h1:G9rHdZMVlBDocIxGkK3jHLWqcTMNvveypYJwrvYKjWU=
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201211222127-503ba3b7e4ad h1:QCCQLxLLZsNKgp49jG0rErcSz9oa/4J5WU7lnaEA99A=
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201211222127-503ba3b7e4ad/go.mod h1:J/D/179LBZhQOhRvmMRNbje/Bk+PjbN0/fzUupmO7+U=
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201214213149-0a807f4e9428 h1:VUvP/g8pDUdqBHgKPoSX6WA/ZH1Y1+FBOk7khgyTLJw=
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201214213149-0a807f4e9428/go.mod h1:J/D/179LBZhQOhRvmMRNbje/Bk+PjbN0/fzUupmO7+U=
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ func (mh *MemcachedGoWithWebhooks) Run() {
err := mh.ctx.Init(
// TODO(estroz): change this to 3 when stabilized.
"--project-version", "3-alpha",
// TODO(estroz): change this to go/v3 when stabilized.
"--plugins", "go/v3-alpha",
"--plugins", "go/v3",
"--repo", "github.com/example/memcached-operator",
"--domain",
mh.ctx.Domain)
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/operator-sdk/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ func GetPluginsCLIAndRoot() (cli.CLI, *cobra.Command) {
&ansiblev1.Plugin{},
),
cli.WithDefaultPlugins(config.Version2, &golangv2.Plugin{}),
// TODO(estroz): make go/v3-alpha plugin the default once stabilized.
cli.WithDefaultPlugins(config.Version3Alpha, &golangv2.Plugin{}),
cli.WithDefaultPlugins(config.Version3Alpha, &golangv3.Plugin{}),
cli.WithExtraCommands(commands...),
)
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions internal/generate/testdata/go/PROJECT
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
domain: example.com
layout: go.kubebuilder.io/v2
projectName: memcached-operator
repo: github.com/example/memcached-operator
resources:
- group: cache
kind: Memcached
version: v1alpha1
version: 3-alpha
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
15 changes: 12 additions & 3 deletions test/e2e-go/e2e_go_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package e2e_go_test
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"path/filepath"
"strings"
Expand Down Expand Up @@ -51,7 +52,8 @@ var _ = Describe("operator-sdk", func() {
testutils.WrapWarnOutput(tc.Kubectl.Command("delete", "clusterrolebinding", metricsClusterRoleBindingName))

By("cleaning up created API objects during test process")
tc.CleanupManifests(filepath.Join("config", "default"))
// TODO(estroz): go/v2 does not have this target, so generalize once tests are refactored.
testutils.WrapWarn(tc.Make("undeploy"))

By("ensuring that the namespace was deleted")
testutils.WrapWarnOutput(tc.Kubectl.Wait(false, "namespace", "foo", "--for", "delete", "--timeout", "2m"))
Expand Down Expand Up @@ -174,8 +176,15 @@ var _ = Describe("operator-sdk", func() {
// The controller updates memcacheds' status.nodes with a list of pods it is replicated across
// on a successful reconcile.
By("validating that the created resource object gets reconciled in the controller")
status, err := tc.Kubectl.Get(true, "memcacheds", "memcached-sample", "-o", "jsonpath={.status.nodes}")
Expect(err).NotTo(HaveOccurred())
var status string
getStatus := func() error {
status, err = tc.Kubectl.Get(true, "memcacheds", "memcached-sample", "-o", "jsonpath={.status.nodes}")
if err == nil && strings.TrimSpace(status) == "" {
err = errors.New("empty status, continue")
}
return err
}
Eventually(getStatus, 1*time.Minute, time.Second).Should(Succeed())
var nodes []string
Expect(json.Unmarshal([]byte(status), &nodes)).To(Succeed())
Expect(len(nodes)).To(BeNumerically(">", 0))
Expand Down
6 changes: 3 additions & 3 deletions test/e2e-go/e2e_go_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var _ = BeforeSuite(func() {
tc.Kubectl.Namespace = fmt.Sprintf("%s-system", tc.ProjectName)

By("copying sample to a temporary e2e directory")
Expect(exec.Command("cp", "-r", "../../testdata/go/v2/memcached-operator", tc.Dir).Run()).To(Succeed())
Expect(exec.Command("cp", "-r", "../../testdata/go/v3/memcached-operator", tc.Dir).Run()).To(Succeed())

By("fetching the current-context")
tc.Kubectx, err = tc.Kubectl.Command("config", "current-context")
Expand Down Expand Up @@ -88,14 +88,14 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())

By("installing cert manager bundle")
Expect(tc.InstallCertManager(true)).To(Succeed())
Expect(tc.InstallCertManager(false)).To(Succeed())
})

// AfterSuite run after all the specs have run, regardless of whether any tests have failed to ensures that
// all be cleaned up
var _ = AfterSuite(func() {
By("uninstall cert manager bundle")
tc.UninstallCertManager(true)
tc.UninstallCertManager(false)

By("uninstalling prerequisites")
tc.UninstallPrerequisites()
Expand Down
2 changes: 1 addition & 1 deletion testdata/go/v3/memcached-operator/PROJECT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
domain: example.com
layout: go.kubebuilder.io/v3-alpha
layout: go.kubebuilder.io/v3
projectName: memcached-operator
repo: github.com/example/memcached-operator
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ spec:
image: quay.io/example/memcached-operator:v0.0.1
livenessProbe:
httpGet:
path: /readyz
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
Expand All @@ -139,7 +139,7 @@ spec:
protocol: TCP
readinessProbe:
httpGet:
path: /healthz
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
Expand Down
4 changes: 2 additions & 2 deletions testdata/go/v3/memcached-operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ spec:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /readyz
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /healthz
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Before creating an API and controller, consider if your operator requires multip

```YAML
domain: example.com
layout: go.kubebuilder.io/v2
layout: go.kubebuilder.io/v3
multigroup: true
...
```
Expand Down
3 changes: 2 additions & 1 deletion website/content/en/docs/cli/operator-sdk_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ operator-sdk init [flags]
### Options

```
--component-config create a versioned ComponentConfig file, may be 'true' or 'false'
--domain string domain for groups (default "my.domain")
--fetch-deps ensure dependencies are downloaded (default true)
-h, --help help for init
--license string license to use to boilerplate, may be one of 'apache2', 'none' (default "apache2")
--owner string owner to add to the copyright
--plugins strings Name and optionally version of the plugin to initialize the project with. Available plugins: ("ansible.sdk.operatorframework.io/v1", "go.kubebuilder.io/v2", "go.kubebuilder.io/v3-alpha", "helm.sdk.operatorframework.io/v1")
--plugins strings Name and optionally version of the plugin to initialize the project with. Available plugins: ("ansible.sdk.operatorframework.io/v1", "go.kubebuilder.io/v2", "go.kubebuilder.io/v3", "helm.sdk.operatorframework.io/v1")
--project-name string name of this project
--project-version string project version, possible values: ("2", "3-alpha") (default "3-alpha")
--repo string name to use for go module (e.g., github.com/user/repo), defaults to the go package of the current working directory.
Expand Down

0 comments on commit f89a2c3

Please sign in to comment.