Skip to content

Commit

Permalink
task: delete dead code used by mongocli (#2766)
Browse files Browse the repository at this point in the history
  • Loading branch information
gssbzn authored Mar 13, 2024
1 parent 8c352cd commit f52ef94
Show file tree
Hide file tree
Showing 23 changed files with 14 additions and 352 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/code-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,6 @@ jobs:
with:
paths: unit-tests.xml
if: always() && matrix.os == 'ubuntu-latest'
integration-tests:
env:
COVERAGE: coverage.out
TEST_CMD: gotestsum --format standard-verbose --
UNIT_TAGS: unit
INTEGRATION_TAGS: integration
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: go install gotest.tools/gotestsum@latest
- run: make integration-test
fuzz-tests:
env:
COVERAGE: coverage.out
Expand Down
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ DEBUG_FLAGS=all=-N -l

TEST_CMD?=go test
UNIT_TAGS?=unit
INTEGRATION_TAGS?=integration
E2E_TAGS?=e2e
E2E_TIMEOUT?=60m
E2E_PARALLEL?=1
Expand Down Expand Up @@ -72,7 +71,7 @@ fmt-all: ### Format all go files with goimports and gofmt
find . -name "*.go" -not -path "./vendor/*" -not -path "./internal/mocks" -exec goimports -l -w "{}" \;

.PHONY: test
test: unit-test integration-test fuzz-normalizer-test
test: unit-test fuzz-normalizer-test

.PHONY: lint
lint: ## Run linter
Expand Down Expand Up @@ -128,11 +127,6 @@ e2e-test: build ## Run E2E tests
# the target assumes the MCLI_* environment variables are exported
$(TEST_CMD) -v -p 1 -parallel $(E2E_PARALLEL) -timeout $(E2E_TIMEOUT) -tags="$(E2E_TAGS)" ./test/e2e... $(E2E_EXTRA_ARGS)

.PHONY: integration-test
integration-test: ## Run integration tests
@echo "==> Running integration tests..."
$(TEST_CMD) --tags="$(INTEGRATION_TAGS)" -count=1 ./internal...

.PHONY: fuzz-normalizer-test
fuzz-normalizer-test: ## Run fuzz test
@echo "==> Running fuzz test..."
Expand Down
3 changes: 1 addition & 2 deletions internal/cli/atlas/deployments/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ type DownloadOpts struct {
}

var (
ErrAtlasNotSupported = errors.New("atlas deployments are not supported")
errEmptyLog = errors.New("log is empty")
errEmptyLog = errors.New("log is empty")
)

func (opts *DownloadOpts) initStore(ctx context.Context) func() error {
Expand Down
3 changes: 0 additions & 3 deletions internal/cli/atlas/deployments/search/indexes/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ import (
)

const (
namePattern = "^[a-zA-Z0-9][a-zA-Z0-9-]*$"
connectWaitSeconds = 10
createTemplate = "Search index created with ID: {{.IndexID}}\n"
notFoundState = "NOT_FOUND"
)

var ErrNoDeploymentName = errors.New("deployment name is required for Atlas resources")
var ErrNotAuthenticated = errors.New("not authenticated, login first to create Atlas resources")
var ErrSearchIndexDuplicated = errors.New("search index is duplicated")
var ErrWatchNotAvailable = errors.New("watch is not available for Atlas resources")

Expand Down
5 changes: 2 additions & 3 deletions internal/cli/atlas/deployments/search/indexes/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package indexes
import (
"bytes"
"context"
"errors"
"testing"

"github.com/golang/mock/gomock"
Expand All @@ -43,7 +44,6 @@ const (
expectedLocalDeployment = "localDeployment1"
expectedDB = "db1"
expectedCollection = "col1"
local = "local"
)

func TestCreate_RunLocal(t *testing.T) {
Expand Down Expand Up @@ -270,8 +270,7 @@ func TestCreate_Duplicated(t *testing.T) {
SearchIndexByName(ctx, index.Name, index.CollectionName).
Return(indexWithID, nil).
Times(1)

if err := opts.Run(ctx); err == nil || err != ErrSearchIndexDuplicated {
if err := opts.Run(ctx); err == nil || !errors.Is(err, ErrSearchIndexDuplicated) {
t.Fatalf("Run() unexpected error: %v", err)
}
}
Expand Down
6 changes: 0 additions & 6 deletions internal/cli/atlas/deployments/search/indexes/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ func TestDelete_RunLocal(t *testing.T) {
ctx := context.Background()

const (
expectedIndexName = "idx1"
expectedLocalDeployment = "localDeployment1"
expectedDB = "db1"
expectedCollection = "col1"
indexID = "1"
)

Expand Down Expand Up @@ -117,10 +114,7 @@ func TestDelete_RunAtlas(t *testing.T) {
ctx := context.Background()

const (
expectedIndexName = "idx1"
expectedLocalDeployment = "localDeployment1"
expectedDB = "db1"
expectedCollection = "col1"
indexID = "1"
projectID = "1"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ func TestDescribe_RunAtlas(t *testing.T) {
ctx := context.Background()

const (
expectedIndexName = "idx1"
expectedLocalDeployment = "localDeployment1"
expectedDB = "db1"
expectedCollection = "col1"
)

deploymentTest := fixture.NewMockAtlasDeploymentOpts(ctrl, expectedLocalDeployment)
Expand Down
1 change: 0 additions & 1 deletion internal/cli/atlas/setup/setup_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
)

const (
labelKey = "Infrastructure Tool"
DefaultAtlasTier = "M0"
defaultAtlasGovTier = "M30"
atlasAdmin = "atlasAdmin"
Expand Down
10 changes: 0 additions & 10 deletions internal/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const (
DefaultProfile = "default" // DefaultProfile default
CloudService = "cloud" // CloudService setting when using Atlas API
CloudGovService = "cloudgov" // CloudGovService setting when using Atlas API for Government
JSON = "json" // JSON output format as json
projectID = "project_id"
orgID = "org_id"
mongoShellPath = "mongosh_path"
Expand Down Expand Up @@ -660,15 +659,6 @@ func (p *Profile) LoadAtlasCLIConfig(readEnvironmentVars bool) error {
return p.load(readEnvironmentVars, AtlasCLIEnvPrefix)
}

func LoadMongoCLIConfig() error { return Default().LoadMongoCLIConfig(true) }
func (p *Profile) LoadMongoCLIConfig(readEnvironmentVars bool) error {
if p.err != nil {
return p.err
}
viper.SetConfigName("config")
return p.load(readEnvironmentVars, MongoCLIEnvPrefix)
}

func hasMongoCLIEnvVars() bool {
envVars := os.Environ()
for _, v := range envVars {
Expand Down
184 changes: 0 additions & 184 deletions internal/config/profile_integration_test.go

This file was deleted.

22 changes: 0 additions & 22 deletions internal/convert/errors.go

This file was deleted.

14 changes: 0 additions & 14 deletions internal/decryption/decryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@ func NewDecryption(options ...Option) *Decryption {
return d
}

func WithLocalOpts(fileName string) func(d *Decryption) {
return func(d *Decryption) {
d.opts.Local = &KeyProviderLocalOpts{
KeyFileName: fileName,
}
}
}

func WithKMIPOpts(opts *KeyProviderKMIPOpts) func(d *Decryption) {
return func(d *Decryption) {
d.opts.KMIP = opts
}
}

func WithAWSOpts(accessKey, secretAccessKey, sessionToken string) func(d *Decryption) {
return func(d *Decryption) {
d.opts.AWS = &KeyProviderAWSOpts{
Expand Down
Loading

0 comments on commit f52ef94

Please sign in to comment.