Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/gpctl/cmd/clusters-cordon.go
2498 views
1
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package cmd
6
7
import (
8
"context"
9
"fmt"
10
"io"
11
12
"github.com/spf13/cobra"
13
14
"github.com/gitpod-io/gitpod/common-go/log"
15
"github.com/gitpod-io/gitpod/ws-manager-bridge/api"
16
)
17
18
// clustersCordonCmd represents the clustersCordonCmd command
19
var clustersCordonCmd = &cobra.Command{
20
Use: "cordon --name [cluster name]",
21
Short: "Cordon a cluster",
22
Run: func(cmd *cobra.Command, args []string) {
23
ctx, cancel := context.WithCancel(context.Background())
24
defer cancel()
25
26
conn, client, err := getClustersClient(ctx)
27
if err != nil {
28
log.WithError(err).Fatal("cannot connect")
29
}
30
defer conn.Close()
31
32
name := getClusterName()
33
request := &api.UpdateRequest{Name: name, Property: &api.UpdateRequest_Cordoned{Cordoned: true}}
34
_, err = client.Update(ctx, request)
35
if err != nil && err != io.EOF {
36
log.Fatal(err)
37
}
38
39
fmt.Printf("cluster '%s' cordoned\n", name)
40
},
41
}
42
43
func init() {
44
clustersCmd.AddCommand(clustersCordonCmd)
45
}
46
47