Skip to content

Commit

Permalink
feat: garm v0.1.5 (#158)
Browse files Browse the repository at this point in the history
This PR attempts to implement the new set of changes and api changes
garm requires for its version v0.1.5. This includes:
- New Credentials API
- New Endpoint API
- Update Garm Server Config Urls via CR

Fixes #150, fixes #143, fixes #127, fixes #139

Signed-off-by: Mario Constanti <[email protected]>
Co-authored-by: Mario Constanti <[email protected]>
  • Loading branch information
rafalgalaw and bavarianbidi authored Oct 21, 2024
1 parent ae4fd78 commit ee9029d
Show file tree
Hide file tree
Showing 112 changed files with 9,456 additions and 1,210 deletions.
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

# 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

0 comments on commit ee9029d

Please sign in to comment.