-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #596 Based on ClusterExtension Signed-off-by: Todd Short <tshort@redhat.com>
- Loading branch information
Showing
11 changed files
with
625 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,133 @@ | ||
/* | ||
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 v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type ExtensionManagedState string | ||
|
||
const ( | ||
// Pause resolution of this Extension | ||
ManagedStateActive ExtensionManagedState = "Active" | ||
// Peform resolution of this Extension | ||
ManagedStatePaused ExtensionManagedState = "Paused" | ||
) | ||
|
||
type ExtensionSourcePackage struct { | ||
//+kubebuilder:validation:MaxLength:=48 | ||
//+kubebuilder:validation:Pattern:=^[a-z0-9]+(-[a-z0-9]+)*$ | ||
Name string `json:"name"` | ||
|
||
//+kubebuilder:validation:MaxLength:=64 | ||
//+kubebuilder:validation:Pattern=`^(\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|[x|X|\*])(\.(0|[1-9]\d*|x|X|\*]))?(\.(0|[1-9]\d*|x|X|\*))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)((?:\s+|,\s*|\s*\|\|\s*)(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|x|X|\*])(\.(0|[1-9]\d*|x|X|\*))?(\.(0|[1-9]\d*|x|X|\*]))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)*$` | ||
//+kubebuilder:Optional | ||
// Version is an optional semver constraint on the package version. If not specified, the latest version available of the package will be installed. | ||
// If specified, the specific version of the package will be installed so long as it is available in any of the content sources available. | ||
// Examples: 1.2.3, 1.0.0-alpha, 1.0.0-rc.1 | ||
// | ||
// For more information on semver, please see https://semver.org/ | ||
Version string `json:"version,omitempty"` | ||
|
||
//+kubebuilder:validation:MaxLength:=48 | ||
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$ | ||
// Channel constraint definition | ||
Channel string `json:"channel,omitempty"` | ||
} | ||
|
||
// TODO: Implement ExtensionSourceDirect containing a URL or other reference mechanism | ||
|
||
type ExtensionSource struct { | ||
// A source package defined by a name, version and/or channel | ||
Package *ExtensionSourcePackage `json:"package,omitempty"` | ||
|
||
// A direct package defined by a URL | ||
// TODO: Direct *ExtensionSourceDirect `json:"direct,omitempty"` | ||
} | ||
|
||
// ExtensionSpec defines the desired state of Extension | ||
type ExtensionSpec struct { | ||
//+kubebuilder:validation:Enum:=Active;Paused | ||
//+kubebuilder:default:=Active | ||
//+kubebuilder:Optional | ||
// | ||
// Pause reconciliation on this Extension | ||
Managed ExtensionManagedState `json:"managed,omitempty"` | ||
|
||
//+kubebuilder:validation:MaxLength:=64 | ||
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$ | ||
// | ||
// ServiceAccount name used to install this extension | ||
ServiceAccountName string `json:"serviceAccountName"` | ||
|
||
//+kubebuilder:validation:MaxLength:=64 | ||
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$ | ||
//+kubebuilder:Optional | ||
// | ||
// Location of installation TBD?? | ||
DefaultNamespace string `json:"defaultNamespace,omitempty"` | ||
|
||
// Source of Extension to be installed | ||
Source ExtensionSource `json:"source"` | ||
|
||
//+kubebuilder:validation:Enum:=Enforce;Ignore | ||
//+kubebuilder:default:=Enforce | ||
//+kubebuilder:Optional | ||
// | ||
// Defines the policy for how to handle upgrade constraints | ||
UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"` | ||
} | ||
|
||
// ExtensionStatus defines the observed state of Extension | ||
type ExtensionStatus struct { | ||
// +optional | ||
InstalledBundleResource string `json:"installedBundleResource,omitempty"` | ||
// +optional | ||
ResolvedBundleResource string `json:"resolvedBundleResource,omitempty"` | ||
|
||
// +patchMergeKey=type | ||
// +patchStrategy=merge | ||
// +listType=map | ||
// +listMapKey=type | ||
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// Extension is the Schema for the extensions API | ||
type Extension struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ExtensionSpec `json:"spec,omitempty"` | ||
Status ExtensionStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// ExtensionList contains a list of Extension | ||
type ExtensionList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Extension `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Extension{}, &ExtensionList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.