-
Notifications
You must be signed in to change notification settings - Fork 828
/
resourcetypes.go
49 lines (43 loc) · 2.12 KB
/
resourcetypes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package resourcetypes
import (
"context"
"time"
)
const (
karpenterClusterNameTag = "karpenter.sh/managed-by"
karpenterNodePoolTag = "karpenter.sh/nodepool"
karpenterLaunchTemplateTag = "karpenter.k8s.aws/cluster"
karpenterSecurityGroupTag = "karpenter.sh/discovery"
karpenterTestingTag = "testing/cluster"
k8sClusterTag = "cluster.k8s.amazonaws.com/name"
githubRunURLTag = "github.com/run-url"
)
// Type is a resource type that can be cleaned through a cluster clean-up operation
// and through an expiration-based cleanup operation
type Type interface {
// String is the string representation of the type
String() string
// Global determines if a resource is globally located in an account
Global() bool
// Get returns all resources of the type associated with the clusterName
Get(ctx context.Context, clusterName string) (ids []string, err error)
// GetExpired returns all resources of the type that were provisioned before the expirationTime
GetExpired(ctx context.Context, expirationTime time.Time, excludedClusters []string) (ids []string, err error)
// Cleanup deletes all resources of the type by id and returns the resource ids it succeeded to delete
// In general, if all resources can't be deleted by id with a single API call (like with DeleteInstances)
// you should call the requests synchronously to avoid rate limiting against the number of requests made
Cleanup(ctx context.Context, ids []string) (cleaned []string, err error)
// CountAll returns the number of all resource of the type in the account
CountAll(ctx context.Context) (count int, err error)
}