Skip to content

Commit 90fe412

Browse files
authored
Merge pull request #2134 from kubernetes-sigs/master
🌱 rebase with master for the release 3.0.0-rc-0
2 parents ad5f0b8 + 72f7c2e commit 90fe412

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+522
-235
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Lint
2+
3+
# Trigger the workflow on pull requests and direct pushes to any branch
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
10+
lint:
11+
name: golangci-lint
12+
runs-on: ubuntu-latest
13+
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push
14+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
15+
steps:
16+
- name: Clone the code
17+
uses: actions/checkout@v2
18+
- name: Run linter
19+
uses: golangci/golangci-lint-action@v2
20+
with:
21+
version: v1.37 # Always uses the latest patch version.
22+
only-new-issues: true # Show only new issues if it's a pull request
23+
- name: Report failure
24+
uses: nashmaniac/[email protected]
25+
# Only report failures of pushes (PRs have are visible through the Checks section) to the default branch
26+
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/master'
27+
with:
28+
title: 🐛 Lint failed for ${{ github.sha }}
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
labels: kind/bug
31+
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

.github/workflows/testdata.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Testdata verification
2+
3+
# Trigger the workflow on pull requests and direct pushes to any branch
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
10+
testdata:
11+
name: Verify testdata directory
12+
runs-on: ubuntu-latest
13+
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push
14+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
15+
steps:
16+
- name: Clone the code
17+
uses: actions/checkout@v2
18+
- name: Setup Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: '1.15'
22+
- name: Remove pre-installed kustomize
23+
# This step is needed as the following one tries to remove
24+
# kustomize for each test but has no permission to do so
25+
run: sudo rm -f /usr/local/bin/kustomize
26+
- name: Verify testdata directory
27+
run: make check-testdata
28+
- name: Report failure
29+
uses: nashmaniac/[email protected]
30+
# Only report failures of pushes (PRs have are visible through the Checks section) to the default branch
31+
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/master'
32+
with:
33+
title: 🐛 Testadata verification failed for ${{ github.sha }}
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
labels: kind/bug
36+
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

.github/workflows/unit-tests.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Unit tests
2+
3+
# Trigger the workflow on pull requests and direct pushes to any branch
4+
on:
5+
push:
6+
pull_request:
7+
8+
9+
jobs:
10+
11+
test:
12+
name: ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os:
17+
- ubuntu-latest
18+
- macos-latest
19+
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push
20+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
21+
steps:
22+
- name: Clone the code
23+
uses: actions/checkout@v2
24+
- name: Setup Go
25+
uses: actions/setup-go@v2
26+
with:
27+
go-version: '1.15'
28+
# This step is needed as the following one tries to remove
29+
# kustomize for each test but has no permission to do so
30+
- name: Remove pre-installed kustomize
31+
run: sudo rm -f /usr/local/bin/kustomize
32+
- name: Perform the test
33+
run: make test
34+
- name: Report failure
35+
uses: nashmaniac/[email protected]
36+
# Only report failures of pushes (PRs have are visible through the Checks section) to the default branch
37+
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/master'
38+
with:
39+
title: 🐛 Unit tests failed on ${{ matrix.os }} for ${{ github.sha }}
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
labels: kind/bug
42+
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
43+
44+
coverage:
45+
name: Code coverage
46+
needs:
47+
- test
48+
runs-on: ubuntu-latest
49+
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push
50+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
51+
steps:
52+
- name: Clone the code
53+
uses: actions/checkout@v2
54+
- name: Setup Go
55+
uses: actions/setup-go@v2
56+
with:
57+
go-version: '1.15'
58+
- name: Generate the coverage output
59+
run: make test-coverage
60+
- name: Send the coverage output
61+
uses: shogo82148/actions-goveralls@v1
62+
with:
63+
path-to-profile: coverage-all.out
64+
- name: Report failure
65+
uses: nashmaniac/[email protected]
66+
# Only report failures of pushes (PRs have are visible through the Checks section) to the default branch
67+
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/master'
68+
with:
69+
title: 🐛 Coverage report failed for ${{ github.sha }}
70+
token: ${{ secrets.GITHUB_TOKEN }}
71+
labels: kind/bug
72+
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

cmd/main.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,33 @@ import (
2222
"sigs.k8s.io/kubebuilder/v3/pkg/cli"
2323
cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
2424
cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
25-
declarativev1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/declarative/v1"
26-
pluginv2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2"
27-
pluginv3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
25+
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
26+
kustomizecommonv1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1"
27+
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
28+
declarativev1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/declarative/v1"
29+
golangv2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2"
30+
golangv3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
2831
)
2932

