/
exec.go
41 lines (33 loc) · 903 Bytes
/
exec.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
// Copyright Contributors to the Open Cluster Management project
package clusterclaim
import (
"github.com/stolostron/cm-cli/pkg/clusterpoolhost"
"github.com/spf13/cobra"
)
func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
if len(args) > 0 {
o.ClusterClaim = args[0]
}
return nil
}
func (o *Options) validate() error {
return nil
}
func (o *Options) run() (err error) {
cph, err := clusterpoolhost.GetClusterPoolHostOrCurrent(o.ClusterPoolHost)
if err != nil {
return err
}
err = cph.OpenClusterClaim(o.ClusterClaim, o.Timeout, o.GetOptions.PrintFlags)
if err != nil {
return err
}
if o.WithCredentials {
cc, err := cph.GetClusterClaim(o.ClusterClaim, true, o.Timeout, o.CMFlags.DryRun, o.GetOptions.PrintFlags)
if err != nil {
return err
}
return cph.PrintClusterClaimCred(cc, o.GetOptions.PrintFlags, o.WithCredentials)
}
return nil
}