Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: garm v0.1.5 #158

Merged
merged 30 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c3f6d4e
feat(controller-info): reflect controller-info, update urls via api
rafalgalaw Aug 13, 2024
d2b95d0
feat(endpoint): implement endpoint api
rafalgalaw Aug 14, 2024
c7dd846
feat(githubcredentials): implement credentials api
rafalgalaw Aug 14, 2024
540e52b
fixes
rafalgalaw Aug 15, 2024
a22f25e
fix(controller): organization tests
rafalgalaw Aug 20, 2024
6c2168c
fix(controller): enterprise tests
rafalgalaw Aug 20, 2024
4a6e374
fix(controller): repository tests
rafalgalaw Aug 20, 2024
0561942
fix(controller): pool tests
rafalgalaw Aug 20, 2024
c790b09
fix: linter
rafalgalaw Aug 20, 2024
37040b8
fix(api): rename endpoint crd to github_endpoint crd
rafalgalaw Aug 25, 2024
1abee19
feat(test): add github_endpoint reconciler tests
rafalgalaw Aug 26, 2024
08a6a65
fix: garm-server-config tests
rafalgalaw Sep 10, 2024
75c3b40
feat: add poolBalancerType field to enterprise, org and repo
rafalgalaw Sep 10, 2024
06690d8
feat: introduce v1beta1 api type
rafalgalaw Sep 16, 2024
b9c53fd
feat: add conversion generator
bavarianbidi Sep 17, 2024
89b0036
feat: prepare for conversion code generation
bavarianbidi Sep 17, 2024
f557d7f
feat: add generated conversion code
bavarianbidi Sep 17, 2024
79185ba
feat: add example manual conversion implementation
bavarianbidi Sep 17, 2024
4ad8377
feat: add manual conversions for enterprise, org and repo
rafalgalaw Sep 30, 2024
fc51e77
fix: v1beta1 tests
rafalgalaw Sep 30, 2024
17df55f
fix: remove pool adoption and always create pool
rafalgalaw Oct 1, 2024
64f6d2f
fix: webhooks and add missing conversions
rafalgalaw Oct 7, 2024
d3c3dc4
fix linter findings and build issues
bavarianbidi Oct 16, 2024
e76d57d
chore: add license header
bavarianbidi Oct 17, 2024
528e825
fix: remove unused logger
bavarianbidi Oct 17, 2024
00bc110
fix: remove nonexisting api resources
bavarianbidi Oct 17, 2024
aa15df6
remove pool adoption test
bavarianbidi Oct 17, 2024
99827da
set current todo to nolint
bavarianbidi Oct 17, 2024
e239cf6
log webhook with values
bavarianbidi Oct 17, 2024
c153b89
change githubcredential CRD to singular
bavarianbidi Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ linters-settings:
gosec:
excludes:
- G115 # Potential integer overflow when converting between integer types

issues:
exclude-rules:
# exclude revive warnings for generated code
- linters:
- revive
path: 'api/v1alpha1/(.+)_conversion\.go'
text: "var-naming: don't use underscores in Go names; func (.+)"
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ help: ## Display this help.
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: conversion
conversion: conversion-gen
$(CONVERSION_GEN) --go-header-file hack/boilerplate.go.txt --output-file zz_generated.conversion.go github.com/mercedes-benz/garm-operator/api/v1alpha1

.PHONY: generate
generate: controller-gen mockgen ## Generate mock client and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate: controller-gen conversion mockgen ## Generate mock client and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
go generate ./...

