Skip to content

Commit

Permalink
cmd/ore: add scaleway garbage collection
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Tortuyaux <[email protected]>
  • Loading branch information
tormath1 committed Apr 12, 2024
1 parent b21d1c0 commit 490eacb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cmd/ore/scaleway/gc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright The Mantle Authors.
// SPDX-License-Identifier: Apache-2.0

package scaleway

import (
"context"
"fmt"
"time"

"github.com/spf13/cobra"
)

var (
cmdGC = &cobra.Command{
Use: "gc",
Short: "GC resources in Scaleway",
Long: `Delete instances and images created over the given duration ago`,
RunE: runGC,
}

gcDuration time.Duration
)

func init() {
Scaleway.AddCommand(cmdGC)
cmdGC.Flags().DurationVar(&gcDuration, "duration", 5*time.Hour, "how old resources must be before they're considered garbage")
}

func runGC(cmd *cobra.Command, args []string) error {
if err := API.GC(context.Background(), gcDuration); err != nil {
return fmt.Errorf("running garbage collection: %w", err)
}

return nil
}

0 comments on commit 490eacb

Please sign in to comment.