-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
unset.go
37 lines (31 loc) · 980 Bytes
/
unset.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
package label
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/eks"
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
"github.com/weaveworks/eksctl/pkg/cfn/manager"
)
func (m *Manager) Unset(ctx context.Context, nodeGroupName string, labels []string) error {
err := m.service.UpdateLabels(ctx, nodeGroupName, nil, labels)
if err != nil {
switch {
case manager.IsStackDoesNotExistError(err):
return m.unsetLabelsOnUnownedNodeGroup(ctx, nodeGroupName, labels)
default:
return err
}
}
return nil
}
func (m *Manager) unsetLabelsOnUnownedNodeGroup(ctx context.Context, nodeGroupName string, labels []string) error {
_, err := m.eksAPI.UpdateNodegroupConfig(ctx, &eks.UpdateNodegroupConfigInput{
ClusterName: aws.String(m.clusterName),
NodegroupName: aws.String(nodeGroupName),
Labels: &ekstypes.UpdateLabelsPayload{RemoveLabels: labels},
})
if err != nil {
return err
}
return nil
}