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(RHTAPWATCH-816): ProjectDevelopmentStreamTemplate CR #6

Merged
merged 1 commit into from
Mar 10, 2024
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
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ resources:
kind: Project
path: github.com/konflux-ci/project-controller/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: konflux.dev
group: projctl
kind: ProjectDevelopmentStreamTemplate
path: github.com/konflux-ci/project-controller/api/v1beta1
version: v1beta1
version: "3"
75 changes: 75 additions & 0 deletions api/v1beta1/projectdevelopmentstreamtemplate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Copyright 2024.

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 v1beta1

import (
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.

// Settings for a variable to be used to customize the template results
type ProjectDevelopmentStreamTemplateVariable struct {
// Variable name
Name string `json:"name"`
// Optional default value for use when a value for the variable is not given
// can reference values of other previously defined variables using the Go
// text/template syntax
Default *string `json:"default,omitempty"`
// Optional description for the variable for display in the UI
Description string `json:"description,omitempty"`
}

// ProjectDevelopmentStreamTemplateSpec defines the resources to be generated
// using a ProjectDevelopmentStreamTemplate
type ProjectDevelopmentStreamTemplateSpec struct {
// The name of the project this stream template belongs to
Project string `json:"project,omitempty"`
// List of variables to allow customizing the template results. The order
// variables in the list is significant as earlier variables can be
// referenced by the default values for later variables
Variables []ProjectDevelopmentStreamTemplateVariable `json:"variables,omitempty"`
// List of resources to be created for version made from this template
// certain values for resource properties may include references to
// variables using the Go-text/template syntax
Resources []UnstructuredObj `json:"resources,omitempty"`
}

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

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

Spec ProjectDevelopmentStreamTemplateSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&ProjectDevelopmentStreamTemplate{}, &ProjectDevelopmentStreamTemplateList{})
}
107 changes: 107 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,89 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: projectdevelopmentstreamtemplates.projctl.konflux.dev
spec:
group: projctl.konflux.dev
names:
kind: ProjectDevelopmentStreamTemplate
listKind: ProjectDevelopmentStreamTemplateList
plural: projectdevelopmentstreamtemplates
singular: projectdevelopmentstreamtemplate
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: ProjectDevelopmentStreamTemplate is the Schema for the projectdevelopmentstreamtemplates
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: |-
ProjectDevelopmentStreamTemplateSpec defines the resources to be generated
using a ProjectDevelopmentStreamTemplate
properties:
project:
description: The name of the project this stream template belongs
to
type: string
resources:
description: |-
List of resources to be created for version made from this template
certain values for resource properties may include references to
variables using the Go-text/template syntax
items:
type: object
x-kubernetes-preserve-unknown-fields: true
type: array
variables:
description: |-
List of variables to allow customizing the template results. The order
variables in the list is significant as earlier variables can be
referenced by the default values for later variables
items:
description: Settings for a variable to be used to customize the
template results
properties:
default:
description: |-
Optional default value for use when a value for the variable is not given
can reference values of other previously defined variables using the Go
text/template syntax
type: string
description:
description: Optional description for the variable for display
in the UI
type: string
name:
description: Variable name
type: string
required:
- name
type: object
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
resources:
- bases/projctl.konflux.dev_projectdevelopmentstreams.yaml
- bases/projctl.konflux.dev_projects.yaml
- bases/projctl.konflux.dev_projectdevelopmentstreamtemplates.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- path: patches/webhook_in_projectdevelopmentstreams.yaml
#- path: patches/webhook_in_projects.yaml
#- path: patches/webhook_in_projectdevelopmentstreamtemplates.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
#- path: patches/cainjection_in_projectdevelopmentstreams.yaml
#- path: patches/cainjection_in_projects.yaml
#- path: patches/cainjection_in_projectdevelopmentstreamtemplates.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
Expand Down
31 changes: 31 additions & 0 deletions config/rbac/projectdevelopmentstreamtemplate_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# permissions for end users to edit projectdevelopmentstreamtemplates.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: projectdevelopmentstreamtemplate-editor-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: project-controller
app.kubernetes.io/part-of: project-controller
app.kubernetes.io/managed-by: kustomize
name: projectdevelopmentstreamtemplate-editor-role
rules:
- apiGroups:
- projctl.konflux.dev
resources:
- projectdevelopmentstreamtemplates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- projctl.konflux.dev
resources:
- projectdevelopmentstreamtemplates/status
verbs:
- get
27 changes: 27 additions & 0 deletions config/rbac/projectdevelopmentstreamtemplate_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# permissions for end users to view projectdevelopmentstreamtemplates.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: projectdevelopmentstreamtemplate-viewer-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: project-controller
app.kubernetes.io/part-of: project-controller
app.kubernetes.io/managed-by: kustomize
name: projectdevelopmentstreamtemplate-viewer-role
rules:
- apiGroups:
- projctl.konflux.dev
resources:
- projectdevelopmentstreamtemplates
verbs:
- get
- list
- watch
- apiGroups:
- projctl.konflux.dev
resources:
- projectdevelopmentstreamtemplates/status
verbs:
- get
1 change: 1 addition & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
resources:
- projctl_v1beta1_projectdevelopmentstream.yaml
- projctl_v1beta1_project.yaml
- projctl_v1beta1_projectdevelopmentstreamtemplate.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
Loading
Loading