Skip to content

Commit

Permalink
chore: Describe GerritMergeRequest CR spec (#28)
Browse files Browse the repository at this point in the history
Change-Id: I7f999749ac5bca82289fa7e5cc5a886ebb37adf8
  • Loading branch information
zmotso committed Mar 20, 2024
1 parent ed55e9c commit ebf50e0
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV OPERATOR=/usr/local/bin/gerrit-operator \
USER_NAME=gerrit-operator \
HOME=/home/gerrit-operator

RUN apk add --no-cache ca-certificates==20230506-r0 \
RUN apk add --no-cache ca-certificates==20240226-r0 \
openssh-client==9.3_p2-r1 \
openssl==3.1.4-r5 \
git==2.40.1-r0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ crdoc: ## Download crdoc locally if necessary.
CONTROLLER_GEN = $(LOCALBIN)/controller-gen
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,v0.9.2)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,v0.13.0)
# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
Expand Down
30 changes: 27 additions & 3 deletions api/v1/gerritmergerequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,52 @@ import (

// GerritMergeRequestSpec defines the desired state of GerritMergeRequest.
type GerritMergeRequestSpec struct {
// OwnerName indicates which gerrit CR should be taken to initialize correct client.
// +nullable
// OwnerName is the name of Gerrit CR, which should be used to initialize the client.
// If empty, the operator will get first Gerrit CR from the namespace.
// +optional
// +kubebuilder:example:=`gerrit`
OwnerName string `json:"ownerName"`

// ProjectName is gerrit project name.
// +required
// +kubebuilder:example:=`my-project`
ProjectName string `json:"projectName"`

// AuthorName is the name of the user who creates the merge request.
// +required
// +kubebuilder:example:=`John Doe`
AuthorName string `json:"authorName"`

// AuthorEmail is the email of the user who creates the merge request.
// +required
// +kubebuilder:example:=`john.foe@mail.com`
AuthorEmail string `json:"authorEmail"`

// TargetBranch default value is master.
// TargetBranch is the name of the branch to which the changes should be merged.
// If changesConfigMap is set, the targetBranch can be only the origin HEAD branch.
// +optional
// +kubebuilder:default=master
// +kubebuilder:example:=master
TargetBranch string `json:"targetBranch,omitempty"`

// SourceBranch is the name of the branch from which the changes should be merged.
// If empty, changesConfigMap should be set.
// +optional
// +kubebuilder:example:=new-feature
SourceBranch string `json:"sourceBranch,omitempty"`

// CommitMessage is the commit message for the merge request.
// If empty, the operator will generate the commit message.
// +optional
// +kubebuilder:example:=`merge new-feature to master`
CommitMessage string `json:"commitMessage,omitempty"`

// ChangesConfigMap is the name of the ConfigMap, which contains files contents that should be merged.
// ConfigMap should eny data keys with content in the json format: {"path": "/controllers/user.go", "contents": "some code here"}.
// If files already exist in the project, they will be overwritten.
// If empty, sourceBranch should be set.
// +optional
// +kubebuilder:example:=`config-map-new-feature`
ChangesConfigMap string `json:"changesConfigMap,omitempty"`

// AdditionalArguments contains merge command additional command line arguments.
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/v2.edp.epam.com_gerritgroupmembers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritgroupmembers.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/v2.edp.epam.com_gerritgroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritgroups.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
36 changes: 29 additions & 7 deletions config/crd/bases/v2.edp.epam.com_gerritmergerequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritmergerequests.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down Expand Up @@ -44,30 +43,53 @@ spec:
nullable: true
type: array
authorEmail:
description: AuthorEmail is the email of the user who creates the
merge request.
example: john.foe@mail.com
type: string
authorName:
description: AuthorName is the name of the user who creates the merge
request.
example: John Doe
type: string
changesConfigMap:
description: 'ChangesConfigMap is the name of the ConfigMap, which
contains files contents that should be merged. ConfigMap should
eny data keys with content in the json format: {"path": "/controllers/user.go",
"contents": "some code here"}. If files already exist in the project,
they will be overwritten. If empty, sourceBranch should be set.'
example: config-map-new-feature
type: string
commitMessage:
description: CommitMessage is the commit message for the merge request.
If empty, the operator will generate the commit message.
example: merge new-feature to master
type: string
ownerName:
description: OwnerName indicates which gerrit CR should be taken to
initialize correct client.
nullable: true
description: OwnerName is the name of Gerrit CR, which should be used
to initialize the client. If empty, the operator will get first
Gerrit CR from the namespace.
example: gerrit
type: string
projectName:
description: ProjectName is gerrit project name.
example: my-project
type: string
sourceBranch:
description: SourceBranch is the name of the branch from which the
changes should be merged. If empty, changesConfigMap should be set.
example: new-feature
type: string
targetBranch:
description: TargetBranch default value is master.
default: master
description: TargetBranch is the name of the branch to which the changes
should be merged. If changesConfigMap is set, the targetBranch can
be only the origin HEAD branch.
example: master
type: string
required:
- authorEmail
- authorName
- ownerName
- projectName
type: object
status:
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/v2.edp.epam.com_gerritprojectaccesses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritprojectaccesses.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/v2.edp.epam.com_gerritprojects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritprojects.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritreplicationconfigs.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/v2.edp.epam.com_gerrits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerrits.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
1 change: 0 additions & 1 deletion config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: manager-role
namespace: placeholder
rules:
Expand Down
27 changes: 27 additions & 0 deletions deploy-templates/_crd_examples/merge-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,30 @@ spec:
commitMessage: kawabunga
authorName: John Doe
authorEmail: john.doe@example.com

---

apiVersion: v2.edp.epam.com/v1
kind: GerritMergeRequest
metadata:
name: test-commit
spec:
ownerName: gerrit
targetBranch: feature1
projectName: app1
commitMessage: Add txt2.txt file
authorName: John Doe
authorEmail: john.doe@example.com
changesConfigMap: test-merge-changes

---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-merge-changes
data:
changes: |
{
"path": "txt2.txt",
"content": "Hello, World!"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritgroupmembers.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
3 changes: 1 addition & 2 deletions deploy-templates/crds/v2.edp.epam.com_gerritgroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritgroups.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
36 changes: 29 additions & 7 deletions deploy-templates/crds/v2.edp.epam.com_gerritmergerequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritmergerequests.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down Expand Up @@ -44,30 +43,53 @@ spec:
nullable: true
type: array
authorEmail:
description: AuthorEmail is the email of the user who creates the
merge request.
example: john.foe@mail.com
type: string
authorName:
description: AuthorName is the name of the user who creates the merge
request.
example: John Doe
type: string
changesConfigMap:
description: 'ChangesConfigMap is the name of the ConfigMap, which
contains files contents that should be merged. ConfigMap should
eny data keys with content in the json format: {"path": "/controllers/user.go",
"contents": "some code here"}. If files already exist in the project,
they will be overwritten. If empty, sourceBranch should be set.'
example: config-map-new-feature
type: string
commitMessage:
description: CommitMessage is the commit message for the merge request.
If empty, the operator will generate the commit message.
example: merge new-feature to master
type: string
ownerName:
description: OwnerName indicates which gerrit CR should be taken to
initialize correct client.
nullable: true
description: OwnerName is the name of Gerrit CR, which should be used
to initialize the client. If empty, the operator will get first
Gerrit CR from the namespace.
example: gerrit
type: string
projectName:
description: ProjectName is gerrit project name.
example: my-project
type: string
sourceBranch:
description: SourceBranch is the name of the branch from which the
changes should be merged. If empty, changesConfigMap should be set.
example: new-feature
type: string
targetBranch:
description: TargetBranch default value is master.
default: master
description: TargetBranch is the name of the branch to which the changes
should be merged. If changesConfigMap is set, the targetBranch can
be only the origin HEAD branch.
example: master
type: string
required:
- authorEmail
- authorName
- ownerName
- projectName
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritprojectaccesses.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
3 changes: 1 addition & 2 deletions deploy-templates/crds/v2.edp.epam.com_gerritprojects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritprojects.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerritreplicationconfigs.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
3 changes: 1 addition & 2 deletions deploy-templates/crds/v2.edp.epam.com_gerrits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.13.0
name: gerrits.v2.edp.epam.com
spec:
group: v2.edp.epam.com
Expand Down
Loading

0 comments on commit ebf50e0

Please sign in to comment.