-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add NexusCleanupPolicy Custom Resource (#25)
Change-Id: I70146a91ce45f722b78a0dc6fdd48a745d4b6bbe
- Loading branch information
Showing
30 changed files
with
2,069 additions
and
3 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,103 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/epam/edp-nexus-operator/api/common" | ||
) | ||
|
||
// NexusCleanupPolicySpec defines the desired state of NexusCleanupPolicy. | ||
type NexusCleanupPolicySpec struct { | ||
// Name is a unique name for the cleanup policy. | ||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" | ||
// +kubebuilder:validation:MaxLength=512 | ||
// +required | ||
// +kubebuilder:example="go-cleanup-policy" | ||
Name string `json:"name"` | ||
|
||
// Format that this cleanup policy can be applied to. | ||
// +required | ||
// +kubebuilder:example="go" | ||
// +kubebuilder:validation:Enum=apt;bower;cocoapods;conan;conda;docker;gitlfs;go;helm;maven2;npm;nuget;p2;pypi;r;raw;rubygems;yum | ||
Format string `json:"format"` | ||
|
||
// Description of the cleanup policy. | ||
// +optional | ||
// +kubebuilder:example="Cleanup policy for go format" | ||
Description string `json:"description,omitempty"` | ||
|
||
// Criteria for the cleanup policy. | ||
// +required | ||
Criteria Criteria `json:"criteria"` | ||
|
||
// NexusRef is a reference to Nexus custom resource. | ||
// +required | ||
NexusRef common.NexusRef `json:"nexusRef"` | ||
} | ||
|
||
type Criteria struct { | ||
// ReleaseType removes components that are of the following release type. | ||
// +optional | ||
// +kubebuilder:example="RELEASES" | ||
// +kubebuilder:validation:Enum=RELEASES;PRERELEASES;"" | ||
ReleaseType string `json:"releaseType,omitempty"` | ||
|
||
// LastBlobUpdated removes components published over “x” days ago. | ||
// +optional | ||
// +kubebuilder:example="30" | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Maximum=24855 | ||
LastBlobUpdated int `json:"lastBlobUpdated,omitempty"` | ||
|
||
// LastDownloaded removes components downloaded over “x” days. | ||
// +optional | ||
// +kubebuilder:example="30" | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Maximum=24855 | ||
LastDownloaded int `json:"lastDownloaded,omitempty"` | ||
|
||
// AssetRegex removes components that match the given regex. | ||
// +optional | ||
// +kubebuilder:example=".*" | ||
AssetRegex string `json:"assetRegex,omitempty"` | ||
} | ||
|
||
// NexusCleanupPolicyStatus defines the observed state of NexusCleanupPolicy. | ||
type NexusCleanupPolicyStatus struct { | ||
// Value is a status of the cleanup policy. | ||
// +optional | ||
Value string `json:"value,omitempty"` | ||
|
||
// Error is an error message if something went wrong. | ||
// +optional | ||
Error string `json:"error,omitempty"` | ||
} | ||
|
||
func (in *NexusCleanupPolicy) GetNexusRef() common.NexusRef { | ||
return in.Spec.NexusRef | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// NexusCleanupPolicy is the Schema for the cleanuppolicies API. | ||
type NexusCleanupPolicy struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NexusCleanupPolicySpec `json:"spec,omitempty"` | ||
Status NexusCleanupPolicyStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// NexusCleanupPolicyList contains a list of NexusCleanupPolicy. | ||
type NexusCleanupPolicyList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NexusCleanupPolicy `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NexusCleanupPolicy{}, &NexusCleanupPolicyList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
137 changes: 137 additions & 0 deletions
137
config/crd/bases/edp.epam.com_nexuscleanuppolicies.yaml
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,137 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.13.0 | ||
name: nexuscleanuppolicies.edp.epam.com | ||
spec: | ||
group: edp.epam.com | ||
names: | ||
kind: NexusCleanupPolicy | ||
listKind: NexusCleanupPolicyList | ||
plural: nexuscleanuppolicies | ||
singular: nexuscleanuppolicy | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: NexusCleanupPolicy is the Schema for the cleanuppolicies 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: NexusCleanupPolicySpec defines the desired state of NexusCleanupPolicy | ||
properties: | ||
criteria: | ||
description: Criteria for the cleanup policy. | ||
properties: | ||
assetRegex: | ||
description: AssetRegex removes components that match the given | ||
regex. | ||
example: .* | ||
type: string | ||
lastBlobUpdated: | ||
description: LastBlobUpdated removes components published over | ||
“x” days ago. | ||
example: "30" | ||
maximum: 24855 | ||
minimum: 1 | ||
type: integer | ||
lastDownloaded: | ||
description: LastDownloaded removes components downloaded over | ||
“x” days. | ||
example: "30" | ||
maximum: 24855 | ||
minimum: 1 | ||
type: integer | ||
releaseType: | ||
description: ReleaseType removes components that are of the following | ||
release type. | ||
enum: | ||
- RELEASES | ||
- PRERELEASES | ||
- "" | ||
example: RELEASES | ||
type: string | ||
type: object | ||
description: | ||
description: Description of the cleanup policy. | ||
example: Cleanup policy for go format | ||
type: string | ||
format: | ||
description: Format that this cleanup policy can be applied to. | ||
enum: | ||
- apt | ||
- bower | ||
- cocoapods | ||
- conan | ||
- conda | ||
- docker | ||
- gitlfs | ||
- go | ||
- helm | ||
- maven2 | ||
- npm | ||
- nuget | ||
- p2 | ||
- pypi | ||
- r | ||
- raw | ||
- rubygems | ||
- yum | ||
example: go | ||
type: string | ||
name: | ||
description: Name is a unique name for the cleanup policy. | ||
example: go-cleanup-policy | ||
maxLength: 512 | ||
type: string | ||
x-kubernetes-validations: | ||
- message: Value is immutable | ||
rule: self == oldSelf | ||
nexusRef: | ||
description: NexusRef is a reference to Nexus custom resource. | ||
properties: | ||
kind: | ||
default: Nexus | ||
description: Kind specifies the kind of the Nexus resource. | ||
type: string | ||
name: | ||
description: Name specifies the name of the Nexus resource. | ||
type: string | ||
required: | ||
- name | ||
type: object | ||
required: | ||
- criteria | ||
- format | ||
- name | ||
- nexusRef | ||
type: object | ||
status: | ||
description: NexusCleanupPolicyStatus defines the observed state of NexusCleanupPolicy. | ||
properties: | ||
error: | ||
description: Error is an error message if something went wrong. | ||
type: string | ||
value: | ||
description: Value is a status of the cleanup policy. | ||
type: string | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
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.