Skip to content

Commit 20e494c

Browse files
authored
Merge pull request #252 from haiyanmeng/path
Make the `Path` field of the "+kubebuilder:resource" marker optional
2 parents 3b07c26 + 06ecc88 commit 20e494c

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

pkg/crd/markers/crd.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,17 @@ func (s PrintColumn) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, versio
179179

180180
// Resource defines "+kubebuilder:resource"
181181
type Resource struct {
182-
Path string
182+
Path string `marker:",optional"`
183183
ShortName []string `marker:",optional"`
184184
Categories []string `marker:",optional"`
185185
Singular string `marker:",optional"`
186186
Scope string `marker:",optional"`
187187
}
188188

189189
func (s Resource) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error {
190-
crd.Names.Plural = s.Path
190+
if s.Path != "" {
191+
crd.Names.Plural = s.Path
192+
}
191193
crd.Names.ShortNames = s.ShortName
192194
crd.Names.Categories = s.Categories
193195

pkg/crd/testdata/cronjob_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ type CronJobStatus struct {
146146

147147
// +kubebuilder:object:root=true
148148
// +kubebuilder:subresource:status
149+
// +kubebuilder:resource
149150

150151
// CronJob is the Schema for the cronjobs API
151152
type CronJob struct {

pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
names:
1111
kind: CronJob
1212
plural: cronjobs
13-
scope: ""
13+
scope: Namespaced
1414
versions:
1515
- name: v1
1616
schema:

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ golangci-lint run --disable-all \
134134

135135
header_text "running go test"
136136

137-
go test ./pkg/... ./cmd/... -parallel 4
137+
go test -race ./pkg/... ./cmd/... -parallel 4
138138

139139
# ensure that Gopkg.{toml,lock} are up-to-date
140140
header_text "ensuring that Gopkg.{toml,lock} are up to date..."

0 commit comments

Comments
 (0)