-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add SonarQualityGate custom resource (#3)
Jira: EPMDEDP-12128 Change-Id: I2278646af5f8f5451460174b27ceb8dc4919c858
- Loading branch information
Showing
42 changed files
with
2,232 additions
and
365 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,93 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/epam/edp-sonar-operator/api/common" | ||
) | ||
|
||
// SonarQualityGateSpec defines the desired state of SonarQualityGate | ||
type SonarQualityGateSpec struct { | ||
// Name is a name of quality gate. | ||
// Name should be unique across all quality gates. | ||
// Don't change this field after creation otherwise quality gate will be recreated. | ||
// +required | ||
// +kubebuilder:validation:MaxLength=100 | ||
// +kubebuilder:example="My Quality Gate" | ||
Name string `json:"name"` | ||
|
||
// Default is a flag to set quality gate as default. | ||
// Only one quality gate can be default. | ||
// If several quality gates have default flag, the random one will be chosen. | ||
// Default quality gate can't be deleted. You need to set another quality gate as default before. | ||
// +optional | ||
// +kubebuilder:example="true" | ||
Default bool `json:"default"` | ||
|
||
// Conditions is a list of conditions for quality gate. | ||
// Key is a metric name, value is a condition. | ||
// +optional | ||
// +nullable | ||
// +kubebuilder:example={new_code_smells: {error: "10", op: "LT"}} | ||
Conditions map[string]Condition `json:"conditions"` | ||
|
||
// SonarRef is a reference to Sonar custom resource. | ||
// +required | ||
SonarRef common.SonarRef `json:"sonarRef"` | ||
} | ||
|
||
// Condition defines the condition for quality gate. | ||
type Condition struct { | ||
// Error is condition error threshold. | ||
// +required | ||
// +kubebuilder:validation:MaxLength=64 | ||
// +kubebuilder:example="10" | ||
Error string `json:"error"` | ||
|
||
// Op is condition operator. | ||
// LT = is lower than | ||
// GT = is greater than | ||
// +optional | ||
// +kubebuilder:validation:Enum=LT;GT | ||
Op string `json:"op,omitempty"` | ||
} | ||
|
||
// SonarQualityGateStatus defines the observed state of SonarQualityGate | ||
type SonarQualityGateStatus struct { | ||
// Value is a status of the user. | ||
// +optional | ||
Value string `json:"value,omitempty"` | ||
|
||
// Error is an error message if something went wrong. | ||
// +optional | ||
Error string `json:"error,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// SonarQualityGate is the Schema for the sonarqualitygates API | ||
type SonarQualityGate struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec SonarQualityGateSpec `json:"spec,omitempty"` | ||
Status SonarQualityGateStatus `json:"status,omitempty"` | ||
} | ||
|
||
func (in *SonarQualityGate) GetSonarRef() common.SonarRef { | ||
return in.Spec.SonarRef | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// SonarQualityGateList contains a list of SonarQualityGate | ||
type SonarQualityGateList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []SonarQualityGate `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&SonarQualityGate{}, &SonarQualityGateList{}) | ||
} |
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,109 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.12.1 | ||
name: sonarqualitygates.edp.epam.com | ||
spec: | ||
group: edp.epam.com | ||
names: | ||
kind: SonarQualityGate | ||
listKind: SonarQualityGateList | ||
plural: sonarqualitygates | ||
singular: sonarqualitygate | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: SonarQualityGate is the Schema for the sonarqualitygates 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: SonarQualityGateSpec defines the desired state of SonarQualityGate | ||
properties: | ||
conditions: | ||
additionalProperties: | ||
description: Condition defines the condition for quality gate. | ||
properties: | ||
error: | ||
description: Error is condition error threshold. | ||
example: "10" | ||
maxLength: 64 | ||
type: string | ||
op: | ||
description: Op is condition operator. LT = is lower than GT | ||
= is greater than | ||
enum: | ||
- LT | ||
- GT | ||
type: string | ||
required: | ||
- error | ||
type: object | ||
description: Conditions is a list of conditions for quality gate. | ||
Key is a metric name, value is a condition. | ||
example: | ||
new_code_smells: | ||
error: "10" | ||
op: LT | ||
nullable: true | ||
type: object | ||
default: | ||
description: Default is a flag to set quality gate as default. Only | ||
one quality gate can be default. If several quality gates have default | ||
flag, the random one will be chosen. Default quality gate can't | ||
be deleted. You need to set another quality gate as default before. | ||
example: "true" | ||
type: boolean | ||
name: | ||
description: Name is a name of quality gate. Name should be unique | ||
across all quality gates. Don't change this field after creation | ||
otherwise quality gate will be recreated. | ||
example: My Quality Gate | ||
maxLength: 100 | ||
type: string | ||
sonarRef: | ||
description: SonarRef is a reference to Sonar custom resource. | ||
properties: | ||
kind: | ||
default: Sonar | ||
description: Kind specifies the kind of the Sonar resource. | ||
type: string | ||
name: | ||
description: Name specifies the name of the Sonar resource. | ||
type: string | ||
required: | ||
- name | ||
type: object | ||
required: | ||
- name | ||
- sonarRef | ||
type: object | ||
status: | ||
description: SonarQualityGateStatus defines the observed state of SonarQualityGate | ||
properties: | ||
error: | ||
description: Error is an error message if something went wrong. | ||
type: string | ||
value: | ||
description: Value is a status of the user. | ||
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: sonarqualitygates.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: sonarqualitygates.edp.epam.com | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhook: | ||
clientConfig: | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert | ||
conversionReviewVersions: | ||
- v1 |
Oops, something went wrong.