Skip to content

Commit

Permalink
cmd/ore: add akamai garbage collection
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
  • Loading branch information
tormath1 committed Dec 3, 2024
1 parent 87e8f7c commit dfb631d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/ore/akamai/gc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright The Mantle Authors.
// SPDX-License-Identifier: Apache-2.0

package akamai

import (
"fmt"
"time"

"github.com/spf13/cobra"
)

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

gcDuration time.Duration
)

func init() {
Akamai.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(cmd.Context(), gcDuration); err != nil {
return fmt.Errorf("running garbage collection: %w", err)
}

return nil
}

0 comments on commit dfb631d

Please sign in to comment.