Expand Down Expand Up @@ -162,6 +166,7 @@ $(LOCALBIN):
KUBECTL ?= kubectl
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
CONVERSION_GEN ?= $(LOCALBIN)/conversion-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
MOCKGEN ?= $(LOCALBIN)/mockgen
Expand All @@ -176,7 +181,8 @@ KIND ?= $(LOCALBIN)/kind
## Tool Versions
KUSTOMIZE_VERSION ?= v5.0.1
CONTROLLER_TOOLS_VERSION ?= v0.15.0
GOLANGCI_LINT_VERSION ?= v1.61.0
CONVERSION_GEN_VERSION ?= v0.30.5
GOLANGCI_LINT_VERSION ?= v1.59.1
MOCKGEN_VERSION ?= v0.4.0
GORELEASER_VERSION ?= v1.21.0
MDTOC_VERSION ?= v1.1.0
Expand All @@ -200,6 +206,12 @@ $(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

.PHONY: conversion-gen
conversion-gen: $(CONVERSION_GEN) ## Download conversion-gen locally if necessary. If wrong version is installed, it will be overwritten.
$(CONVERSION_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/conversion-gen || \
GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/conversion-gen@$(CONVERSION_GEN_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
Expand Down
214 changes: 150 additions & 64 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,74 +1,160 @@
# SPDX-License-Identifier: MIT
bavarianbidi marked this conversation as resolved.
Show resolved Hide resolved

# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: mercedes-benz.com
layout:
- go.kubebuilder.io/v4
- go.kubebuilder.io/v4
projectName: garm-operator
repo: github.com/mercedes-benz/garm-operator
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Enterprise
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Pool
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Organization
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Image
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Repository
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Runner
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Enterprise
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Pool
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
conversion: true
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Organization
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Image
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
conversion: true
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Repository
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
conversion: true
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Runner
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Enterprise
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Organization
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Repository
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Pool
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Runner
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: Image
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: GitHubEndpoint
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: GitHubCredential
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: mercedes-benz.com
group: garm-operator
kind: GarmServerConfig
path: github.com/mercedes-benz/garm-operator/api/v1beta1
version: v1beta1
version: "3"
7 changes: 5 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ allow_k8s_contexts('kind-garm-operator')
# as the plugin has already well written readiness checks we can use it to wait for
deploy_cert_manager(
kind_cluster_name='garm-operator', # just for security reasons ;-)
version='v1.12.0' # the version of cert-manager to deploy
version='v1.15.3' # the version of cert-manager to deploy
)

# mode could be either 'local' or 'debug'
# when set to 'debug', delve will be used within the container to start
# the manager binary and the dlv debug port will be exposed
#
# for more details, please read the DEVELOPMENT.md
mode = 'local'
mode = 'local'

# kustomize overlays
templated_yaml = kustomize('config/overlays/' + mode)
Expand All @@ -36,6 +36,9 @@ k8s_resource(
'pools.garm-operator.mercedes-benz.com:customresourcedefinition',
'runners.garm-operator.mercedes-benz.com:customresourcedefinition',
'repositories.garm-operator.mercedes-benz.com:customresourcedefinition',
'garmserverconfigs.garm-operator.mercedes-benz.com:customresourcedefinition',
'githubcredential.garm-operator.mercedes-benz.com:customresourcedefinition',
'githubendpoints.garm-operator.mercedes-benz.com:customresourcedefinition',
'garm-operator-controller-manager:serviceaccount',
'garm-operator-leader-election-role:role',
'garm-operator-manager-role:clusterrole',
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: MIT

// +k8s:conversion-gen=github.com/mercedes-benz/garm-operator/api/v1beta1
package v1alpha1
36 changes: 36 additions & 0 deletions api/v1alpha1/enterprise_conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
apiconversion "k8s.io/apimachinery/pkg/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"

"github.com/mercedes-benz/garm-operator/api/v1beta1"
)

var _ conversion.Convertible = &Enterprise{}

func (e *Enterprise) ConvertTo(dstRaw conversion.Hub) error {
return Convert_v1alpha1_Enterprise_To_v1beta1_Enterprise(e, dstRaw.(*v1beta1.Enterprise), nil)
}

func (e *Enterprise) ConvertFrom(dstRaw conversion.Hub) error {
return Convert_v1beta1_Enterprise_To_v1alpha1_Enterprise(dstRaw.(*v1beta1.Enterprise), e, nil)
}

func Convert_v1alpha1_EnterpriseSpec_To_v1beta1_EnterpriseSpec(in *EnterpriseSpec, out *v1beta1.EnterpriseSpec, s apiconversion.Scope) error {
out.CredentialsRef = corev1.TypedLocalObjectReference{
Name: in.CredentialsName,
Kind: "GitHubCredential",
APIGroup: &v1beta1.GroupVersion.Group,
}

return autoConvert_v1alpha1_EnterpriseSpec_To_v1beta1_EnterpriseSpec(in, out, s)
}

func Convert_v1beta1_EnterpriseSpec_To_v1alpha1_EnterpriseSpec(in *v1beta1.EnterpriseSpec, out *EnterpriseSpec, s apiconversion.Scope) error {
out.CredentialsName = in.CredentialsRef.Name

return autoConvert_v1beta1_EnterpriseSpec_To_v1alpha1_EnterpriseSpec(in, out, s)
}
13 changes: 13 additions & 0 deletions api/v1alpha1/enterprise_webhook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT

package v1alpha1

import (
ctrl "sigs.k8s.io/controller-runtime"
)

func (r *Enterprise) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Complete()
}
3 changes: 3 additions & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ var (

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

// localSchemeBuilder is getting used by the generated conversion
localSchemeBuilder = SchemeBuilder.SchemeBuilder
)
18 changes: 18 additions & 0 deletions api/v1alpha1/image_conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
package v1alpha1

import (
"sigs.k8s.io/controller-runtime/pkg/conversion"

"github.com/mercedes-benz/garm-operator/api/v1beta1"
)

var _ conversion.Convertible = &Image{}

func (i *Image) ConvertTo(dstRaw conversion.Hub) error {
return Convert_v1alpha1_Image_To_v1beta1_Image(i, dstRaw.(*v1beta1.Image), nil)
}

func (i *Image) ConvertFrom(dstRaw conversion.Hub) error {
return Convert_v1beta1_Image_To_v1alpha1_Image(dstRaw.(*v1beta1.Image), i, nil)
}
Loading