Skip to content

Commit

Permalink
Merge pull request #2753 from camilamacedo86/update-samples
Browse files Browse the repository at this point in the history
🌱  ( testdata samples / ci ) ensure that project-v3 and project-v3-with-kustomize does the same scaffold
  • Loading branch information
k8s-ci-robot committed Jun 20, 2022
2 parents dcc5bb4 + 9a814b5 commit 8b0f136
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions test/testdata/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function scaffold_test_project {
$kb create api --group crew --version v1 --kind Captain --controller=true --resource=true --make=false
$kb create api --group crew --version v1 --kind Captain --controller=true --resource=true --make=false --force
$kb create webhook --group crew --version v1 --kind Captain --defaulting --programmatic-validation
if [ $project == "project-v3" ]; then
if [ $project == "project-v3" ] || [ $project == "project-v3-with-kustomize-v2" ]; then
$kb create webhook --group crew --version v1 --kind Captain --defaulting --programmatic-validation --force
fi

Expand All @@ -61,7 +61,7 @@ function scaffold_test_project {
fi
$kb create webhook --group crew --version v1 --kind FirstMate --conversion

if [ $project == "project-v3" ]; then
if [ $project == "project-v3" ] || [ $project == "project-v3-with-kustomize-v2" ]; then
$kb create api --group crew --version v1 --kind Admiral --plural=admirales --controller=true --resource=true --namespaced=false --make=false
$kb create webhook --group crew --version v1 --kind Admiral --plural=admirales --defaulting
else
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v3-with-kustomize-v2/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ resources:
group: crew
kind: Admiral
path: sigs.k8s.io/kubebuilder/testdata/project-v3-with-kustomize-v2/api/v1
plural: admirales
version: v1
webhooks:
defaulting: true
Expand Down
4 changes: 2 additions & 2 deletions testdata/project-v3-with-kustomize-v2/api/v1/admiral_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ type AdmiralStatus struct {

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:resource:path=admirales,scope=Cluster

// Admiral is the Schema for the admirals API
// Admiral is the Schema for the admirales API
type Admiral struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (r *Admiral) SetupWebhookWithManager(mgr ctrl.Manager) error {

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-crew-testproject-org-v1-admiral,mutating=true,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=admirals,verbs=create;update,versions=v1,name=madmiral.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/mutate-crew-testproject-org-v1-admiral,mutating=true,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=admirales,verbs=create;update,versions=v1,name=madmiral.kb.io,admissionReviewVersions=v1

var _ webhook.Defaulter = &Admiral{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: admirals.crew.testproject.org
name: admirales.crew.testproject.org
spec:
group: crew.testproject.org
names:
kind: Admiral
listKind: AdmiralList
plural: admirals
plural: admirales
singular: admiral
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: Admiral is the Schema for the admirals API
description: Admiral is the Schema for the admirales API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
resources:
- bases/crew.testproject.org_captains.yaml
- bases/crew.testproject.org_firstmates.yaml
- bases/crew.testproject.org_admirals.yaml
- bases/crew.testproject.org_admirales.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_captains.yaml
#- patches/webhook_in_firstmates.yaml
#- patches/webhook_in_admirals.yaml
#- patches/webhook_in_admirales.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- patches/cainjection_in_captains.yaml
#- patches/cainjection_in_firstmates.yaml
#- patches/cainjection_in_admirals.yaml
#- patches/cainjection_in_admirales.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
name: admirals.crew.testproject.org
name: admirales.crew.testproject.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: admirals.crew.testproject.org
name: admirales.crew.testproject.org
spec:
conversion:
strategy: Webhook
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# permissions for end users to edit admirals.
# permissions for end users to edit admirales.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand All @@ -7,7 +7,7 @@ rules:
- apiGroups:
- crew.testproject.org
resources:
- admirals
- admirales
verbs:
- create
- delete
Expand All @@ -19,6 +19,6 @@ rules:
- apiGroups:
- crew.testproject.org
resources:
- admirals/status
- admirales/status
verbs:
- get
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# permissions for end users to view admirals.
# permissions for end users to view admirales.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand All @@ -7,14 +7,14 @@ rules:
- apiGroups:
- crew.testproject.org
resources:
- admirals
- admirales
verbs:
- get
- list
- watch
- apiGroups:
- crew.testproject.org
resources:
- admirals/status
- admirales/status
verbs:
- get
6 changes: 3 additions & 3 deletions testdata/project-v3-with-kustomize-v2/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rules:
- apiGroups:
- crew.testproject.org
resources:
- admirals
- admirales
verbs:
- create
- delete
Expand All @@ -20,13 +20,13 @@ rules:
- apiGroups:
- crew.testproject.org
resources:
- admirals/finalizers
- admirales/finalizers
verbs:
- update
- apiGroups:
- crew.testproject.org
resources:
- admirals/status
- admirales/status
verbs:
- get
- patch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ webhooks:
- CREATE
- UPDATE
resources:
- admirals
- admirales
sideEffects: None
- admissionReviewVersions:
- v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type AdmiralReconciler struct {
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirals,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirals/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirals/finalizers,verbs=update
//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirales,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirales/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirales/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down

0 comments on commit 8b0f136

Please sign in to comment.