-
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 NexusScript custom resource (#17)
Change-Id: I2df6c897ace09dbac3705544f97a77812eb25923
- Loading branch information
Showing
40 changed files
with
2,239 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
with-expecter: True | ||
inpackage: False | ||
dir: "{{.InterfaceDir}}/mocks" | ||
mockname: "Mock{{.InterfaceName}}" | ||
outpkg: "mocks" | ||
filename: "{{.InterfaceName | lower}}_mock.go" | ||
all: True | ||
packages: | ||
github.com/epam/edp-nexus-operator/pkg/client/nexus: | ||
config: | ||
recursive: True |
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
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,75 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/epam/edp-nexus-operator/api/common" | ||
) | ||
|
||
// NexusScriptSpec defines the desired state of NexusScript. | ||
type NexusScriptSpec struct { | ||
// Name is the id of the script. | ||
// Name should be unique across all scripts. | ||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" | ||
// +kubebuilder:validation:MaxLength=512 | ||
// +required | ||
// +kubebuilder:example="anonymous" | ||
Name string `json:"name"` | ||
|
||
// Content is the content of the script. | ||
// +required | ||
// +kubebuilder:example="security.setAnonymousAccess(Boolean.valueOf(args))" | ||
Content string `json:"content"` | ||
|
||
// Payload is the payload of the script. | ||
// +optional | ||
// +kubebuilder:example="true" | ||
Payload string `json:"payload,omitempty"` | ||
|
||
// NexusRef is a reference to Nexus custom resource. | ||
// +required | ||
NexusRef common.NexusRef `json:"nexusRef"` | ||
} | ||
|
||
// NexusScriptStatus defines the observed state of NexusScript. | ||
type NexusScriptStatus struct { | ||
// Value is a status of the script. | ||
// +optional | ||
Value string `json:"value,omitempty"` | ||
|
||
// Error is an error message if something went wrong. | ||
// +optional | ||
Error string `json:"error,omitempty"` | ||
|
||
// Executed defines if script was executed. | ||
Executed bool `json:"executed,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// NexusScript is the Schema for the nexusscripts API. | ||
type NexusScript struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NexusScriptSpec `json:"spec,omitempty"` | ||
Status NexusScriptStatus `json:"status,omitempty"` | ||
} | ||
|
||
func (in *NexusScript) GetNexusRef() common.NexusRef { | ||
return in.Spec.NexusRef | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// NexusScriptList contains a list of NexusScript. | ||
type NexusScriptList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NexusScript `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NexusScript{}, &NexusScriptList{}) | ||
} |
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
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.13.0 | ||
name: nexusscripts.edp.epam.com | ||
spec: | ||
group: edp.epam.com | ||
names: | ||
kind: NexusScript | ||
listKind: NexusScriptList | ||
plural: nexusscripts | ||
singular: nexusscript | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: NexusScript is the Schema for the nexusscripts 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: NexusScriptSpec defines the desired state of NexusScript. | ||
properties: | ||
content: | ||
description: Content is the content of the script. | ||
example: security.setAnonymousAccess(Boolean.valueOf(args)) | ||
type: string | ||
name: | ||
description: Name is the id of the script. Name should be unique across | ||
all scripts. | ||
example: anonymous | ||
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 | ||
payload: | ||
description: Payload is the payload of the script. | ||
example: "true" | ||
type: string | ||
required: | ||
- content | ||
- name | ||
- nexusRef | ||
type: object | ||
status: | ||
description: NexusScriptStatus defines the observed state of NexusScript. | ||
properties: | ||
error: | ||
description: Error is an error message if something went wrong. | ||
type: string | ||
executed: | ||
description: Executed defines if script was executed. | ||
type: boolean | ||
value: | ||
description: Value is a status of the script. | ||
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
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,7 @@ | ||
# The following patch adds a directive for certmanager to inject CA into the CRD | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) | ||
name: nexusscripts.edp.epam.com |
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,16 @@ | ||
# The following patch enables a conversion webhook for the CRD | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: nexusscripts.edp.epam.com | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhook: | ||
clientConfig: | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert | ||
conversionReviewVersions: | ||
- v1 |
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,31 @@ | ||
# permissions for end users to edit nexusscripts. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: clusterrole | ||
app.kubernetes.io/instance: nexusscript-editor-role | ||
app.kubernetes.io/component: rbac | ||
app.kubernetes.io/created-by: nexus-operator | ||
app.kubernetes.io/part-of: nexus-operator | ||
app.kubernetes.io/managed-by: kustomize | ||
name: nexusscript-editor-role | ||
rules: | ||
- apiGroups: | ||
- edp.epam.com | ||
resources: | ||
- nexusscripts | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- edp.epam.com | ||
resources: | ||
- nexusscripts/status | ||
verbs: | ||
- get |
Oops, something went wrong.