Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/preview/previewctl/cmd/access.go
2500 views
1
// Copyright (c) 2022 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
10
"github.com/cockroachdb/errors"
11
"github.com/sirupsen/logrus"
12
"github.com/spf13/cobra"
13
)
14
15
func newHasAccessCmd(logger *logrus.Logger) *cobra.Command {
16
clusters := []string{}
17
cmd := &cobra.Command{
18
Use: "has-access",
19
Short: "Check if caller has access to the provided list of clusters",
20
RunE: func(cmd *cobra.Command, args []string) error {
21
for _, kc := range clusters {
22
if !hasAccess(context.Background(), logger, kc) {
23
return errors.Newf("no access to [%v]", kc)
24
}
25
}
26
27
logger.Infof("Has access to %v", clusters)
28
return nil
29
},
30
}
31
32
cmd.PersistentFlags().StringSliceVar(&clusters, "clusters", []string{""}, "Comma separated list of cluster to check access for")
33
34
return cmd
35
}
36
37