Skip to content

Commit

Permalink
Merge branch 'master' into fix/rdb_cli
Browse files Browse the repository at this point in the history
  • Loading branch information
jremy42 authored Jan 9, 2025
2 parents e3f8ca4 + aafd622 commit e3f98cf
Show file tree
Hide file tree
Showing 410 changed files with 166,353 additions and 173,482 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,24 @@ jobs:
env:
SLACK_WEBHOOK_NIGHTLY: ${{ secrets.SLACK_WEBHOOK_NIGHTLY }}
FAILED_PRODUCT: ${{ matrix.products }}

sweepers:
runs-on: ubuntu-latest
needs: nightly
if: always()
steps:
# Checkout should always be before setup-go to ensure caching is working
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Run Sweepers
run: go run -v ./cmd/scw-sweeper
env:
SCW_DEBUG: 1
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COPY .git/ .git/

RUN ./scripts/build.sh

FROM alpine:3.20
FROM alpine:3.21
WORKDIR /
RUN apk update && apk add --no-cache bash ca-certificates openssh-client && update-ca-certificates
COPY --from=builder /go/src/github.com/scaleway/scaleway-cli/scw .
Expand Down
202 changes: 202 additions & 0 deletions cmd/scw-sweeper/main.go
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
}
2 changes: 1 addition & 1 deletion cmd/scw-wasm-tester/human.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/hashicorp/go-version"
"github.com/scaleway/scaleway-cli/v2/core"
"github.com/scaleway/scaleway-cli/v2/internal/human"
"github.com/scaleway/scaleway-cli/v2/core/human"
)

func wasmTestMarshalBuildInfo(_ js.Value, _ []js.Value) any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARGS:
[project-id] Project ID to use. If none is passed the default project ID will be used
[type] Create a server of the given type
[os-id] Create a server with the given os_id
[enable-vpc] Activate the Private Network feature for this server
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-3)

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ARGS:
server-id UUID of the server you want to update
name Updated name for your server
[schedule-deletion] Specify whether the server should be flagged for automatic deletion
[enable-vpc] Activate or deactivate Private Network support for this server
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-3)

FLAGS:
Expand Down
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
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-iam-user-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AVAILABLE COMMANDS:
list List users of an Organization
update Update a user
update-password Update an user's password. Private Beta feature.
update-username Update an user's username. Private Beta feature.

FLAGS:
-h, --help help for user
Expand Down
5 changes: 3 additions & 2 deletions cmd/scw/testdata/test-all-usage-ipam-ip-list-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ ARGS:
[subnet-id] Subnet ID to filter for.
[vpc-id] VPC ID to filter for.
[attached] Defines whether to filter only for IPs which are attached to a resource
[resource-name] Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.
[resource-id] Resource ID to filter for. Only IPs attached to this resource will be returned
[resource-ids.{index}] Resource IDs to filter for. Only IPs attached to at least one of these resources will be returned
[resource-type] Resource type to filter for. Only IPs attached to this type of resource will be returned (unknown_type | custom | instance_server | instance_ip | instance_private_nic | lb_server | fip_ip | vpc_gateway | vpc_gateway_network | k8s_node | k8s_cluster | rdb_instance | redis_cluster | baremetal_server | baremetal_private_nic | llm_deployment | mgdb_instance | apple_silicon_server | apple_silicon_private_nic)
[resource-types.{index}] Resource types to filter for. Only IPs attached to these types of resources will be returned (unknown_type | custom | instance_server | instance_ip | instance_private_nic | lb_server | fip_ip | vpc_gateway | vpc_gateway_network | k8s_node | k8s_cluster | rdb_instance | redis_cluster | baremetal_server | baremetal_private_nic | llm_deployment | mgdb_instance | apple_silicon_server | apple_silicon_private_nic)
[mac-address] MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned
[tags.{index}] Tags to filter for, only IPs with one or more matching tags will be returned
[is-ipv6] Defines whether to filter only for IPv4s or IPv6s
[resource-name] Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.
[resource-types.{index}] Resource types to filter for. Only IPs attached to these types of resources will be returned (unknown_type | custom | instance_server | instance_ip | instance_private_nic | lb_server | fip_ip | vpc_gateway | vpc_gateway_network | k8s_node | k8s_cluster | rdb_instance | redis_cluster | baremetal_server | baremetal_private_nic | llm_deployment | mgdb_instance | apple_silicon_server | apple_silicon_private_nic)
[ip-ids.{index}] IP IDs to filter for. Only IPs with these UUIDs will be returned
[organization-id] Organization ID to filter for. Only IPs belonging to this Organization will be returned
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw | all)

Expand Down
22 changes: 22 additions & 0 deletions cmd/scw/testdata/test-all-usage-k8s-acl-add-usage.golden
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 cmd/scw/testdata/test-all-usage-k8s-acl-delete-usage.golden
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
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-k8s-acl-list-usage.golden
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
22 changes: 22 additions & 0 deletions cmd/scw/testdata/test-all-usage-k8s-acl-set-usage.golden
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
Loading

0 comments on commit e3f98cf

Please sign in to comment.