@@ -21,17 +21,7 @@ import (
2121 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222)
2323
24- // ComponentSrcType describes the type of
25- // the src for the Component.
26- // Only one of the following location type may be specified.
27- // +kubebuilder:validation:Enum=Git;Image
28- type ComponentSrcType string
29-
30- const (
31- GitComponentSrcType ComponentSrcType = "Git"
32- ImageComponentSrcType ComponentSrcType = "Image"
33- )
34-
24+ // !!! Will be removed when we remove old model
3525type GitSource struct {
3626 // An HTTPS URL representing the git repository to create the component from.
3727 URL string `json:"url"`
@@ -65,7 +55,164 @@ type ComponentSource struct {
6555type ComponentSourceUnion struct {
6656 // Git Source for a Component.
6757 // Optional.
58+ // !!! Will be removed when we remove old model
6859 GitSource * GitSource `json:"git,omitempty"`
60+
61+ // Git repository URL for the component.
62+ // Optional.
63+ // !!! Will be required when we remove old model
64+ GitURL string `json:"url,omitempty"`
65+
66+ // Dockerfile path for all versions, unless explicitly specified for a version.
67+ // Used only when sending a PR with build pipeline configuration was requested via 'spec.actions.create-pipeline-configuration-pr'.
68+ // Default: "Dockerfile"
69+ // Optional.
70+ DockerfileURI string `json:"dockerfileUri,omitempty"`
71+
72+ // List of all versions for this component.
73+ // Optional.
74+ // !!! Will be required when we remove old model
75+ Versions []ComponentVersion `json:"versions,omitempty"`
76+ }
77+
78+ type ComponentActions struct {
79+ // Send a PR with build pipeline configuration proposal for Component version(s).
80+ // If not set, version onboarding will be done without pipeline configuration PR.
81+ // Could be used after onboarding to create / renew build pipeline definition.
82+ // Optional.
83+ CreateConfiguration ComponentCreatePipelineConfiguration `json:"create-pipeline-configuration-pr,omitempty"`
84+
85+ // Specify name of component version to restart the push build for.
86+ // Can be specified together with 'trigger-push-builds' and any duplicates will be removed.
87+ // Optional.
88+ TriggerBuild string `json:"trigger-push-build,omitempty"`
89+
90+ // Specify names of component versions to restart the push build for.
91+ // Can be specified together with 'trigger-push-build' and any duplicates will be removed.
92+ // Optional.
93+ TriggerBuilds []string `json:"trigger-push-builds,omitempty"`
94+ }
95+
96+ type ComponentCreatePipelineConfiguration struct {
97+ // When specified it will send a PR with build pipeline configuration proposal for all Component versions.
98+ // Has precedence over 'version' and 'versions'.
99+ // Optional.
100+ AllVersions bool `json:"all-versions,omitempty"`
101+
102+ // When specified it will send a PR with build pipeline configuration proposal for the Component version.
103+ // Can be specified together with 'versions' and any duplicates will be removed.
104+ // Optional.
105+ Version string `json:"version,omitempty"`
106+
107+ // When specified it will send a PR with build pipeline configuration proposal for Component versions.
108+ // Can be specified together with 'version' and any duplicates will be removed.
109+ // Optional.
110+ Versions []string `json:"versions,omitempty"`
111+ }
112+
113+ type ComponentBuildPipeline struct {
114+ // Pipeline used for pull and push pipeline runs.
115+ // Can specify just one of: pipelinespec-from-bundle, pipelineref-by-name, pipelineref-by-git-resolver.
116+ // Optional.
117+ PullAndPush PipelineDefinition `json:"pull-and-push,omitempty"`
118+
119+ // Pipeline used for pull pipeline run.
120+ // Can specify just one of: pipelinespec-from-bundle, pipelineref-by-name, pipelineref-by-git-resolver.
121+ // Optional.
122+ Pull PipelineDefinition `json:"pull,omitempty"`
123+
124+ // Pipeline used for push pipeline run.
125+ // Can specify just one of: pipelinespec-from-bundle, pipelineref-by-name, pipelineref-by-git-resolver.
126+ // Optional.
127+ Push PipelineDefinition `json:"push,omitempty"`
128+ }
129+
130+ type PipelineDefinition struct {
131+ // Will be used to fill out PipelineRef in pipeline runs to user specific pipeline via git resolver,
132+ // specifying repository with a pipeline definition.
133+ // Optional.
134+ PipelineRefGit PipelineRefGitSpec `json:"pipelineref-by-git-resolver,omitempty"`
135+
136+ // Will be used to fill out PipelineRef in pipeline runs to user specific pipeline.
137+ // Such pipeline definition has to be in .tekton.
138+ // Optional.
139+ PipelineRefName string `json:"pipelineref-by-name,omitempty"`
140+
141+ // Will be used to fetch bundle and fill out PipelineSpec in pipeline runs.
142+ // Pipeline name is based on build-pipeline-config CM in build-service NS.
143+ // When 'latest' bundle is specified, bundle image will be used from CM.
144+ // When bundle is specified to specific image bundle, then that one will be used
145+ // and pipeline name will be used to fetch pipeline from that bundle.
146+ // Optional.
147+ PipelineSpecFromBundle PipelineSpecFromBundleSpec `json:"pipelinespec-from-bundle,omitempty"`
148+ }
149+
150+ type PipelineSpecFromBundleSpec struct {
151+ // Bundle image reference. Use 'latest' to get bundle from build-pipeline-config CM,
152+ // or specify a specific bundle image.
153+ // Required.
154+ // +required
155+ Bundle string `json:"bundle"`
156+
157+ // Pipeline name to fetch from the bundle, or from build-pipeline-config CM.
158+ // Required.
159+ // +required
160+ Name string `json:"name"`
161+ }
162+
163+ type PipelineRefGitSpec struct {
164+ // Path to the pipeline definition file within the repository.
165+ // Example: pipeline/push.yaml
166+ // Required.
167+ // +required
168+ PathInRepo string `json:"pathInRepo"`
169+
170+ // Git revision (branch, tag, or commit) to use.
171+ // Example: main
172+ // Required.
173+ // +required
174+ Revision string `json:"revision"`
175+
176+ // Git repository URL containing the pipeline definition.
177+ // Example: https://github.com/custom-pipelines/pipelines.git
178+ // Required.
179+ // +required
180+ Url string `json:"url"`
181+ }
182+
183+ type ComponentVersion struct {
184+ // Used only when sending a PR with build pipeline configuration was requested via 'spec.actions.create-pipeline-configuration-pr'.
185+ // Pipeline used for the version; when omitted, the default pipeline will be used from 'spec.default-build-pipeline'.
186+ // Optional.
187+ BuildPipeline ComponentBuildPipeline `json:"build-pipeline,omitempty"`
188+
189+ // Context directory for the version.
190+ // Used only when sending a PR with build pipeline configuration was requested via 'spec.actions.create-pipeline-configuration-pr'.
191+ // Default: "" (empty string, root of repository).
192+ // Optional.
193+ Context string `json:"context,omitempty"`
194+
195+ // Dockerfile path for the version.
196+ // Used only when sending a PR with build pipeline configuration was requested via 'spec.actions.create-pipeline-configuration-pr'.
197+ // Default: "Dockerfile".
198+ // Optional.
199+ DockerfileURI string `json:"dockerfileUri,omitempty"`
200+
201+ // User defined name for the version.
202+ // After sanitization (lower case, removing spaces, etc) all version names must be unique.
203+ // Required.
204+ // +required
205+ Name string `json:"name"`
206+
207+ // Git branch to use for the version.
208+ // Required.
209+ // +required
210+ Revision string `json:"revision"`
211+
212+ // When 'true' it will disable builds for a revision in the version.
213+ // Default: false.
214+ // Optional.
215+ SkipBuilds bool `json:"skip-builds,omitempty"`
69216}
70217
71218// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
@@ -77,27 +224,30 @@ type ComponentSpec struct {
77224 // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
78225 // +kubebuilder:validation:MaxLength=63
79226 // ComponentName is name of the component to be added to the Application. The name must adhere to DNS-1123 validation.
80- // Required.
81- // +required
82- ComponentName string `json:"componentName"`
227+ // Optional.
228+ // +optional
229+ // !!! Will be removed when we remove old model
230+ ComponentName string `json:"componentName,omitempty"`
83231
84232 // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
85233 // Application is the name of the application resource that the component belongs to.
86- // Required.
87- // +required
88- Application string `json:"application"`
234+ // Optional.
235+ // +optional
236+ // !!! Will be removed when we remove old model
237+ Application string `json:"application,omitempty"`
89238
90239 // Secret describes the name of a Kubernetes secret containing either:
91240 // 1. A Personal Access Token to access the Component's git repostiory (if using a Git-source component) or
92241 // 2. An Image Pull Secret to access the Component's container image (if using an Image-source component).
93242 // Optional.
94243 // +optional
244+ // !!! Will be removed when we remove old model
95245 Secret string `json:"secret,omitempty"`
96246
97247 // Source describes the Component source.
98- // Optional .
99- // +optional
100- Source ComponentSource `json:"source,omitempty "`
248+ // Required .
249+ // +required
250+ Source ComponentSource `json:"source"`
101251
102252 // Compute Resources required by this component.
103253 // Optional.
@@ -107,38 +257,65 @@ type ComponentSpec struct {
107257 // The number of replicas to deploy the component with.
108258 // Optional.
109259 // +optional
260+ // !!! Will be removed when we remove old model
110261 Replicas * int `json:"replicas,omitempty"`
111262
112263 // The port to expose the component over.
113264 // Optional.
114265 // +optional
266+ // !!! Will be removed when we remove old model
115267 TargetPort int `json:"targetPort,omitempty"`
116268
117269 // The route to expose the component with.
118270 // Optional.
119271 // +optional
272+ // !!! Will be removed when we remove old model
120273 Route string `json:"route,omitempty"`
121274
122275 // An array of environment variables to add to the component (ValueFrom not currently supported)
123276 // Optional
124277 // +optional
125278 Env []corev1.EnvVar `json:"env,omitempty"`
126279
127- // The container image to build or create the component from
128- // Example: quay.io/someorg/somerepository:latest.
280+ // The container image repository to use for this component (without tag).
281+ // Either will be set by Image Repository, or explicitly specified with custom repo.
282+ // All versions of this component will use this single image repository.
283+ // Example: quay.io/org/tenant/component
129284 // Optional.
130285 // +optional
131286 ContainerImage string `json:"containerImage,omitempty"`
132287
133288 // Whether or not to bypass the generation of GitOps resources for the Component. Defaults to false.
134289 // Optional.
135290 // +optional
291+ // !!! Will be removed when we remove old model
136292 SkipGitOpsResourceGeneration bool `json:"skipGitOpsResourceGeneration,omitempty"`
137293
138294 // The list of components to be nudged by this components build upon a successful result.
139295 // Optional.
140296 // +optional
297+ // !!! Will be removed when we remove old model
141298 BuildNudgesRef []string `json:"build-nudges-ref,omitempty"`
299+
300+ // Specific actions that will be processed by the controller and then removed from 'spec.actions'.
301+ // Used for triggering builds or creating pipeline configuration PRs.
302+ // Optional.
303+ // +optional
304+ Actions ComponentActions `json:"actions,omitempty"`
305+
306+ // When 'true', during offboarding a cleaning PR won't be created.
307+ // Default: false.
308+ // Optional.
309+ // +optional
310+ SkipOffboardingPr bool `json:"skip-offboarding-pr,omitempty"`
311+
312+ // Used only when sending a PR with build pipeline configuration was requested via 'spec.actions.create-pipeline-configuration-pr'.
313+ // Pipeline used for all versions, unless explicitly specified for a specific version.
314+ // When omitted it has to be specified in all versions.
315+ // Optional.
316+ // +optional
317+ DefaultBuildPipeline ComponentBuildPipeline `json:"default-build-pipeline,omitempty"`
318+
142319}
143320
144321// ComponentStatus defines the observed state of Component
@@ -150,30 +327,48 @@ type ComponentStatus struct {
150327 Conditions []metav1.Condition `json:"conditions,omitempty"`
151328
152329 // Webhook URL generated by Builds
330+ // !!! Will be removed when we remove old model
153331 Webhook string `json:"webhook,omitempty"`
154332
155333 // ContainerImage stores the associated built container image for the component
156334 ContainerImage string `json:"containerImage,omitempty"`
157335
158336 // The devfile model for the Component CR
337+ // !!! Will be removed when we remove old model
159338 Devfile string `json:"devfile,omitempty"`
160339
161340 // GitOps specific status for the Component CR
341+ // !!! Will be removed when we remove old model
162342 GitOps GitOpsStatus `json:"gitops,omitempty"`
163343
164344 // The last built commit id (SHA-1 checksum) from the latest component build.
165345 // Example: 41fbdb124775323f58fd5ce93c70bb7d79c20650.
346+ // !!! Will be removed when we remove old model SHOULD this be in version specific section??
166347 LastBuiltCommit string `json:"lastBuiltCommit,omitempty"`
167348
168349 // The last digest image component promoted with.
169350 // Example: quay.io/someorg/somerepository@sha256:5ca85b7f7b9da18a9c4101e81ee1d9bac35ac2b0b0221908ff7389204660a262.
351+ // !!! Will be removed when we remove old model SHOULD this be in version specific section??
170352 LastPromotedImage string `json:"lastPromotedImage,omitempty"`
171353
172354 // The list of names of Components whose builds nudge this resource (their spec.build-nudges-ref[] references this component)
355+ // !!! Will be removed when we remove old model
173356 BuildNudgedBy []string `json:"build-nudged-by,omitempty"`
357+
358+ // General error message, not specific to any version (version-specific errors are in versions[].message).
359+ // Example: "Spec.ContainerImage is not set" or "GitHub App is not installed".
360+ Message string `json:"message,omitempty`
361+
362+ // Name of Repository CR for the component.
363+ PacRepository string `json:"pac-repository,omitempty`
364+
365+ // All versions which were processed by onboarding.
366+ // When version is removed from the spec, offboarding will remove it from the status.
367+ Versions []ComponentVersionStatus `json:"versions,omitempty"`
174368}
175369
176370// GitOpsStatus contains GitOps repository-specific status for the component
371+ // !!! Will be removed when we remove old model
177372type GitOpsStatus struct {
178373 // RepositoryURL is the gitops repository URL for the component
179374 RepositoryURL string `json:"repositoryURL,omitempty"`
@@ -191,6 +386,34 @@ type GitOpsStatus struct {
191386 CommitID string `json:"commitID,omitempty"`
192387}
193388
389+ type ComponentVersionStatus struct {
390+ // Link with onboarding PR if requested by 'spec.actions.create-pipeline-configuration-pr'.
391+ // Only present if onboarding was successful.
392+ // Example: https://github.com/user/repo/pull/1
393+ ConfigurationMergeURL string `json:"configuration-merge-url,omitempty"`
394+
395+ // Version specific error message.
396+ // Example: "pipeline for this version doesn't exist"
397+ Message string `json:"message,omitempty"`
398+
399+ // Name for the version.
400+ Name string `json:"name,omitempty"`
401+
402+ // Onboarding status will be either 'succeeded' or 'failed' ('disabled' won't be there because we will just remove specific version section).
403+ OnboardingStatus string `json:"onboarding-status,omitempty"`
404+
405+ // Timestamp for when onboarding happened.
406+ // Only present if onboarding was successful.
407+ // Example: "29 May 2024 15:11:16 UTC"
408+ OnboardingTime string `json:"onboarding-time,omitempty"`
409+
410+ // Git revision (branch) for the version.
411+ Revision string `json:"revision,omitempty"`
412+
413+ // Identifies that builds for the revision in the version are disabled.
414+ SkipBuilds bool `json:"skip-builds,omitempty"`
415+ }
416+
194417//+kubebuilder:object:root=true
195418//+kubebuilder:subresource:status
196419
0 commit comments