Skip to content

CLOUDP-316083: Release Integrations independent CRD & controller #2399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,12 @@ resources:
kind: AtlasBackupCompliancePolicy
path: github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1
version: v1
- api:
crdVersion: v1
namespaced: true
domain: mongodb.com
group: atlas
kind: AtlasThirdPartyIntegration
path: github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1
version: v1
version: "3"
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
akov2 "github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/v1/status"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/status"
)

func init() {
Expand All @@ -31,7 +30,7 @@ func init() {
// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:subresource:status
// +groupName:=atlas.nextapi.mongodb.com
// +groupName:=atlas.mongodb.com
// +kubebuilder:resource:categories=atlas,shortName=atpi
type AtlasThirdPartyIntegration struct {
metav1.TypeMeta `json:",inline"`
Expand Down Expand Up @@ -65,7 +64,7 @@ func (atpi *AtlasThirdPartyIntegration) GetConditions() []metav1.Condition {
// +kubebuilder:validation:XValidation:rule="!has(self.victorOps) || (self.type == 'VICTOR_OPS' && has(self.victorOps))",message="only VICTOR_OPS type may set victorOps fields"
// +kubebuilder:validation:XValidation:rule="!has(self.webhook) || (self.type == 'WEBHOOK' && has(self.webhook))",message="only WEBHOOK type may set webhook fields"
type AtlasThirdPartyIntegrationSpec struct {
akov2.ProjectDualReference `json:",inline"`
ProjectDualReference `json:",inline"`

// Type of the integration
// +kubebuilder:validation:Enum:=DATADOG;MICROSOFT_TEAMS;NEW_RELIC;OPS_GENIE;PAGER_DUTY;PROMETHEUS;SLACK;VICTOR_OPS;WEBHOOK
Expand Down Expand Up @@ -219,6 +218,6 @@ type AtlasThirdPartyIntegrationList struct {
Items []AtlasThirdPartyIntegration `json:"items"`
}

func (i *AtlasThirdPartyIntegration) ProjectDualRef() *akov2.ProjectDualReference {
func (i *AtlasThirdPartyIntegration) ProjectDualRef() *ProjectDualReference {
return &i.Spec.ProjectDualReference
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
package v1

import (
"fmt"
"testing"

gofuzz "github.com/google/gofuzz"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -26,6 +28,8 @@ import (
"github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/cel"
)

const fuzzIterations = 100

func TestIntegrationCELChecks(t *testing.T) {
for _, tc := range []struct {
title string
Expand Down Expand Up @@ -204,7 +208,7 @@ func TestIntegrationCELChecks(t *testing.T) {
unstructuredObject, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&tc.obj)
require.NoError(t, err)

crdPath := "../../next-crds/atlas.nextapi.mongodb.com_atlasthirdpartyintegrations.yaml"
crdPath := "../../config/crd/bases/atlas.mongodb.com_atlasthirdpartyintegrations.yaml"
validator, err := cel.VersionValidatorFromFile(t, crdPath, "v1")
assert.NoError(t, err)
errs := validator(unstructuredObject, nil)
Expand All @@ -213,3 +217,15 @@ func TestIntegrationCELChecks(t *testing.T) {
})
}
}

func FuzzIntegrationCloning(f *testing.F) {
for i := uint(0); i < fuzzIterations; i++ {
f.Add(([]byte)(fmt.Sprintf("seed sample %x", i)), i)
}
f.Fuzz(func(t *testing.T, data []byte, index uint) {
integrationData := &AtlasThirdPartyIntegration{}
gofuzz.NewFromGoFuzz(data).Fuzz(integrationData)
copy := integrationData.DeepCopy()
assert.Equal(t, integrationData, copy, "failed copy for index=%d", index)
})
}
40 changes: 40 additions & 0 deletions api/v1/status/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading