Skip to content

Commit

Permalink
- simplify create/update object
Browse files Browse the repository at this point in the history
- improve log
- fix bug with object copy
- add more tests
- rename folders
- remove multigroup
  • Loading branch information
ericogr committed Mar 20, 2021
1 parent 3b1cc20 commit 77c0579
Show file tree
Hide file tree
Showing 33 changed files with 253 additions and 115 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ all: manager

# Run tests
test: generate fmt vet manifests
go test ./... -coverprofile cover.out
go test -v ./... -coverprofile cover.out

# Build manager binary
manager: generate fmt vet
Expand Down Expand Up @@ -68,7 +68,7 @@ docker-push:
docker push ${IMG}

security: gosec
gosec . controllers/template.ericogr.github.com apis/template.ericogr.github.com/v1/
gosec . controllers/template.k8s.ericogr.com.br apis/template.k8s.ericogr.com.br/v1/

# find or download controller-gen
# download controller-gen if necessary
Expand Down
7 changes: 3 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
domain: github.com
multigroup: true
domain: k8s.ericogr.com.br
repo: github.com/ericogr/k8s-object-template
resources:
- group: template.ericogr.github.com
- group: template
kind: ObjectTemplate
version: v1
- group: template.ericogr.github.com
- group: template
kind: ObjectTemplateParams
version: v1
version: "2"
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rules:
- update
# <<
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams
verbs:
Expand All @@ -51,15 +51,15 @@ rules:
- update
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams/status
verbs:
- get
- patch
- update
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates
verbs:
Expand All @@ -71,7 +71,7 @@ rules:
- update
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates/status
verbs:
Expand All @@ -80,7 +80,7 @@ rules:
- update
```
# New Custom Resource Definitions (CRD's)
You have two new CRD's: [ObjectTemplate](config/crd/bases/template.ericogr.github.com_objecttemplates.yaml) and [ObjectTemplateParameters](config/crd/bases/template.ericogr.github.com_objecttemplateparams.yaml).
You have two new CRD's: [ObjectTemplate](config/crd/bases/template.k8s.ericogr.com.br_objecttemplates.yaml) and [ObjectTemplateParameters](config/crd/bases/template.k8s.ericogr.com.br_objecttemplateparams.yaml).
**ObjectTemplate (cluster scope):** template used to create kubernetes objects at users namespaces (can be used by k8s admins)
Expand All @@ -93,7 +93,7 @@ Use templates as a base to create kubernetes objects. Users can define your own
```yaml
---
apiVersion: template.ericogr.github.com/v1
apiVersion: template.k8s.ericogr.com.br/v1
kind: ObjectTemplate
metadata:
name: objecttemplate-configmap-test
Expand Down Expand Up @@ -157,7 +157,7 @@ Users can define your own parameters to create new objects based on templates in

```yaml
---
apiVersion: template.ericogr.github.com/v1
apiVersion: template.k8s.ericogr.com.br/v1
kind: ObjectTemplateParams
metadata:
name: objecttemplateparams-sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1 contains API Schema definitions for the template.ericogr.github.com v1 API group
// Package v1 contains API Schema definitions for the template.k8s.ericogr.com.br v1 API group
// +kubebuilder:object:generate=true
// +groupName=template.ericogr.github.com
// +groupName=template.k8s.ericogr.com.br
package v1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "template.ericogr.github.com", Version: "v1"}
GroupVersion = schema.GroupVersion{Group: "template.k8s.ericogr.com.br", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
creationTimestamp: null
name: objecttemplateparams.template.ericogr.github.com
name: objecttemplateparams.template.k8s.ericogr.com.br
spec:
additionalPrinterColumns:
- JSONPath: .status.status
Expand All @@ -15,7 +15,7 @@ spec:
- JSONPath: .metadata.creationTimestamp
name: age
type: date
group: template.ericogr.github.com
group: template.k8s.ericogr.com.br
names:
kind: ObjectTemplateParams
listKind: ObjectTemplateParamsList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
creationTimestamp: null
name: objecttemplates.template.ericogr.github.com
name: objecttemplates.template.k8s.ericogr.com.br
spec:
additionalPrinterColumns:
- JSONPath: .status.status
Expand All @@ -15,7 +15,7 @@ spec:
- JSONPath: .metadata.creationTimestamp
name: age
type: date
group: template.ericogr.github.com
group: template.k8s.ericogr.com.br
names:
kind: ObjectTemplate
listKind: ObjectTemplateList
Expand Down
4 changes: 2 additions & 2 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/template.ericogr.github.com_objecttemplates.yaml
- bases/template.ericogr.github.com_objecttemplateparams.yaml
- bases/template.k8s.ericogr.com.br_objecttemplates.yaml
- bases/template.k8s.ericogr.com.br_objecttemplateparams.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: objecttemplateparams.template.ericogr.github.com
name: objecttemplateparams.template.k8s.ericogr.com.br
2 changes: 1 addition & 1 deletion config/crd/patches/cainjection_in_objecttemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: objecttemplates.template.ericogr.github.com
name: objecttemplates.template.k8s.ericogr.com.br
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_objecttemplateparams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: objecttemplateparams.template.ericogr.github.com
name: objecttemplateparams.template.k8s.ericogr.com.br
spec:
conversion:
strategy: Webhook
Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_objecttemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: objecttemplates.template.ericogr.github.com
name: objecttemplates.template.k8s.ericogr.com.br
spec:
conversion:
strategy: Webhook
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/objecttemplate_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: objecttemplate-editor-role
rules:
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates
verbs:
Expand All @@ -17,7 +17,7 @@ rules:
- update
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates/status
verbs:
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/objecttemplate_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ metadata:
name: objecttemplate-viewer-role
rules:
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates
verbs:
- get
- list
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates/status
verbs:
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/objecttemplateparams_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: objecttemplateparams-editor-role
rules:
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams
verbs:
Expand All @@ -17,7 +17,7 @@ rules:
- update
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams/status
verbs:
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/objecttemplateparams_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ metadata:
name: objecttemplateparams-viewer-role
rules:
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams
verbs:
- get
- list
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams/status
verbs:
Expand Down
8 changes: 4 additions & 4 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rules:
- update
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams
verbs:
Expand All @@ -30,15 +30,15 @@ rules:
- update
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplateparams/status
verbs:
- get
- patch
- update
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates
verbs:
Expand All @@ -50,7 +50,7 @@ rules:
- update
- watch
- apiGroups:
- template.ericogr.github.com
- template.k8s.ericogr.com.br
resources:
- objecttemplates/status
verbs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: template.ericogr.github.com/v1
apiVersion: template.k8s.ericogr.com.br/v1
kind: ObjectTemplate
metadata:
name: objecttemplate-configmap-test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
apiVersion: template.ericogr.github.com/v1
apiVersion: template.k8s.ericogr.com.br/v1
kind: ObjectTemplateParams
metadata:
name: objecttemplateparams-sample
namespace: default
spec:
templates:
- name: objecttemplate-configmap-test
Expand Down
Loading

0 comments on commit 77c0579

Please sign in to comment.