-
Notifications
You must be signed in to change notification settings - Fork 614
MCO-2296: Promote OSImageStreams to v1 #2854
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
Open
pablintino
wants to merge
1
commit into
openshift:master
Choose a base branch
from
pablintino:osimagestream-v1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
662 changes: 662 additions & 0 deletions
662
...ineconfiguration/v1/tests/osimagestreams.machineconfiguration.openshift.io/OSStreams.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // +genclient | ||
| // +genclient:nonNamespaced | ||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
||
| // OSImageStream describes a set of streams and associated images available | ||
| // for the MachineConfigPools to be used as base OS images. | ||
| // | ||
| // The resource is a singleton named "cluster". | ||
| // | ||
| // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). | ||
| // +openshift:compatibility-gen:level=1 | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:resource:path=osimagestreams,scope=Cluster | ||
| // +kubebuilder:subresource:status | ||
| // +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2555 | ||
| // +openshift:file-pattern=cvoRunLevel=0000_80,operatorName=machine-config,operatorOrdering=01 | ||
| // +openshift:enable:FeatureGate=OSStreams | ||
| // +kubebuilder:metadata:labels=openshift.io/operator-managed= | ||
| // +kubebuilder:validation:XValidation:rule="self.metadata.name == 'cluster'",message="osimagestream is a singleton, .metadata.name must be 'cluster'" | ||
| // +kubebuilder:validation:XValidation:rule="self.spec == oldSelf.spec || !has(self.status) || self.spec.defaultStream in self.status.availableStreams.map(s, s.name)",message="spec.defaultStream must reference an existing stream name from status.availableStreams" | ||
| type OSImageStream struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
|
|
||
| // metadata is the standard object's metadata. | ||
| // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata | ||
| // +optional | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| // spec contains the desired OSImageStream config configuration. | ||
| // +required | ||
| Spec OSImageStreamSpec `json:"spec,omitzero,omitempty"` | ||
|
|
||
| // status describes the last observed state of this OSImageStream. | ||
| // Populated by the MachineConfigOperator after reading release metadata. | ||
| // When not present, the controller has not yet reconciled this resource. | ||
| // +optional | ||
| Status OSImageStreamStatus `json:"status,omitempty,omitzero"` | ||
| } | ||
|
|
||
| // OSImageStreamStatus describes the current state of a OSImageStream | ||
| // +kubebuilder:validation:XValidation:rule="self.defaultStream in self.availableStreams.map(s, s.name)",message="defaultStream must reference a stream name from availableStreams" | ||
| type OSImageStreamStatus struct { | ||
|
|
||
| // availableStreams is a list of the available OS Image Streams that can be | ||
| // used as the base image for MachineConfigPools. | ||
| // availableStreams is required, must have at least one item, must not exceed | ||
| // 100 items, and must have unique entries keyed on the name field. | ||
| // | ||
| // +required | ||
| // +kubebuilder:validation:MinItems=1 | ||
| // +kubebuilder:validation:MaxItems=100 | ||
| // +listType=map | ||
| // +listMapKey=name | ||
| AvailableStreams []OSImageStreamSet `json:"availableStreams,omitempty"` | ||
|
|
||
| // defaultStream is the name of the stream that should be used as the default | ||
| // when no specific stream is requested by a MachineConfigPool. | ||
| // | ||
| // It must be a valid RFC 1123 subdomain between 1 and 253 characters in length, | ||
| // consisting of lowercase alphanumeric characters, hyphens ('-'), and periods ('.'), | ||
| // and must reference the name of one of the streams in availableStreams. | ||
| // | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=253 | ||
| // +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character." | ||
| DefaultStream string `json:"defaultStream,omitempty"` | ||
| } | ||
|
|
||
| // OSImageStreamSpec defines the desired state of a OSImageStream. | ||
| type OSImageStreamSpec struct { | ||
| // defaultStream is the desired name of the stream that should be used as the | ||
| // default when no specific stream is requested by a MachineConfigPool. | ||
| // | ||
| // This field is set by the installer during installation. Users may need to | ||
| // update it if the currently selected stream is no longer available, for | ||
| // example when the stream has reached its End of Life. | ||
| // The MachineConfigOperator uses this value to determine which stream from | ||
| // status.availableStreams to apply as the default for MachineConfigPools | ||
| // that do not specify a stream override. | ||
| // | ||
| // When status.availableStreams has been populated by the operator, updating | ||
| // this field requires that the new value references the name of one of the | ||
| // streams in status.availableStreams. Status-only updates by the operator | ||
| // are not subject to this constraint, allowing the operator to update | ||
| // availableStreams independently of this field. | ||
| // During initial creation, before the operator has populated status, any | ||
| // valid value is accepted. | ||
| // | ||
| // For upgrade scenarios where the source OCP version doesn't have this CRD | ||
| // the MCO creates and populates the OSImageStream cluster singleton setting | ||
| // this field with the proper value based on the source OCP version. | ||
| // | ||
| // It must be a valid RFC 1123 subdomain between 1 and 253 characters in length, | ||
| // consisting of lowercase alphanumeric characters, hyphens ('-'), and periods ('.'). | ||
| // | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=253 | ||
| // +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character." | ||
| DefaultStream string `json:"defaultStream,omitempty"` | ||
| } | ||
|
|
||
| type OSImageStreamSet struct { | ||
| // name is the required identifier of the stream. | ||
| // | ||
| // name is determined by the operator based on the OCI label of the | ||
| // discovered OS or Extension Image. | ||
| // | ||
| // Must be a valid RFC 1123 subdomain between 1 and 253 characters in length, | ||
| // consisting of lowercase alphanumeric characters, hyphens ('-'), and periods ('.'). | ||
| // | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=253 | ||
| // +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character." | ||
| Name string `json:"name,omitempty"` | ||
|
|
||
| // osImage is a required OS Image referenced by digest. | ||
| // | ||
| // osImage contains the immutable, fundamental operating system components, including the kernel | ||
| // and base utilities, that define the core environment for the node's host operating system. | ||
| // | ||
| // The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>, | ||
| // where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9. | ||
| // The length of the whole spec must be between 1 to 447 characters. | ||
| // +required | ||
| OSImage ImageDigestFormat `json:"osImage,omitempty"` | ||
|
|
||
| // osExtensionsImage is a required OS Extensions Image referenced by digest. | ||
| // | ||
| // osExtensionsImage bundles the extra repositories used to enable extensions, augmenting | ||
| // the base operating system without modifying the underlying immutable osImage. | ||
| // | ||
| // The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>, | ||
| // where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9. | ||
| // The length of the whole spec must be between 1 to 447 characters. | ||
| // +required | ||
| OSExtensionsImage ImageDigestFormat `json:"osExtensionsImage,omitempty"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
||
| // OSImageStreamList is a list of OSImageStream resources | ||
| // | ||
| // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). | ||
| // +openshift:compatibility-gen:level=1 | ||
| type OSImageStreamList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
|
|
||
| // metadata is the standard list's metadata. | ||
| // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata | ||
| metav1.ListMeta `json:"metadata"` | ||
|
|
||
| Items []OSImageStream `json:"items"` | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the omission behavior for
metadata.Line 32marksmetadataas optional, but the comment does not say what happens when callers omit it. For a new v1 API, that omission behavior should be part of the field docs.As per coding guidelines, "Documentation for
+optionalfields must explain the behavior when the field is omitted".🤖 Prompt for AI Agents