Skip to content

CLOUDP-297918: Move to New Atlas SDK #2304

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 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2f58b69
mass update sdk
roothorp Apr 17, 2025
67e4678
update cluster var names
roothorp Apr 17, 2025
c2c5786
more var name updates
roothorp Apr 25, 2025
ab87262
update other sdk versions
roothorp Apr 28, 2025
792a44d
cleanup delete calls
roothorp Apr 28, 2025
a22461c
fix alert config changes
roothorp Apr 28, 2025
14ccb8c
fix search index
roothorp Apr 28, 2025
be7ee6b
fix teams
roothorp Apr 28, 2025
e7e86c3
fix network container
roothorp Apr 28, 2025
c29a9c4
fix datafederation
roothorp Apr 28, 2025
e951128
update direct sdk client references
roothorp Apr 28, 2025
2f7b4c8
fix stream
roothorp Apr 28, 2025
b76be96
fix cloud provider integrations
roothorp Apr 28, 2025
8642cdc
fix private endpoint
roothorp Apr 28, 2025
916c14c
fix x509
roothorp Apr 28, 2025
807635e
fix e2e helper
roothorp Apr 28, 2025
3bd6a28
fix network peering
roothorp Apr 28, 2025
f7b668f
fix API error
roothorp Apr 28, 2025
1fe3197
clean up e2e tests
roothorp Apr 28, 2025
c7b4ae0
Add warnings for removed process args
roothorp May 21, 2025
51ad048
duplicate replication specs per num shards
roothorp Jun 5, 2025
2ef5edd
cleanup missed delete call
roothorp Jun 12, 2025
512f4b6
handle new diskSizeGB location
roothorp Jun 12, 2025
4063037
fix tests
roothorp Jun 12, 2025
8b4d799
remove old sdk from test helper
roothorp Jun 16, 2025
a8c26b3
update licenses
roothorp Jun 16, 2025
a0688a5
fix tools/clean
roothorp Jun 16, 2025
abaa785
appease linter
roothorp Jun 16, 2025
3a2d4e6
fix off by one
roothorp Jun 19, 2025
9ad2884
fix missed changes from merge
roothorp Jun 19, 2025
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
2 changes: 1 addition & 1 deletion .licenses-gomod.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
100644 b1190edabf8ad97f199b0eb0358514f45d8c9bb3 go.mod
100644 7637c1575b33e7df59f34cea7f0782a3ccbf603f go.mod
29 changes: 14 additions & 15 deletions api/v1/alert_configurations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strconv"
"strings"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"go.uber.org/zap"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
Expand Down Expand Up @@ -61,14 +61,14 @@ func (in *AlertConfiguration) ToAtlas() (*admin.GroupAlertsConfig, error) {
result.SetEnabled(in.Enabled)
result.SetEventTypeName(in.EventTypeName)

matchers := make([]map[string]interface{}, 0, len(in.Matchers))
matchers := make([]admin.StreamsMatcher, 0, len(in.Matchers))
for _, m := range in.Matchers {
matchers = append(
matchers,
map[string]interface{}{
"fieldName": m.FieldName,
"operator": m.Operator,
"value": m.Value,
admin.StreamsMatcher{
FieldName: m.FieldName,
Operator: m.Operator,
Value: m.Value,
},
)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func (in Threshold) Key() string {
return in.Operator + "|" + in.Units + "|" + in.Threshold
}

func (in *Threshold) IsEqual(threshold *admin.GreaterThanRawThreshold) bool {
func (in *Threshold) IsEqual(threshold *admin.StreamProcessorMetricThreshold) bool {
logger := zap.NewExample().Sugar()
if in == nil {
return threshold == nil
Expand All @@ -161,21 +161,20 @@ func (in *Threshold) IsEqual(threshold *admin.GreaterThanRawThreshold) bool {
return true
}

func (in *Threshold) ToAtlas() (*admin.GreaterThanRawThreshold, error) {
func (in *Threshold) ToAtlas() (*admin.StreamProcessorMetricThreshold, error) {
if in == nil {
return nil, nil
}

tr64, err := strconv.ParseInt(in.Threshold, 10, 64)
tr64, err := strconv.ParseFloat(in.Threshold, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse threshold value: %w. should be float", err)
}

tr := int(tr64)
result := &admin.GreaterThanRawThreshold{
result := &admin.StreamProcessorMetricThreshold{
Operator: &in.Operator,
Units: &in.Units,
Threshold: &tr,
Threshold: &tr64,
}

return result, nil
Expand Down Expand Up @@ -367,7 +366,7 @@ func (in MetricThreshold) Key() string {
in.Mode
}

func (in *MetricThreshold) IsEqual(threshold *admin.ServerlessMetricThreshold) bool {
func (in *MetricThreshold) IsEqual(threshold *admin.FlexClusterMetricThreshold) bool {
if in == nil {
return threshold == nil
}
Expand All @@ -388,7 +387,7 @@ func (in *MetricThreshold) IsEqual(threshold *admin.ServerlessMetricThreshold) b
in.Mode == threshold.GetMode()
}

func (in *MetricThreshold) ToAtlas() (*admin.ServerlessMetricThreshold, error) {
func (in *MetricThreshold) ToAtlas() (*admin.FlexClusterMetricThreshold, error) {
if in == nil {
return nil, nil
}
Expand All @@ -398,7 +397,7 @@ func (in *MetricThreshold) ToAtlas() (*admin.ServerlessMetricThreshold, error) {
return nil, fmt.Errorf("failed to parse threshold value: %w. should be float", err)
}

result := &admin.ServerlessMetricThreshold{
result := &admin.FlexClusterMetricThreshold{
MetricName: in.MetricName,
Operator: &in.Operator,
Threshold: &tr,
Expand Down
14 changes: 7 additions & 7 deletions api/v1/alert_configurations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
)
Expand All @@ -27,12 +27,12 @@ func TestServerlessMetricThreshold(t *testing.T) {
tests := []struct {
name string
akoData *MetricThreshold
atlasData *admin.ServerlessMetricThreshold
atlasData *admin.FlexClusterMetricThreshold
equal bool
}{
{
name: "Should be able to parse float Theshold",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand All @@ -50,7 +50,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should be able to parse int Theshold",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand All @@ -68,7 +68,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should be false if Theshold is not a number",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should be false if operator mismatched",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand All @@ -116,7 +116,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should fail if Threshold mismatched",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasbackupcompliancepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1
import (
"strings"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasbackupcompliancepolicy_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasdatabaseuser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"fmt"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1
import (
"errors"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"go.mongodb.org/atlas/mongodbatlas"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasfederatedauth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"errors"
"fmt"

"go.mongodb.org/atlas-sdk/v20241113001/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasfederatedauth_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/go-test/deep"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"go.mongodb.org/atlas-sdk/v20241113001/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasproject_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"go.mongodb.org/atlas-sdk/v20231115004/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"sigs.k8s.io/yaml"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasteam_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/networkpeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/provider"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/compat"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/privateendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/provider"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/status"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/project_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
)

type ProjectSettings struct {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/project_teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
)
Expand Down
6 changes: 3 additions & 3 deletions api/v1/status/alert_configurations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"
"strconv"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"go.uber.org/zap"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/compat"
Expand Down Expand Up @@ -160,7 +160,7 @@ type Threshold struct {
Threshold string `json:"threshold,omitempty"`
}

func ThresholdFromAtlas(threshold *admin.GreaterThanRawThreshold) *Threshold {
func ThresholdFromAtlas(threshold *admin.StreamProcessorMetricThreshold) *Threshold {
if threshold == nil {
return nil
}
Expand All @@ -185,7 +185,7 @@ type MetricThreshold struct {
Mode string `json:"mode,omitempty"`
}

func MetricThresholdFromAtlas(threshold *admin.ServerlessMetricThreshold) *MetricThreshold {
func MetricThresholdFromAtlas(threshold *admin.FlexClusterMetricThreshold) *MetricThreshold {
if threshold == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1/status/networkpeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package status

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/provider"
)
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ require (
github.com/sethvargo/go-password v0.3.1
github.com/stretchr/testify v1.10.0
go.mongodb.org/atlas v0.38.0
go.mongodb.org/atlas-sdk/v20231115004 v20231115004.1.0
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0
go.mongodb.org/atlas-sdk/v20241113001 v20241113001.0.0
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0
go.mongodb.org/mongo-driver v1.17.4
go.uber.org/zap v1.27.0
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/atlas v0.38.0 h1:zfwymq20GqivGwxPZfypfUDry+WwMGVui97z1d8V4bU=
go.mongodb.org/atlas v0.38.0/go.mod h1:DJYtM+vsEpPEMSkQzJnFHrT0sP7ev6cseZc/GGjJYG8=
go.mongodb.org/atlas-sdk/v20231115004 v20231115004.1.0 h1:vOvfk8bPedcphaTHIm6p8UB/ZPeVOqJZ7+MmTuI1eGs=
go.mongodb.org/atlas-sdk/v20231115004 v20231115004.1.0/go.mod h1:FzD5DLz+WPB+z3OGgNBjXMPQJjJ7Y+hKn4iupXZuoOc=
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0 h1:OuV1HfIpZUZa4+BKvtrvDlNqnilkCkdHspuZok6KAbM=
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0/go.mod h1:0707RpWIrNFZ6Msy/dwRDCzC5JVDon61JoOqcbfCujg=
go.mongodb.org/atlas-sdk/v20241113001 v20241113001.0.0 h1:G3UZcWwWziGUuaILWp/Gc+jLm1tfu7OUhUOpMWVZSWc=
go.mongodb.org/atlas-sdk/v20241113001 v20241113001.0.0/go.mod h1:fMiUyCacIAm+XwFkJ4j+rJtYLRsGU7hButtgGv+SBU4=
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0 h1:KX8PrYp3/PCSxG4NbGLcc3+EsNcfyhcvylGbe/oRlx8=
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0/go.mod h1:HHCmHxHPdJRr1bUXlvRIZbm7M4gRujjur1GnjE44YgA=
go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw=
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/atlas/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package atlas

import "go.mongodb.org/atlas-sdk/v20231115008/admin"
import "go.mongodb.org/atlas-sdk/v20250312002/admin"

func NewClient(domain, publicKey, privateKey string) (*admin.APIClient, error) {
return admin.NewClient(
Expand Down
36 changes: 7 additions & 29 deletions internal/controller/atlas/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import (
"strings"

"github.com/mongodb-forks/digest"
adminv20231115008 "go.mongodb.org/atlas-sdk/v20231115008/admin"
adminv20241113001 "go.mongodb.org/atlas-sdk/v20241113001/admin"
adminv20250312002 "go.mongodb.org/atlas-sdk/v20250312002/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"go.mongodb.org/atlas/mongodbatlas"
"go.uber.org/zap"

Expand All @@ -48,9 +46,7 @@ type Provider interface {
}

type ClientSet struct {
SdkClient20231115008 *adminv20231115008.APIClient
SdkClient20241113001 *adminv20241113001.APIClient
SdkClient20250312002 *adminv20250312002.APIClient
SdkClient20250312002 *admin.APIClient
}

type ProductionProvider struct {
Expand Down Expand Up @@ -148,34 +144,16 @@ func (p *ProductionProvider) SdkClientSet(ctx context.Context, creds *Credential

httpClient := &http.Client{Transport: transport}

clientv20231115008, err := adminv20231115008.NewClient(
adminv20231115008.UseBaseURL(p.domain),
adminv20231115008.UseHTTPClient(httpClient),
adminv20231115008.UseUserAgent(operatorUserAgent()))
if err != nil {
return nil, err
}

clientv20241113001, err := adminv20241113001.NewClient(
adminv20241113001.UseBaseURL(p.domain),
adminv20241113001.UseHTTPClient(httpClient),
adminv20241113001.UseUserAgent(operatorUserAgent()))
if err != nil {
return nil, err
}

clientv20241113002, err := adminv20250312002.NewClient(
adminv20250312002.UseBaseURL(p.domain),
adminv20250312002.UseHTTPClient(httpClient),
adminv20250312002.UseUserAgent(operatorUserAgent()))
clientv20250312002, err := admin.NewClient(
admin.UseBaseURL(p.domain),
admin.UseHTTPClient(httpClient),
admin.UseUserAgent(operatorUserAgent()))
if err != nil {
return nil, err
}

return &ClientSet{
SdkClient20231115008: clientv20231115008,
SdkClient20241113001: clientv20241113001,
SdkClient20250312002: clientv20241113002,
SdkClient20250312002: clientv20250312002,
}, nil
}

Expand Down
Loading
Loading