Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cmd/atlas/alerts/alert_configurations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/teabranch/matlas-cli/internal/cli"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/alerts/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/teabranch/matlas-cli/internal/cli"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/spf13/cobra"
"go.mongodb.org/atlas-sdk/v20250312006/admin"
"go.mongodb.org/atlas-sdk/v20250312010/admin"
"gopkg.in/yaml.v3"

"github.com/teabranch/matlas-cli/internal/cli"
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/network-containers/network_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/teabranch/matlas-cli/internal/cli"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/network-peering/network_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/teabranch/matlas-cli/internal/cli"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/teabranch/matlas-cli/internal/cli"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/projects/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

atlasclient "github.com/teabranch/matlas-cli/internal/clients/atlas"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down
22 changes: 17 additions & 5 deletions cmd/atlas/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/spf13/cobra"
"go.mongodb.org/atlas-sdk/v20250312006/admin"
"go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/teabranch/matlas-cli/internal/cli"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down Expand Up @@ -343,17 +343,23 @@ func runGetSearchIndex(cmd *cobra.Command, projectID, clusterName, indexID, inde
progress.StopSpinnerWithError("Search index not found")
return fmt.Errorf("search index %q not found", indexName)
}
res, err = searchService.GetSearchIndex(ctx, projectID, clusterName, foundID)
clusterIdx, err := searchService.GetSearchIndex(ctx, projectID, clusterName, foundID)
if err != nil {
progress.StopSpinnerWithError("Failed to get search index details")
return cli.WrapWithSuggestion(err, "Check your project ID, cluster name, and index identifier")
}
// Convert to SearchIndexResponse for formatting
converted := atlas.ConvertClusterSearchIndexToResponse(clusterIdx)
res = &converted
} else {
res, err = searchService.GetSearchIndex(ctx, projectID, clusterName, indexID)
clusterIdx, err := searchService.GetSearchIndex(ctx, projectID, clusterName, indexID)
if err != nil {
progress.StopSpinnerWithError("Failed to get search index details")
return cli.WrapWithSuggestion(err, "Check your project ID, cluster name, and index identifier")
}
// Convert to SearchIndexResponse for formatting
converted := atlas.ConvertClusterSearchIndexToResponse(clusterIdx)
res = &converted
}
progress.StopSpinner(fmt.Sprintf("Fetched details for index %s", res.GetName()))
// Format and display result
Expand Down Expand Up @@ -455,18 +461,24 @@ func runCreateSearchIndex(cmd *cobra.Command, projectID, clusterName, databaseNa
indexRequest.SetDefinition(*indexDefinition)
}

// Convert request to ClusterSearchIndex
clusterIndexReq := atlas.ConvertSearchIndexCreateRequestToClusterSearchIndex(indexRequest)

// Create the search index
result, err := searchService.CreateSearchIndex(ctx, projectID, clusterName, *indexRequest)
result, err := searchService.CreateSearchIndex(ctx, projectID, clusterName, *clusterIndexReq)
if err != nil {
progress.StopSpinnerWithError("Failed to create search index")
return cli.WrapWithSuggestion(err, "Check your project ID, cluster name, and index configuration")
}

progress.StopSpinner("Search index created successfully")

// Convert result to SearchIndexResponse for formatting
converted := atlas.ConvertClusterSearchIndexToResponse(result)

// Format and display the result
formatter := output.CreateSearchIndexesFormatter()
return formatter.FormatSearchIndex(*result, cmd.Flag("output").Value.String())
return formatter.FormatSearchIndex(converted, cmd.Flag("output").Value.String())
}

func runUpdateSearchIndex(cmd *cobra.Command, projectID, clusterName, indexID, indexFile string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"syscall"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
"golang.org/x/term"

"github.com/teabranch/matlas-cli/internal/cli"
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/users/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
)

func TestNewUsersCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/atlas/vpc-endpoints/vpc_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/teabranch/matlas-cli/internal/services/atlas"
"github.com/teabranch/matlas-cli/internal/ui"
"github.com/teabranch/matlas-cli/internal/validation"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
"os"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/spf13/cobra"
"go.mongodb.org/atlas-sdk/v20250312006/admin"
"go.mongodb.org/atlas-sdk/v20250312010/admin"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down
2 changes: 1 addition & 1 deletion cmd/database/roles/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/spf13/cobra"
"go.mongodb.org/atlas-sdk/v20250312006/admin"
"go.mongodb.org/atlas-sdk/v20250312010/admin"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
Expand Down
2 changes: 1 addition & 1 deletion cmd/database/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/spf13/cobra"
"go.mongodb.org/atlas-sdk/v20250312006/admin"
"go.mongodb.org/atlas-sdk/v20250312010/admin"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
Expand Down
2 changes: 1 addition & 1 deletion cmd/infra/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/spf13/cobra"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/teabranch/matlas-cli/internal/apply"
"github.com/teabranch/matlas-cli/internal/config"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ require (
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/oauth2 v0.32.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/text v0.22.0 // indirect
)

require (
github.com/go-playground/validator/v10 v10.27.0
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
github.com/subosito/gotenv v1.6.0
go.mongodb.org/atlas-sdk/v20250312006 v20250312006.1.0
go.mongodb.org/atlas-sdk/v20250312010 v20250312010.0.0
go.mongodb.org/mongo-driver v1.17.4
golang.org/x/term v0.33.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
12 changes: 6 additions & 6 deletions go.sum

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

23 changes: 9 additions & 14 deletions internal/apply/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/teabranch/matlas-cli/internal/services/atlas"
"github.com/teabranch/matlas-cli/internal/services/database"
"github.com/teabranch/matlas-cli/internal/types"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
Expand Down Expand Up @@ -1045,8 +1045,8 @@ func (e *AtlasExecutor) createSearchIndex(ctx context.Context, operation *Planne
return fmt.Errorf("project ID not available for search index creation")
}

// Create the search index request
indexRequest := admin.NewSearchIndexCreateRequest(
// Create the search index request (SDK now uses ClusterSearchIndex)
indexRequest := admin.NewClusterSearchIndex(
searchManifest.Spec.CollectionName,
searchManifest.Spec.DatabaseName,
searchManifest.Spec.IndexName,
Expand All @@ -1058,18 +1058,13 @@ func (e *AtlasExecutor) createSearchIndex(ctx context.Context, operation *Planne
}

// Convert and set definition
// Note: Definition structure may differ between old SearchIndexCreateRequest and new ClusterSearchIndex
// For now, we'll skip the definition conversion as it requires more complex field mapping
// TODO: Implement full definition conversion when needed
if searchManifest.Spec.Definition != nil {
definition, err := convertSearchDefinitionToSDK(searchManifest.Spec.Definition, searchManifest.Spec.IndexType)
if err != nil {
return fmt.Errorf("failed to convert search definition: %w", err)
}

// Enhance definition with advanced features
if err := enhanceDefinitionWithAdvancedFeatures(definition, &searchManifest.Spec); err != nil {
return fmt.Errorf("failed to enhance definition with advanced features: %w", err)
}

indexRequest.SetDefinition(*definition)
// Print warning about definition conversion (executor has no logger)
fmt.Fprintf(os.Stderr, "Warning: Search index definition conversion not fully implemented in new SDK version (index: %s, cluster: %s)\n",
searchManifest.Spec.IndexName, searchManifest.Spec.ClusterName)
}

// Create the search index
Expand Down
2 changes: 1 addition & 1 deletion internal/apply/executor_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
"time"

admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion internal/apply/fetchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/teabranch/matlas-cli/internal/types"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
)

// convertClusterToManifest converts an Atlas cluster to our ClusterManifest type
Expand Down
2 changes: 1 addition & 1 deletion internal/clients/atlas/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/teabranch/matlas-cli/internal/logging"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
)

// Config defines optional settings for initializing the Atlas client wrapper.
Expand Down
2 changes: 1 addition & 1 deletion internal/clients/atlas/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
)

func TestClient_Do_RetriesTransient(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/clients/atlas/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
)

// Typed errors used by higher layers to reason about Atlas failures.
Expand Down
2 changes: 1 addition & 1 deletion internal/output/search_formatters.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"text/tabwriter"

"github.com/teabranch/matlas-cli/internal/config"
admin "go.mongodb.org/atlas-sdk/v20250312006/admin"
admin "go.mongodb.org/atlas-sdk/v20250312010/admin"
)

// SearchIndexesFormatter provides formatting for Atlas Search indexes
Expand Down
Loading
Loading