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

Introduce the CFTask resource #1155

Merged
merged 1 commit into from May 31, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions controllers/PROJECT
Expand Up @@ -110,4 +110,13 @@ resources:
kind: CFSpace
path: code.cloudfoundry.org/korifi/controllers/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cloudfoundry.org
group: korifi
kind: CFTask
path: code.cloudfoundry.org/korifi/controllers/api/v1alpha1
version: v1alpha1
version: "3"
65 changes: 65 additions & 0 deletions controllers/api/v1alpha1/cftask_types.go
@@ -0,0 +1,65 @@
/*
Copyright 2021.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// CFTaskSpec defines the desired state of CFTask
type CFTaskSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Command []string `json:"command,omitempty"`
AppRef corev1.LocalObjectReference `json:"appRef,omitempty"`
}

// CFTaskStatus defines the observed state of CFTask
type CFTaskStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

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

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

Spec CFTaskSpec `json:"spec,omitempty"`
Status CFTaskStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&CFTask{}, &CFTaskList{})
}
1 change: 1 addition & 0 deletions controllers/api/v1alpha1/shared_types.go
Expand Up @@ -14,6 +14,7 @@ const (
CFProcessTypeLabelKey = "korifi.cloudfoundry.org/process-type"
CFDomainGUIDLabelKey = "korifi.cloudfoundry.org/domain-guid"
CFRouteGUIDLabelKey = "korifi.cloudfoundry.org/route-guid"
CFTaskGUIDLabelKey = "korifi.cloudfoundry.org/task-guid"

StagingConditionType = "Staging"
ReadyConditionType = "Ready"
Expand Down
95 changes: 95 additions & 0 deletions controllers/api/v1alpha1/zz_generated.deepcopy.go

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

11 changes: 11 additions & 0 deletions controllers/config/cf_roles/cf_admin.yaml
Expand Up @@ -134,6 +134,17 @@ rules:
- update
- watch

- apiGroups:
- korifi.cloudfoundry.org
resources:
- cftasks
verbs:
- get
- create
- delete
- list
- patch

- apiGroups:
- kpack.io
resources:
Expand Down
11 changes: 11 additions & 0 deletions controllers/config/cf_roles/cf_space_developer.yaml
Expand Up @@ -98,6 +98,17 @@ rules:
- list
- patch

- apiGroups:
- korifi.cloudfoundry.org
resources:
- cftasks
verbs:
- get
- create
- delete
- list
- patch

- apiGroups:
- kpack.io
resources:
Expand Down
65 changes: 65 additions & 0 deletions controllers/config/crd/bases/korifi.cloudfoundry.org_cftasks.yaml
@@ -0,0 +1,65 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: cftasks.korifi.cloudfoundry.org
spec:
group: korifi.cloudfoundry.org
names:
kind: CFTask
listKind: CFTaskList
plural: cftasks
singular: cftask
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: CFTask is the Schema for the cftasks 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: CFTaskSpec defines the desired state of CFTask
properties:
appRef:
description: LocalObjectReference contains enough information to let
you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
command:
items:
type: string
type: array
type: object
status:
description: CFTaskStatus defines the observed state of CFTask
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
3 changes: 3 additions & 0 deletions controllers/config/crd/kustomization.yaml
Expand Up @@ -13,6 +13,7 @@ resources:
- bases/korifi.cloudfoundry.org_cforgs.yaml
- bases/korifi.cloudfoundry.org_cfspaces.yaml
- bases/korifi.cloudfoundry.org_buildworkloads.yaml
- bases/korifi.cloudfoundry.org_cftasks.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand All @@ -28,6 +29,7 @@ patchesStrategicMerge:
#- patches/webhook_in_cfservicebindings.yaml
#- patches/webhook_in_cforgs.yaml
#- patches/webhook_in_cfspaces.yaml
#- patches/webhook_in_cftasks.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
Expand All @@ -42,6 +44,7 @@ patchesStrategicMerge:
#- patches/cainjection_in_cfservicebindings.yaml
#- patches/cainjection_in_cforgs.yaml
#- patches/cainjection_in_cfspaces.yaml
#- patches/cainjection_in_cftasks.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
7 changes: 7 additions & 0 deletions controllers/config/crd/patches/cainjection_in_cftasks.yaml
@@ -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: cftasks.korifi.cloudfoundry.org
16 changes: 16 additions & 0 deletions controllers/config/crd/patches/webhook_in_cftasks.yaml
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: cftasks.korifi.cloudfoundry.org
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
24 changes: 24 additions & 0 deletions controllers/config/rbac/cftask_editor_role.yaml
@@ -0,0 +1,24 @@
# permissions for end users to edit cftasks.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cftask-editor-role
rules:
- apiGroups:
- korifi.cloudfoundry.org
resources:
- cftasks
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- korifi.cloudfoundry.org
resources:
- cftasks/status
verbs:
- get
20 changes: 20 additions & 0 deletions controllers/config/rbac/cftask_viewer_role.yaml
@@ -0,0 +1,20 @@
# permissions for end users to view cftasks.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cftask-viewer-role
rules:
- apiGroups:
- korifi.cloudfoundry.org
resources:
- cftasks
verbs:
- get
- list
- watch
- apiGroups:
- korifi.cloudfoundry.org
resources:
- cftasks/status
verbs:
- get