-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLOUDP-192880: Make clean CLI tool (#1149)
Signed-off-by: Jose Vazquez <jose.vazquez@mongodb.com>
- Loading branch information
Showing
29 changed files
with
127 additions
and
665 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,6 @@ tmp/ | |
|
||
# ready to work samples | ||
deploy/ | ||
|
||
# ignore tool binaries | ||
tools/clean/clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
go 1.21.1 | ||
|
||
use ( | ||
. | ||
./tools/clean | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= | ||
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= | ||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= | ||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= | ||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= | ||
github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= | ||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...hub/actions/cleanup/atlasclient/client.go → tools/clean/atlas/client/client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package atlasclient | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
|
2 changes: 1 addition & 1 deletion
2
.github/actions/cleanup/config.go → tools/clean/atlas/config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package atlas | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module tools/clean | ||
|
||
go 1.21.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"strings" | ||
"tools/clean/atlas" | ||
"tools/clean/pe" | ||
"tools/clean/vpc" | ||
) | ||
|
||
func main() { | ||
if err := Clean(os.Args); err != nil { | ||
log.Printf("Invocation failed: %s", err) | ||
log.Fatalf("Usage: %s {atlas|pe|vpc}", os.Args[0]) | ||
} | ||
} | ||
|
||
var cleanAtlas = atlas.CleanAtlas | ||
|
||
var cleanPEs = pe.CleanPEs | ||
|
||
var cleanVPCs = vpc.CleanVPCs | ||
|
||
func Clean(args []string) error { | ||
if len(args) != 2 { | ||
return fmt.Errorf("Wrong number of arguments: expected 1 got %d", len(args)-1) | ||
} | ||
action := strings.ToLower(args[1]) | ||
switch action { | ||
case "atlas": | ||
cleanAtlas() | ||
case "pe": | ||
cleanPEs() | ||
case "vpc": | ||
cleanVPCs() | ||
default: | ||
return fmt.Errorf("Unsupported action %q", action) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCleanBadInputs(t *testing.T) { | ||
t.Run("Calling without arguments fails", func(t *testing.T) { | ||
assert.ErrorContains(t, Clean([]string{}), "Wrong number of arguments") | ||
}) | ||
t.Run("Calling just with the command fails", func(t *testing.T) { | ||
assert.ErrorContains(t, Clean([]string{"clean"}), "expected 1 got 0") | ||
}) | ||
t.Run("Calling with too many arguments fails", func(t *testing.T) { | ||
assert.ErrorContains(t, Clean([]string{"clean", "atlas", "duh"}), "expected 1 got 2") | ||
}) | ||
} | ||
|
||
func TestCleanCalls(t *testing.T) { | ||
t.Run("Calling atlas works", func(t *testing.T) { | ||
cleanAtlas = func() {} | ||
assert.NoError(t, Clean([]string{"clean", "Atlas"})) | ||
}) | ||
t.Run("Calling vpc works", func(t *testing.T) { | ||
cleanVPCs = func() {} | ||
assert.NoError(t, Clean([]string{"clean", "VPC"})) | ||
}) | ||
t.Run("Calling atlas fails due to missing credentials", func(t *testing.T) { | ||
cleanPEs = func() {} | ||
assert.NoError(t, Clean([]string{"clean", "Pe"})) | ||
}) | ||
} |
2 changes: 1 addition & 1 deletion
2
.github/actions/cleanup-pe/cleanall.go → tools/clean/pe/cleanall.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package pe | ||
|
||
import ( | ||
"context" | ||
|
Oops, something went wrong.