-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/rdb_cli
- Loading branch information
Showing
410 changed files
with
166,353 additions
and
173,482 deletions.
There are no files selected for viewing
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
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,202 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
accountSweeper "github.com/scaleway/scaleway-sdk-go/api/account/v3/sweepers" | ||
applesiliconSweeper "github.com/scaleway/scaleway-sdk-go/api/applesilicon/v1alpha1/sweepers" | ||
baremetalSweeper "github.com/scaleway/scaleway-sdk-go/api/baremetal/v1/sweepers" | ||
blockSweeper "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1/sweepers" | ||
cockpitSweeper "github.com/scaleway/scaleway-sdk-go/api/cockpit/v1/sweepers" | ||
containerSweeper "github.com/scaleway/scaleway-sdk-go/api/container/v1beta1/sweepers" | ||
flexibleipSweeper "github.com/scaleway/scaleway-sdk-go/api/flexibleip/v1alpha1/sweepers" | ||
functionSweeper "github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers" | ||
iamSweeper "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1/sweepers" | ||
inferenceSweeper "github.com/scaleway/scaleway-sdk-go/api/inference/v1beta1/sweepers" | ||
instanceSweeper "github.com/scaleway/scaleway-sdk-go/api/instance/v1/sweepers" | ||
iotSweeper "github.com/scaleway/scaleway-sdk-go/api/iot/v1/sweepers" | ||
ipamSweeper "github.com/scaleway/scaleway-sdk-go/api/ipam/v1/sweepers" | ||
jobsSweeper "github.com/scaleway/scaleway-sdk-go/api/jobs/v1alpha1/sweepers" | ||
k8sSweeper "github.com/scaleway/scaleway-sdk-go/api/k8s/v1/sweepers" | ||
lbSweeper "github.com/scaleway/scaleway-sdk-go/api/lb/v1/sweepers" | ||
mnqSweeper "github.com/scaleway/scaleway-sdk-go/api/mnq/v1beta1/sweepers" | ||
mongodbSweeper "github.com/scaleway/scaleway-sdk-go/api/mongodb/v1alpha1/sweepers" | ||
rdbSweeper "github.com/scaleway/scaleway-sdk-go/api/rdb/v1/sweepers" | ||
redisSweeper "github.com/scaleway/scaleway-sdk-go/api/redis/v1/sweepers" | ||
registrySweeper "github.com/scaleway/scaleway-sdk-go/api/registry/v1/sweepers" | ||
secretSweeper "github.com/scaleway/scaleway-sdk-go/api/secret/v1beta1/sweepers" | ||
sdbSweeper "github.com/scaleway/scaleway-sdk-go/api/serverless_sqldb/v1alpha1/sweepers" | ||
vpcSweeper "github.com/scaleway/scaleway-sdk-go/api/vpc/v2/sweepers" | ||
vpcgwSweeper "github.com/scaleway/scaleway-sdk-go/api/vpcgw/v1/sweepers" | ||
webhostingSweeper "github.com/scaleway/scaleway-sdk-go/api/webhosting/v1alpha1/sweepers" | ||
"github.com/scaleway/scaleway-sdk-go/scw" | ||
) | ||
|
||
func main() { | ||
exitCode := mainNoExit() | ||
os.Exit(exitCode) | ||
} | ||
|
||
func getConfigProfile() *scw.Profile { | ||
config, err := scw.LoadConfig() | ||
if err != nil { | ||
return &scw.Profile{} | ||
} | ||
profile, err := config.GetActiveProfile() | ||
if err != nil { | ||
return &scw.Profile{} | ||
} | ||
return profile | ||
} | ||
|
||
func mainNoExit() int { | ||
configProfile := getConfigProfile() | ||
envProfile := scw.LoadEnvProfile() | ||
profile := scw.MergeProfiles(configProfile, envProfile) | ||
|
||
client, err := scw.NewClient( | ||
scw.WithProfile(profile), | ||
scw.WithUserAgent("scw-sweeper"), | ||
scw.WithEnv(), | ||
) | ||
if err != nil { | ||
log.Fatalf("Cannot create Scaleway client: %s", err) | ||
} | ||
|
||
err = accountSweeper.SweepAll(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = applesiliconSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = baremetalSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = cockpitSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = containerSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = flexibleipSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = functionSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = iamSweeper.SweepSSHKey(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = inferenceSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = instanceSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
// Instance servers need to be swept before volumes and snapshots can be swept | ||
// because volumes and snapshots are attached to servers. | ||
err = blockSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = iotSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = ipamSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = jobsSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = k8sSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = lbSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = mongodbSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = mnqSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = rdbSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = redisSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = registrySweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = secretSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = sdbSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = vpcSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
err = vpcgwSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
log.Fatalf("Error sweeping vpcgw: %s", err) | ||
return -1 | ||
} | ||
|
||
err = webhostingSweeper.SweepAllLocalities(client) | ||
if err != nil { | ||
log.Fatalf("Error sweeping webhosting: %s", err) | ||
return -1 | ||
} | ||
|
||
return 0 | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
cmd/scw/testdata/test-all-usage-iam-user-update-username-usage.golden
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,19 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟥🟥🟥 STDERR️️ 🟥🟥🟥️ | ||
Update an user's username. Private Beta feature. | ||
|
||
USAGE: | ||
scw iam user update-username <user-id ...> [arg=value ...] | ||
|
||
ARGS: | ||
user-id ID of the user to update | ||
username The new username | ||
|
||
FLAGS: | ||
-h, --help help for update-username | ||
|
||
GLOBAL FLAGS: | ||
-c, --config string The path to the config file | ||
-D, --debug Enable debug mode | ||
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human") | ||
-p, --profile string The config profile to use |
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
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,22 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟥🟥🟥 STDERR️️ 🟥🟥🟥️ | ||
Add new ACL rules for a specific cluster. | ||
|
||
USAGE: | ||
scw k8s acl add [arg=value ...] | ||
|
||
ARGS: | ||
cluster-id ID of the cluster whose ACLs will be added | ||
[acls.{index}.ip] IP subnet to allow | ||
[acls.{index}.scaleway-ranges] Allow access to cluster from all Scaleway ranges as defined in https://www.scaleway.com/en/docs/console/account/reference-content/scaleway-network-information/#ip-ranges-used-by-scaleway. | ||
[acls.{index}.description] Description of the ACL | ||
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) | ||
|
||
FLAGS: | ||
-h, --help help for add | ||
|
||
GLOBAL FLAGS: | ||
-c, --config string The path to the config file | ||
-D, --debug Enable debug mode | ||
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human") | ||
-p, --profile string The config profile to use |
19 changes: 19 additions & 0 deletions
19
cmd/scw/testdata/test-all-usage-k8s-acl-delete-usage.golden
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,19 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟥🟥🟥 STDERR️️ 🟥🟥🟥️ | ||
Delete an existing ACL. | ||
|
||
USAGE: | ||
scw k8s acl delete [arg=value ...] | ||
|
||
ARGS: | ||
acl-id ID of the ACL rule to delete | ||
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) | ||
|
||
FLAGS: | ||
-h, --help help for delete | ||
|
||
GLOBAL FLAGS: | ||
-c, --config string The path to the config file | ||
-D, --debug Enable debug mode | ||
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human") | ||
-p, --profile string The config profile to use |
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,19 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟥🟥🟥 STDERR️️ 🟥🟥🟥️ | ||
List ACLs for a specific cluster. | ||
|
||
USAGE: | ||
scw k8s acl list [arg=value ...] | ||
|
||
ARGS: | ||
cluster-id ID of the cluster whose ACLs will be listed | ||
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw | all) | ||
|
||
FLAGS: | ||
-h, --help help for list | ||
|
||
GLOBAL FLAGS: | ||
-c, --config string The path to the config file | ||
-D, --debug Enable debug mode | ||
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human") | ||
-p, --profile string The config profile to use |
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,22 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟥🟥🟥 STDERR️️ 🟥🟥🟥️ | ||
Set new ACL rules for a specific cluster. | ||
|
||
USAGE: | ||
scw k8s acl set [arg=value ...] | ||
|
||
ARGS: | ||
cluster-id ID of the cluster whose ACLs will be set | ||
[acls.{index}.ip] IP subnet to allow | ||
[acls.{index}.scaleway-ranges] Allow access to cluster from all Scaleway ranges as defined in https://www.scaleway.com/en/docs/console/account/reference-content/scaleway-network-information/#ip-ranges-used-by-scaleway. | ||
[acls.{index}.description] Description of the ACL | ||
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) | ||
|
||
FLAGS: | ||
-h, --help help for set | ||
|
||
GLOBAL FLAGS: | ||
-c, --config string The path to the config file | ||
-D, --debug Enable debug mode | ||
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human") | ||
-p, --profile string The config profile to use |
Oops, something went wrong.