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

Creation of CompassManagerMapping CRD after successfull registration Runtime in Compass #27

Merged
merged 23 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
Expand Down Expand Up @@ -36,7 +33,7 @@ jobs:
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: --timeout=5m
args: --timeout=5m --out-format=github-actions

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ linters:
- godox # detects TODOs keywords
# - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt. Dissabled as can't work together with `gci`
- gomnd # detects magic numbers
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
# - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- nestif # reports deeply nested if statements
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/ internal/
COPY pkg/ pkg/
Expand Down
3 changes: 1 addition & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kyma-project.io
group: operator
kind: CompassManager
kind: CompassManagerMapping
path: github.com/kyma-project/compass-manager/api/v1beta1
version: v1beta1
version: "3"
36 changes: 36 additions & 0 deletions api/v1beta1/compassmanagermapping_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// CompassManagerMappingSpec defines the desired state of CompassManagerMapping
type CompassManagerMappingSpec struct{}

// CompassManagerMappingStatus defines the observed state of CompassManagerMapping
type CompassManagerMappingStatus struct{}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// CompassManagerMapping is the Schema for the compassmanagermappings API
type CompassManagerMapping struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CompassManagerMappingSpec `json:"spec,omitempty"`
Status CompassManagerMappingStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// CompassManagerMappingList contains a list of CompassManagerMapping
type CompassManagerMappingList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CompassManagerMapping `json:"items"`
}

func init() {
SchemeBuilder.Register(&CompassManagerMapping{}, &CompassManagerMappingList{})
}
20 changes: 20 additions & 0 deletions api/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Package v1beta1 contains API Schema definitions for the operator v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=operator.kyma-project.io
package v1beta1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "operator.kyma-project.io", Version: "v1beta1"} //nolint:gochecknoglobals

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} //nolint:gochecknoglobals

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme //nolint:gochecknoglobals
)
99 changes: 99 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.2
creationTimestamp: null
name: compassmanagermappings.operator.kyma-project.io
spec:
group: operator.kyma-project.io
names:
kind: CompassManagerMapping
listKind: CompassManagerMappingList
plural: compassmanagermappings
singular: compassmanagermapping
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: CompassManagerMapping is the Schema for the compassmanagermappings
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CompassManagerMappingSpec defines the desired state of CompassManagerMapping
type: object
status:
description: CompassManagerMappingStatus defines the observed state of
CompassManagerMapping
type: object
type: object
served: true
storage: true
subresources:
status: {}
21 changes: 21 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This kustomization.yaml is not intended to be run by itself,
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/operator.kyma-project.io_compassmanagermappings.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_compassmanagermappings.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_compassmanagermappings.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml
19 changes: 19 additions & 0 deletions config/crd/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
nameReference:
- kind: Service
version: v1
fieldSpecs:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/name

namespace:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false

varReference:
- path: metadata/annotations
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: compassmanagermappings.operator.kyma-project.io
16 changes: 16 additions & 0 deletions config/crd/patches/webhook_in_compassmanagermappings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: compassmanagermappings.operator.kyma-project.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
31 changes: 31 additions & 0 deletions config/rbac/compassmanagermapping_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# permissions for end users to edit compassmanagermappings.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: compassmanagermapping-editor-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: compass-manager
app.kubernetes.io/part-of: compass-manager
app.kubernetes.io/managed-by: kustomize
name: compassmanagermapping-editor-role
rules:
- apiGroups:
- operator.kyma-project.io
resources:
- compassmanagermappings
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- operator.kyma-project.io
resources:
- compassmanagermappings/status
verbs:
- get
27 changes: 27 additions & 0 deletions config/rbac/compassmanagermapping_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# permissions for end users to view compassmanagermappings.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: compassmanagermapping-viewer-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: compass-manager
app.kubernetes.io/part-of: compass-manager
app.kubernetes.io/managed-by: kustomize
name: compassmanagermapping-viewer-role
rules:
- apiGroups:
- operator.kyma-project.io
resources:
- compassmanagermappings
verbs:
- get
- list
- watch
- apiGroups:
- operator.kyma-project.io
resources:
- compassmanagermappings/status
verbs:
- get
Loading