3033
func main() {
34+
35+
// Bundle plugin which built the golang projects scaffold by Kubebuilder go/v3
36+
gov3Bundle, _ := plugin.NewBundle(golang.DefaultNameQualifier, plugin.Version{Number: 3},
37+
kustomizecommonv1.Plugin{},
38+
golangv3.Plugin{},
39+
)
40+
3141
c, err := cli.New(
3242
cli.WithCommandName("kubebuilder"),
3343
cli.WithVersion(versionString()),
3444
cli.WithPlugins(
35-
&pluginv2.Plugin{},
36-
&pluginv3.Plugin{},
45+
golangv2.Plugin{},
46+
gov3Bundle,
47+
&kustomizecommonv1.Plugin{},
3748
&declarativev1.Plugin{},
3849
),
39-
cli.WithDefaultPlugins(cfgv2.Version, &pluginv2.Plugin{}),
40-
cli.WithDefaultPlugins(cfgv3.Version, &pluginv3.Plugin{}),
50+
cli.WithDefaultPlugins(cfgv2.Version, golangv2.Plugin{}),
51+
cli.WithDefaultPlugins(cfgv3.Version, gov3Bundle),
4152
cli.WithDefaultProjectVersion(cfgv3.Version),
4253
cli.WithCompletion(),
4354
)

docs/book/src/reference/generating-crd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ type CustomSet struct {
144144
metav1.TypeMeta `json:",inline"`
145145
metav1.ObjectMeta `json:"metadata,omitempty"`
146146

147-
Spec ToySpec `json:"spec,omitempty"`
148-
Status ToyStatus `json:"status,omitempty"`
147+
Spec CustomSetSpec `json:"spec,omitempty"`
148+
Status CustomSetStatus `json:"status,omitempty"`
149149
}
150150
```
151151

pkg/cli/cli.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ type CLI struct { //nolint:maligned
4848
commandName string
4949
// CLI version string.
5050
version string
51+
// CLI root's command description.
52+
description string
5153
// Plugins registered in the CLI.
5254
plugins map[string]plugin.Plugin
5355
// Default plugins in case none is provided and a config file can't be found.
@@ -120,7 +122,9 @@ func New(options ...Option) (*CLI, error) {
120122
func newCLI(options ...Option) (*CLI, error) {
121123
// Default CLI options.
122124
c := &CLI{
123-
commandName: "kubebuilder",
125+
commandName: "kubebuilder",
126+
description: `CLI tool for building Kubernetes extensions and tools.
127+
`,
124128
plugins: make(map[string]plugin.Plugin),
125129
defaultPlugins: make(map[config.Version][]string),
126130
fs: machinery.Filesystem{FS: afero.NewOsFs()},

pkg/cli/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ func WithVersion(version string) Option {
4444
}
4545
}
4646

47+
// WithDescription is an Option that sets the CLI's root description.
48+
func WithDescription(description string) Option {
49+
return func(c *CLI) error {
50+
c.description = description
51+
return nil
52+
}
53+
}
54+
4755
// WithPlugins is an Option that sets the CLI's plugins.
4856
//
4957
// Specifying any invalid plugin results in an error.

pkg/cli/options_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ var _ = Describe("CLI options", func() {
6767
})
6868
})
6969

70+
Context("WithDescription", func() {
71+
It("should use the provided description string", func() {
72+
description := "alternative description"
73+
c, err = newCLI(WithDescription(description))
74+
Expect(err).NotTo(HaveOccurred())
75+
Expect(c).NotTo(BeNil())
76+
Expect(c.description).To(Equal(description))
77+
})
78+
})
79+
7080
Context("WithPlugins", func() {
7181
It("should return a valid CLI", func() {
7282
c, err = newCLI(WithPlugins(p))

pkg/cli/root.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ const (
3131

3232
func (c CLI) newRootCmd() *cobra.Command {
3333
cmd := &cobra.Command{
34-
Use: c.commandName,
35-
Long: `CLI tool for building Kubernetes extensions and tools.
36-
`,
34+
Use: c.commandName,
35+
Long: c.description,
3736
Example: c.rootExamples(),
3837
RunE: func(cmd *cobra.Command, args []string) error {
3938
return cmd.Help()

0 commit comments

Comments
 (0)