Skip to content

Commit

Permalink
CLOUDP-278384: Support Independent ID config generation (#3330)
Browse files Browse the repository at this point in the history
Signed-off-by: jose.vazquez <[email protected]>
  • Loading branch information
josvazg authored Oct 30, 2024
1 parent 0d5fb11 commit 638c43f
Show file tree
Hide file tree
Showing 19 changed files with 465 additions and 78 deletions.
13 changes: 12 additions & 1 deletion docs/command/atlas-kubernetes-config-generate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ Options
-
- false
- Flag that generates kubernetes secrets with data for projects, users, deployments entities.
* - --independentResources
-
- false
- Flag that makes the generated resources that support independent usage, to use external IDs rather than Kubernetes references.
* - --operatorVersion
- string
- false
- Version of Atlas Kubernetes Operator to generate resources for. This value defaults to "2.4.0".
- Version of Atlas Kubernetes Operator to generate resources for. This value defaults to "2.5.0".
* - --orgId
- string
- false
Expand Down Expand Up @@ -96,6 +100,13 @@ Examples
atlas kubernetes config generate --projectId=<projectId>


.. code-block::
:copyable: false

# Export Project, DatabaseUsers, Deployments resources for a specific project, but use external IDs where supported:
atlas kubernetes config generate --projectId=<projectId> --independentResources


.. code-block::
:copyable: false

Expand Down
2 changes: 1 addition & 1 deletion docs/command/atlas-organizations-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Options
* - --includeDeleted
-
- false
- Flag that indictaes whether to include deleted organizations in the list. This option applies only to Ops Manager organizations. You can't return deleted Atlas or Cloud Manager organizations.
- Flag that indicates whether to include deleted organizations in the list. This option applies only to Ops Manager organizations. You can't return deleted Atlas or Cloud Manager organizations.
* - --limit
- int
- false
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/mattn/go-isatty v0.0.20
github.com/mongodb-forks/digest v1.1.0
github.com/mongodb-labs/cobra2snooty v0.18.2
github.com/mongodb/mongodb-atlas-kubernetes/v2 v2.4.1
github.com/mongodb/mongodb-atlas-kubernetes/v2 v2.5.0
github.com/pelletier/go-toml v1.9.5
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/shirou/gopsutil/v4 v4.24.9
Expand Down
38 changes: 30 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwF
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0=
github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go-v2 v1.32.3 h1:T0dRlFBKcdaUPGNtkBSwHZxrtis8CQU17UpNBZYd0wk=
github.com/aws/aws-sdk-go-v2 v1.32.3/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo=
github.com/aws/aws-sdk-go-v2/config v1.28.1 h1:oxIvOUXy8x0U3fR//0eq+RdCKimWI900+SV+10xsCBw=
Expand Down Expand Up @@ -76,6 +80,10 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.32.3 h1:wVnQ6tigGsRqSWDEEyH6lSAJ9OyF
github.com/aws/aws-sdk-go-v2/service/sts v1.32.3/go.mod h1:VZa9yTFyj4o10YGsmDO4gbQJUvvhY72fhumT8W4LqsE=
github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM=
github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/briandowns/spinner v1.23.1 h1:t5fDPmScwUjozhDj4FA46p5acZWIPXYE30qW2Ptu650=
github.com/briandowns/spinner v1.23.1/go.mod h1:LaZeM4wm2Ywy6vO571mvhQNRcWfRUnXOs0RcKV0wYKM=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
Expand Down Expand Up @@ -168,6 +176,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/cel-go v0.20.1 h1:nDx9r8S3L4pE61eDdt8igGj8rf5kjYR3ILxWIpWNi84=
github.com/google/cel-go v0.20.1/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand All @@ -190,8 +200,8 @@ github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM=
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA=
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM=
github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA=
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 h1:SJ+NtwL6QaZ21U+IrK7d0gGgpjGGvd2kz+FzTHVzdqI=
Expand Down Expand Up @@ -259,16 +269,16 @@ github.com/mongodb-forks/digest v1.1.0 h1:7eUdsR1BtqLv0mdNm4OXs6ddWvR4X2/OsLwdKk
github.com/mongodb-forks/digest v1.1.0/go.mod h1:rb+EX8zotClD5Dj4NdgxnJXG9nwrlx3NWKJ8xttz1Dg=
github.com/mongodb-labs/cobra2snooty v0.18.2 h1:qWpLCMWbQb5FSZ5ehiWN2URmieMJhQtQPxT0uhIK62A=
github.com/mongodb-labs/cobra2snooty v0.18.2/go.mod h1:WnzqCFmx4f72Yj9dL/ulBUqcatfURGdKFf8DLT4h7zQ=
github.com/mongodb/mongodb-atlas-kubernetes/v2 v2.4.1 h1:EzIRqZ6yXX1U0gQBJJF6LYH5KQksU7k7wOVv/vtPoXg=
github.com/mongodb/mongodb-atlas-kubernetes/v2 v2.4.1/go.mod h1:hb8r0m7WRoSeKVX4yMKMxbVpgu/xlDqPUKTQoytG1mQ=
github.com/mongodb/mongodb-atlas-kubernetes/v2 v2.5.0 h1:2SzjXb9B3mVkYJfkCQXMMVjLULTNU7CXvLVKBpUe3MY=
github.com/mongodb/mongodb-atlas-kubernetes/v2 v2.5.0/go.mod h1:n4Ii1oia76D+x6Bn14KyfNxysMf6XAR6z8LfE93KHh0=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0=
github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4=
github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag=
github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8=
github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
Expand All @@ -282,7 +292,15 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
Expand All @@ -306,6 +324,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand Down Expand Up @@ -527,6 +547,8 @@ k8s.io/apiserver v0.31.2 h1:VUzOEUGRCDi6kX1OyQ801m4A7AUPglpsmGvdsekmcI4=
k8s.io/apiserver v0.31.2/go.mod h1:o3nKZR7lPlJqkU5I3Ove+Zx3JuoFjQobGX1Gctw6XuE=
k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc=
k8s.io/client-go v0.31.2/go.mod h1:NPa74jSVR/+eez2dFsEIHNa+3o09vtNaWwWwb1qSxSs=
k8s.io/component-base v0.31.2 h1:Z1J1LIaC0AV+nzcPRFqfK09af6bZ4D1nAOpWsy9owlA=
k8s.io/component-base v0.31.2/go.mod h1:9PeyyFN/drHjtJZMCTkSpQJS3U9OXORnHQqMLDz0sUQ=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
Expand Down
23 changes: 14 additions & 9 deletions internal/cli/kubernetes/config/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ var ErrUnsupportedOperatorVersionFmt = "version %q is not supported. Supported v
type GenerateOpts struct {
cli.GlobalOpts
cli.OutputOpts
clusterName []string
dataFederationName []string
includeSecrets bool
targetNamespace string
operatorVersion string
store store.OperatorGenericStore
credsStore store.CredentialsGetter
crdsProvider crds.AtlasOperatorCRDProvider
clusterName []string
dataFederationName []string
includeSecrets bool
targetNamespace string
operatorVersion string
store store.OperatorGenericStore
credsStore store.CredentialsGetter
crdsProvider crds.AtlasOperatorCRDProvider
independentResources bool
}

func (opts *GenerateOpts) ValidateTargetNamespace() error {
Expand Down Expand Up @@ -93,6 +94,7 @@ func (opts *GenerateOpts) Run() error {
WithFeatureValidator(atlasCRDs).
WithPatcher(atlasCRDs).
WithDataFederationNames(opts.dataFederationName).
WithIndependentResources(opts.independentResources).
Run()
if err != nil {
return err
Expand All @@ -115,6 +117,9 @@ func GenerateBuilder() *cobra.Command {
Example: `# Export Project, DatabaseUsers, Deployments resources for a specific project without connection and integration secrets:
atlas kubernetes config generate --projectId=<projectId>
# Export Project, DatabaseUsers, Deployments resources for a specific project, but use external IDs where supported:
atlas kubernetes config generate --projectId=<projectId> --independentResources
# Export Project, DatabaseUsers, Deployments resources for a specific project including connection and integration secrets:
atlas kubernetes config generate --projectId=<projectId> --includeSecrets
Expand Down Expand Up @@ -149,6 +154,6 @@ func GenerateBuilder() *cobra.Command {
cmd.Flags().StringVar(&opts.targetNamespace, flag.OperatorTargetNamespace, "", usage.OperatorTargetNamespace)
cmd.Flags().StringVar(&opts.operatorVersion, flag.OperatorVersion, features.LatestOperatorMajorVersion, usage.OperatorVersion)
cmd.Flags().StringSliceVar(&opts.dataFederationName, flag.DataFederationName, []string{}, usage.ExporterDataFederationName)

cmd.Flags().BoolVar(&opts.independentResources, flag.IndependentResources, false, usage.IndependentResources)
return cmd
}
1 change: 1 addition & 0 deletions internal/flag/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,5 @@ const (
IdentityProviderID = "identityProviderId" // IdentityProviderId flag
AuditAuthorizationSuccess = "auditAuthorizationSuccess" // AuditAuthorizationSuccess flag
AuditFilter = "auditFilter" // AuditFilter flag
IndependentResources = "independentResources" // IndependentResources flag
)
24 changes: 20 additions & 4 deletions internal/kubernetes/operator/config_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
maxClusters = 500
DefaultClustersCount = 10
InactiveStatus = "INACTIVE"

credentialSuffix = "-credentials"
)

type ConfigExporter struct {
Expand All @@ -55,6 +57,7 @@ type ConfigExporter struct {
dictionaryForAtlasNames map[string]string
dataFederationNames []string
patcher Patcher
independentResources bool
}

type Patcher interface {
Expand Down Expand Up @@ -116,6 +119,11 @@ func (e *ConfigExporter) WithPatcher(p Patcher) *ConfigExporter {
return e
}

func (e *ConfigExporter) WithIndependentResources(enabled bool) *ConfigExporter {
e.independentResources = enabled
return e
}

func (e *ConfigExporter) Run() (string, error) {
// TODO: Add REST to OPERATOR entities matcher
output := bytes.NewBufferString(yamlSeparator)
Expand Down Expand Up @@ -215,10 +223,11 @@ func (e *ConfigExporter) exportProject() ([]runtime.Object, string, error) {
r = append(r, t)
}

credentialsName := credentialsName(projectData.Project.Name)
// Project secret with credentials
r = append(r, project.BuildProjectConnectionSecret(
r = append(r, project.BuildProjectNamedConnectionSecret(
e.credsProvider,
projectData.Project.Name,
credentialsName,
projectData.Project.Namespace,
e.orgID,
e.includeSecretsData,
Expand All @@ -231,8 +240,10 @@ func (e *ConfigExporter) exportProject() ([]runtime.Object, string, error) {
e.projectID,
projectData.Project.Name,
e.targetNamespace,
credentialsName,
e.dictionaryForAtlasNames,
e.operatorVersion)
e.operatorVersion,
e.independentResources)
if err != nil {
return nil, "", err
}
Expand Down Expand Up @@ -262,9 +273,10 @@ func (e *ConfigExporter) exportDeployments(projectName string) ([]runtime.Object
e.clusterNames = clusters
}

credentials := credentialsName(projectName)
for _, deploymentName := range e.clusterNames {
// Try advanced cluster first
if advancedCluster, err := deployment.BuildAtlasAdvancedDeployment(e.dataProvider, e.featureValidator, e.projectID, projectName, deploymentName, e.targetNamespace, e.dictionaryForAtlasNames, e.operatorVersion); err == nil {
if advancedCluster, err := deployment.BuildAtlasAdvancedDeployment(e.dataProvider, e.featureValidator, e.projectID, projectName, deploymentName, e.targetNamespace, credentials, e.dictionaryForAtlasNames, e.operatorVersion, e.independentResources); err == nil {
if advancedCluster != nil {
// Append deployment to result
result = append(result, advancedCluster.Deployment)
Expand Down Expand Up @@ -448,3 +460,7 @@ func (e *ConfigExporter) exportAtlasFederatedAuth(projectName string) ([]runtime
}
return append(result, federatedAuthentification), nil
}

func credentialsName(projectName string) string {
return projectName + credentialSuffix
}
10 changes: 5 additions & 5 deletions internal/kubernetes/operator/config_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func TestExportAtlasStreamProcessing(t *testing.T) {
ce := NewConfigExporter(atlasOperatorGenericStore, nil, projectID, orgID).
WithFeatureValidator(featureValidator).
WithTargetNamespace("test").
WithTargetOperatorVersion("2.4.0")
WithTargetOperatorVersion("2.5.0")

resources, err := ce.exportAtlasStreamProcessing("my-project")
require.NoError(t, err)
Expand All @@ -308,7 +308,7 @@ func TestExportAtlasStreamProcessing(t *testing.T) {
Name: "my-project-instance-0",
Namespace: "test",
Labels: map[string]string{
"mongodb.com/atlas-resource-version": "2.4.0",
"mongodb.com/atlas-resource-version": "2.5.0",
},
},
Spec: akov2.AtlasStreamInstanceSpec{
Expand Down Expand Up @@ -348,7 +348,7 @@ func TestExportAtlasStreamProcessing(t *testing.T) {
Name: "my-project-instance-0-samplelowlinestreamlowlinesolar",
Namespace: "test",
Labels: map[string]string{
"mongodb.com/atlas-resource-version": "2.4.0",
"mongodb.com/atlas-resource-version": "2.5.0",
},
},
Spec: akov2.AtlasStreamConnectionSpec{
Expand All @@ -370,7 +370,7 @@ func TestExportAtlasStreamProcessing(t *testing.T) {
Name: "my-project-instance-0-kafka-config",
Namespace: "test",
Labels: map[string]string{
"mongodb.com/atlas-resource-version": "2.4.0",
"mongodb.com/atlas-resource-version": "2.5.0",
},
},
Spec: akov2.AtlasStreamConnectionSpec{
Expand Down Expand Up @@ -625,7 +625,7 @@ func defaultTestConfigExporter(t *testing.T, genStore *mocks.MockOperatorGeneric
return NewConfigExporter(genStore, nil, projectID, orgID).
WithTargetNamespace("test").
WithFeatureValidator(featureValidator).
WithTargetOperatorVersion("2.4.0").
WithTargetOperatorVersion("2.5.0").
WithSecretsData(true)
}

Expand Down
Loading

0 comments on commit 638c43f

Please sign in to comment.