Skip to content

Commit f89a2c3

Browse files
author
Eric Stroczynski
authored
*: make go/v3 the default plugin (#4307)
1 parent 6a9c7b3 commit f89a2c3

File tree

14 files changed

+60
-31
lines changed

14 files changed

+60
-31
lines changed

.gitignore

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
# Build artifacts
55
/build
66
/dist
7-
/tools/bin
8-
/images/*/bin
7+
**/bin/
8+
9+
# Test artifacts
10+
**/testbin/
911

1012
# CI GPG keyring
1113
/.ci/gpg/keyring
@@ -16,12 +18,6 @@ website/resources/
1618
website/node_modules/
1719
website/tech-doc-hugo
1820

19-
# Ensure that will not commit the bin gen in the go sample
20-
testdata/go/v2/memcached-operator/bin/*
21-
testdata/go/v3/memcached-operator/bin/*
22-
testdata/ansible/memcached-operator/bin/*
23-
testdata/helm/memcached-operator/bin/*
24-
2521
# Ignore molecule samples testdata if it be generated in the testdata/ diretory
2622
testdata/ansible/memcached-molecule-operator
2723

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
entries:
2+
- description: >
3+
Go CLI plugin go/v3 is now the default.
4+
kind: change
5+
breaking: false
6+
migration:
7+
header: Upgrade your Go project from "go.kubebuilder.io/v2" to "go.kubebuilder.io/v3"
8+
body: >
9+
The newly released go/v3 plugin has many new features and (breaking) changes
10+
incompatible with projects created by go/v2. You are not required to upgrade
11+
and your go/v2 project will continue to work with new operator-sdk versions.
12+
If you wish to upgrade, check out the upstream
13+
[migration guide](https://master.book.kubebuilder.io/migration/plugin/plugins.html).
14+
15+
Additionally, if using project version "3-alpha", you must update your "plugins" config field:
16+
17+
Old:
18+
```yaml
19+
plugins:
20+
go.sdk.operatorframework.io/v2-alpha: {}
21+
```
22+
23+
New:
24+
```yaml
25+
plugins:
26+
manifests.sdk.operatorframework.io/v2: {}
27+
scorecard.sdk.operatorframework.io/v2: {}
28+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
rsc.io/letsencrypt v0.0.3 // indirect
3535
sigs.k8s.io/controller-runtime v0.7.0
3636
sigs.k8s.io/controller-tools v0.4.1
37-
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201211222127-503ba3b7e4ad
37+
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201214213149-0a807f4e9428
3838
sigs.k8s.io/yaml v1.2.0
3939
)
4040

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,8 @@ sigs.k8s.io/controller-tools v0.3.0 h1:y3YD99XOyWaXkiF1kd41uRvfp/64teWcrEZFuHxPh
13541354
sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI=
13551355
sigs.k8s.io/controller-tools v0.4.1 h1:VkuV0MxlRPmRu5iTgBZU4UxUX2LiR99n3sdQGRxZF4w=
13561356
sigs.k8s.io/controller-tools v0.4.1/go.mod h1:G9rHdZMVlBDocIxGkK3jHLWqcTMNvveypYJwrvYKjWU=
1357-
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201211222127-503ba3b7e4ad h1:QCCQLxLLZsNKgp49jG0rErcSz9oa/4J5WU7lnaEA99A=
1358-
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201211222127-503ba3b7e4ad/go.mod h1:J/D/179LBZhQOhRvmMRNbje/Bk+PjbN0/fzUupmO7+U=
1357+
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201214213149-0a807f4e9428 h1:VUvP/g8pDUdqBHgKPoSX6WA/ZH1Y1+FBOk7khgyTLJw=
1358+
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201214213149-0a807f4e9428/go.mod h1:J/D/179LBZhQOhRvmMRNbje/Bk+PjbN0/fzUupmO7+U=
13591359
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
13601360
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
13611361
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=

hack/generate/samples/internal/go/v3/memcached_with_webhooks.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ func (mh *MemcachedGoWithWebhooks) Run() {
6161
err := mh.ctx.Init(
6262
// TODO(estroz): change this to 3 when stabilized.
6363
"--project-version", "3-alpha",
64-
// TODO(estroz): change this to go/v3 when stabilized.
65-
"--plugins", "go/v3-alpha",
64+
"--plugins", "go/v3",
6665
"--repo", "github.com/example/memcached-operator",
6766
"--domain",
6867
mh.ctx.Domain)

internal/cmd/operator-sdk/cli/cli.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ func GetPluginsCLIAndRoot() (cli.CLI, *cobra.Command) {
6666
&ansiblev1.Plugin{},
6767
),
6868
cli.WithDefaultPlugins(config.Version2, &golangv2.Plugin{}),
69-
// TODO(estroz): make go/v3-alpha plugin the default once stabilized.
70-
cli.WithDefaultPlugins(config.Version3Alpha, &golangv2.Plugin{}),
69+
cli.WithDefaultPlugins(config.Version3Alpha, &golangv3.Plugin{}),
7170
cli.WithExtraCommands(commands...),
7271
)
7372
if err != nil {
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
domain: example.com
2-
layout: go.kubebuilder.io/v2
32
projectName: memcached-operator
43
repo: github.com/example/memcached-operator
54
resources:
65
- group: cache
76
kind: Memcached
87
version: v1alpha1
98
version: 3-alpha
10-
plugins:
11-
go.sdk.operatorframework.io/v2-alpha: {}

test/e2e-go/e2e_go_cluster_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package e2e_go_test
1919
import (
2020
"encoding/base64"
2121
"encoding/json"
22+
"errors"
2223
"fmt"
2324
"path/filepath"
2425
"strings"
@@ -51,7 +52,8 @@ var _ = Describe("operator-sdk", func() {
5152
testutils.WrapWarnOutput(tc.Kubectl.Command("delete", "clusterrolebinding", metricsClusterRoleBindingName))
5253

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

5658
By("ensuring that the namespace was deleted")
5759
testutils.WrapWarnOutput(tc.Kubectl.Wait(false, "namespace", "foo", "--for", "delete", "--timeout", "2m"))
@@ -174,8 +176,15 @@ var _ = Describe("operator-sdk", func() {
174176
// The controller updates memcacheds' status.nodes with a list of pods it is replicated across
175177
// on a successful reconcile.
176178
By("validating that the created resource object gets reconciled in the controller")
177-
status, err := tc.Kubectl.Get(true, "memcacheds", "memcached-sample", "-o", "jsonpath={.status.nodes}")
178-
Expect(err).NotTo(HaveOccurred())
179+
var status string
180+
getStatus := func() error {
181+
status, err = tc.Kubectl.Get(true, "memcacheds", "memcached-sample", "-o", "jsonpath={.status.nodes}")
182+
if err == nil && strings.TrimSpace(status) == "" {
183+
err = errors.New("empty status, continue")
184+
}
185+
return err
186+
}
187+
Eventually(getStatus, 1*time.Minute, time.Second).Should(Succeed())
179188
var nodes []string
180189
Expect(json.Unmarshal([]byte(status), &nodes)).To(Succeed())
181190
Expect(len(nodes)).To(BeNumerically(">", 0))

test/e2e-go/e2e_go_suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var _ = BeforeSuite(func() {
5555
tc.Kubectl.Namespace = fmt.Sprintf("%s-system", tc.ProjectName)
5656

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

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

9090
By("installing cert manager bundle")
91-
Expect(tc.InstallCertManager(true)).To(Succeed())
91+
Expect(tc.InstallCertManager(false)).To(Succeed())
9292
})
9393

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

100100
By("uninstalling prerequisites")
101101
tc.UninstallPrerequisites()

testdata/go/v3/memcached-operator/PROJECT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
domain: example.com
2-
layout: go.kubebuilder.io/v3-alpha
2+
layout: go.kubebuilder.io/v3
33
projectName: memcached-operator
44
repo: github.com/example/memcached-operator
55
resources:

0 commit comments

Comments
 (0)