-
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.
[EPMDEDP-7391]: feat: implement SonarGroup custom resource
Change-Id: I375665da0dcd8d3c01b7b0aa35d75f8db179c854
- Loading branch information
1 parent
0b8e55c
commit 1a2834c
Showing
27 changed files
with
1,116 additions
and
88 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,10 @@ | ||
apiVersion: v2.edp.epam.com/v1alpha1 | ||
kind: SonarGroup | ||
metadata: | ||
name: test-sonar-group | ||
spec: | ||
sonarOwner: sonar | ||
name: testgroup1 | ||
description: "group description" | ||
|
||
|
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,45 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: sonargroups.v2.edp.epam.com | ||
spec: | ||
group: v2.edp.epam.com | ||
names: | ||
kind: SonarGroup | ||
listKind: SonarGroupList | ||
plural: sonargroups | ||
singular: sonargroup | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
served: true | ||
storage: true | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
properties: | ||
apiVersion: | ||
type: string | ||
kind: | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
properties: | ||
sonarOwner: | ||
type: string | ||
description: 'name of root sonar custom resource' | ||
name: | ||
type: string | ||
description: 'group name' | ||
description: | ||
type: string | ||
required: | ||
- sonarOwner | ||
- name | ||
type: object | ||
status: | ||
type: object | ||
additionalProperties: 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
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,46 @@ | ||
package v1alpha1 | ||
|
||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
type SonarGroup struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
Spec SonarGroupSpec `json:"spec"` | ||
Status SonarGroupStatus `json:"status"` | ||
} | ||
|
||
type SonarGroupSpec struct { | ||
SonarOwner string `json:"sonarOwner"` | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
} | ||
|
||
type SonarGroupStatus struct { | ||
Value string `json:"value"` | ||
FailureCount int64 `json:"failureCount"` | ||
ID string `json:"id"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
type SonarGroupList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []SonarGroup `json:"items"` | ||
} | ||
|
||
func (in SonarGroup) GetFailureCount() int64 { | ||
return in.Status.FailureCount | ||
} | ||
|
||
func (in *SonarGroup) SetFailureCount(count int64) { | ||
in.Status.FailureCount = count | ||
} | ||
|
||
func (in SonarGroup) GetStatus() string { | ||
return in.Status.Value | ||
} | ||
|
||
func (in *SonarGroup) SetStatus(value string) { | ||
in.Status.Value = value | ||
} |
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
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,14 @@ | ||
package sonar | ||
|
||
import "github.com/pkg/errors" | ||
|
||
type ErrNotFound string | ||
|
||
func (e ErrNotFound) Error() string { | ||
return string(e) | ||
} | ||
|
||
func IsErrNotFound(err error) bool { | ||
_, ok := errors.Cause(err).(ErrNotFound) | ||
return ok | ||
} |
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,9 @@ | ||
package sonar | ||
|
||
import "testing" | ||
|
||
func TestIsErrNotFound(t *testing.T) { | ||
if IsErrNotFound(nil) { | ||
t.Fatal("wrong error") | ||
} | ||
} |
Oops, something went wrong.