Skip to content

Commit a8b683d

Browse files
authored
Merge pull request #765 from mengqiy/cleanuplabel
✨ cleanup stale label in v2 scaffolding
2 parents 1d0e96b + a80870c commit a8b683d

13 files changed

+31
-114
lines changed

pkg/scaffold/project.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (p *V1Project) Scaffold() error {
115115
&scaffoldv1.KustomizeImagePatch{},
116116
&metricsauthv1.KustomizePrometheusMetricsPatch{},
117117
&metricsauthv1.KustomizeAuthProxyPatch{},
118-
&project.AuthProxyService{},
118+
&scaffoldv1.AuthProxyService{},
119119
&project.AuthProxyRole{},
120120
&project.AuthProxyRoleBinding{},
121121
&manager.Config{Image: imgName},
@@ -184,7 +184,7 @@ func (p *V2Project) Scaffold() error {
184184
&scaffoldv2.KustomizeImagePatch{},
185185
&metricsauthv2.KustomizePrometheusMetricsPatch{},
186186
&metricsauthv2.KustomizeAuthProxyPatch{},
187-
&project.AuthProxyService{},
187+
&scaffoldv2.AuthProxyService{},
188188
&project.AuthProxyRole{},
189189
&project.AuthProxyRoleBinding{},
190190
&managerv2.Config{Image: imgName},

pkg/scaffold/project/authproxyservice.go pkg/scaffold/v1/authproxyservice.go

+2-2
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 project
17+
package v1
1818

1919
import (
2020
"path/filepath"
@@ -24,7 +24,7 @@ import (
2424

2525
var _ input.File = &AuthProxyService{}
2626

27-
// AuthProxyService scaffolds the config/rbac/auth_proxy_role.yaml file
27+
// AuthProxyService scaffolds the config/rbac/auth_proxy_service.yaml file
2828
type AuthProxyService struct {
2929
input.Input
3030
}

pkg/scaffold/v1/resource/rolebinding.go

-65
This file was deleted.

pkg/scaffold/v1/resource/role.go pkg/scaffold/v2/authproxyservice.go

+23-29
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,46 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package resource
17+
package v2
1818

1919
import (
20-
"fmt"
2120
"path/filepath"
2221

2322
"sigs.k8s.io/kubebuilder/pkg/scaffold/input"
2423
)
2524

26-
var _ input.File = &Role{}
25+
var _ input.File = &AuthProxyService{}
2726

28-
// Role scaffolds the config/manager/group_role_rbac.yaml file
29-
type Role struct {
27+
// AuthProxyService scaffolds the config/rbac/auth_proxy_service.yaml file
28+
type AuthProxyService struct {
3029
input.Input
31-
32-
// Resource is a resource in the API group
33-
Resource *Resource
3430
}
3531

3632
// GetInput implements input.File
37-
func (r *Role) GetInput() (input.Input, error) {
33+
func (r *AuthProxyService) GetInput() (input.Input, error) {
3834
if r.Path == "" {
39-
r.Path = filepath.Join("config", "manager", fmt.Sprintf(
40-
"%s_role_rbac.yaml", r.Resource.Group))
35+
r.Path = filepath.Join("config", "rbac", "auth_proxy_service.yaml")
4136
}
42-
r.TemplateBody = roleTemplate
37+
r.TemplateBody = AuthProxyServiceTemplate
4338
return r.Input, nil
4439
}
4540

46-
// Validate validates the values
47-
func (r *Role) Validate() error {
48-
return r.Resource.Validate()
49-
}
50-
51-
var roleTemplate = `apiVersion: rbac.authorization.k8s.io/v1
52-
kind: ClusterRole
41+
var AuthProxyServiceTemplate = `apiVersion: v1
42+
kind: Service
5343
metadata:
44+
annotations:
45+
prometheus.io/port: "8443"
46+
prometheus.io/scheme: https
47+
prometheus.io/scrape: "true"
5448
labels:
55-
controller-tools.k8s.io: "1.0"
56-
name: {{.Resource.Group}}-role
57-
rules:
58-
- apiGroups:
59-
- {{ .Resource.Group }}.{{ .Domain }}
60-
resources:
61-
- '*'
62-
verbs:
63-
- '*'
64-
49+
control-plane: controller-manager
50+
name: controller-manager-metrics-service
51+
namespace: system
52+
spec:
53+
ports:
54+
- name: https
55+
port: 8443
56+
targetPort: https
57+
selector:
58+
control-plane: controller-manager
6559
`

pkg/scaffold/v2/crd/enablecainjection_patch.go

+1-1
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 v2
17+
package crd
1818

1919
import (
2020
"fmt"

pkg/scaffold/v2/crd/enablewebhook_patch.go

+1-1
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 v2
17+
package crd
1818

1919
import (
2020
"fmt"

pkg/scaffold/v2/crd/kustomization.go

+1-1
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 v2
17+
package crd
1818

1919
import (
2020
"fmt"

pkg/scaffold/v2/crd/kustomizeconfig.go

+1-1
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 v2
17+
package crd
1818

1919
import (
2020
"path/filepath"

pkg/scaffold/v2/manager/config.go

-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ kind: Namespace
4545
metadata:
4646
labels:
4747
control-plane: controller-manager
48-
controller-tools.k8s.io: "1.0"
4948
name: system
5049
---
5150
apiVersion: apps/v1
@@ -55,18 +54,15 @@ metadata:
5554
namespace: system
5655
labels:
5756
control-plane: controller-manager
58-
controller-tools.k8s.io: "1.0"
5957
spec:
6058
selector:
6159
matchLabels:
6260
control-plane: controller-manager
63-
controller-tools.k8s.io: "1.0"
6461
replicas: 1
6562
template:
6663
metadata:
6764
labels:
6865
control-plane: controller-manager
69-
controller-tools.k8s.io: "1.0"
7066
spec:
7167
containers:
7268
- command:

pkg/scaffold/v2/webhook/service.go

-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,4 @@ spec:
5151
targetPort: 443
5252
selector:
5353
control-plane: controller-manager
54-
controller-tools.k8s.io: "1.0"
5554
`

testdata/project-v2/config/manager/manager.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ kind: Namespace
33
metadata:
44
labels:
55
control-plane: controller-manager
6-
controller-tools.k8s.io: "1.0"
76
name: system
87
---
98
apiVersion: apps/v1
@@ -13,18 +12,15 @@ metadata:
1312
namespace: system
1413
labels:
1514
control-plane: controller-manager
16-
controller-tools.k8s.io: "1.0"
1715
spec:
1816
selector:
1917
matchLabels:
2018
control-plane: controller-manager
21-
controller-tools.k8s.io: "1.0"
2219
replicas: 1
2320
template:
2421
metadata:
2522
labels:
2623
control-plane: controller-manager
27-
controller-tools.k8s.io: "1.0"
2824
spec:
2925
containers:
3026
- command:

testdata/project-v2/config/rbac/auth_proxy_service.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ metadata:
77
prometheus.io/scrape: "true"
88
labels:
99
control-plane: controller-manager
10-
controller-tools.k8s.io: "1.0"
1110
name: controller-manager-metrics-service
1211
namespace: system
1312
spec:
@@ -17,4 +16,3 @@ spec:
1716
targetPort: https
1817
selector:
1918
control-plane: controller-manager
20-
controller-tools.k8s.io: "1.0"

testdata/project-v2/config/webhook/service.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ spec:
1010
targetPort: 443
1111
selector:
1212
control-plane: controller-manager
13-
controller-tools.k8s.io: "1.0"

0 commit comments

Comments
 (0)