Skip to content

Commit 83200fa

Browse files
authored
Merge pull request #561 from runzexia/add-resources-validate
add all resources validate
2 parents e389094 + 6310ab6 commit 83200fa

File tree

13 files changed

+51
-16
lines changed

13 files changed

+51
-16
lines changed

cmd/init_project.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"sigs.k8s.io/kubebuilder/pkg/scaffold/input"
3636
"sigs.k8s.io/kubebuilder/pkg/scaffold/manager"
3737
"sigs.k8s.io/kubebuilder/pkg/scaffold/project"
38-
"sigs.k8s.io/kubebuilder/pkg/scaffold/resource"
3938
)
4039

4140
func newInitProjectCmd() *cobra.Command {
@@ -146,9 +145,9 @@ func (o *projectOptions) runInit() {
146145
&project.KustomizeImagePatch{},
147146
&project.KustomizePrometheusMetricsPatch{},
148147
&project.KustomizeAuthProxyPatch{},
149-
&resource.AuthProxyService{},
150-
&resource.AuthProxyRole{},
151-
&resource.AuthProxyRoleBinding{})
148+
&project.AuthProxyService{},
149+
&project.AuthProxyRole{},
150+
&project.AuthProxyRoleBinding{})
152151
if err != nil {
153152
log.Fatal(err)
154153
}

pkg/scaffold/resource/authproxyrole.go renamed to pkg/scaffold/project/authproxyrole.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package resource
17+
package project
1818

1919
import (
2020
"path/filepath"
@@ -27,9 +27,6 @@ var _ input.File = &AuthProxyRole{}
2727
// AuthProxyRole scaffolds the config/rbac/auth_proxy_role.yaml file
2828
type AuthProxyRole struct {
2929
input.Input
30-
31-
// Resource is a resource in the API group
32-
Resource *Resource
3330
}
3431

3532
// GetInput implements input.File

pkg/scaffold/resource/authproxyrolebinding.go renamed to pkg/scaffold/project/authproxyrolebinding.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package resource
17+
package project
1818

1919
import (
2020
"path/filepath"
@@ -27,9 +27,6 @@ var _ input.File = &AuthProxyRoleBinding{}
2727
// AuthProxyRoleBinding scaffolds the config/rbac/auth_proxy_role_binding_rbac.yaml file
2828
type AuthProxyRoleBinding struct {
2929
input.Input
30-
31-
// Resource is a resource in the API group
32-
Resource *Resource
3330
}
3431

3532
// GetInput implements input.File

pkg/scaffold/resource/authproxyservice.go renamed to pkg/scaffold/project/authproxyservice.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package resource
17+
package project
1818

1919
import (
2020
"path/filepath"
@@ -27,9 +27,6 @@ var _ input.File = &AuthProxyService{}
2727
// AuthProxyService scaffolds the config/rbac/auth_proxy_role.yaml file
2828
type AuthProxyService struct {
2929
input.Input
30-
31-
// Resource is a resource in the API group
32-
Resource *Resource
3330
}
3431

3532
// GetInput implements input.File

pkg/scaffold/resource/addtoscheme.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ func (a *AddToScheme) GetInput() (input.Input, error) {
4343
return a.Input, nil
4444
}
4545

46+
// Validate validates the values
47+
func (a *AddToScheme) Validate() error {
48+
return a.Resource.Validate()
49+
}
50+
4651
var addResourceTemplate = `{{ .Boilerplate }}
4752
4853
package apis

pkg/scaffold/resource/crd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ func (c *CRD) GetInput() (input.Input, error) {
6161
return c.Input, nil
6262
}
6363

64+
// Validate validates the values
65+
func (c *CRD) Validate() error {
66+
return c.Resource.Validate()
67+
}
68+
6469
var crdTemplate = `apiVersion: apiextensions.k8s.io/v1beta1
6570
kind: CustomResourceDefinition
6671
metadata:

pkg/scaffold/resource/crd_sample.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func (c *CRDSample) GetInput() (input.Input, error) {
4646
return c.Input, nil
4747
}
4848

49+
// Validate validates the values
50+
func (c *CRDSample) Validate() error {
51+
return c.Resource.Validate()
52+
}
53+
4954
var crdSampleTemplate = `apiVersion: {{ .Resource.Group }}.{{ .Domain }}/{{ .Resource.Version }}
5055
kind: {{ .Resource.Kind }}
5156
metadata:

pkg/scaffold/resource/doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ func (a *Doc) GetInput() (input.Input, error) {
4444
return a.Input, nil
4545
}
4646

47+
// Validate validates the values
48+
func (a *Doc) Validate() error {
49+
return a.Resource.Validate()
50+
}
51+
4752
var docGoTemplate = `{{ .Boilerplate }}
4853
4954
// Package {{.Resource.Version}} contains API Schema definitions for the {{ .Resource.Group }} {{.Resource.Version}} API group

pkg/scaffold/resource/group.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func (g *Group) GetInput() (input.Input, error) {
4141
return g.Input, nil
4242
}
4343

44+
// Validate validates the values
45+
func (g *Group) Validate() error {
46+
return g.Resource.Validate()
47+
}
48+
4449
var groupTemplate = `{{ .Boilerplate }}
4550
4651
// Package {{ .Resource.Group }} contains {{ .Resource.Group }} API versions

pkg/scaffold/resource/register.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func (r *Register) GetInput() (input.Input, error) {
4141
return r.Input, nil
4242
}
4343

44+
// Validate validates the values
45+
func (r *Register) Validate() error {
46+
return r.Resource.Validate()
47+
}
48+
4449
var registerTemplate = `{{ .Boilerplate }}
4550
4651
// NOTE: Boilerplate only. Ignore this file.

0 commit comments

Comments
 (0)