-
Notifications
You must be signed in to change notification settings - Fork 21
/
eula.go
64 lines (54 loc) · 1.56 KB
/
eula.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2023 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package command
import (
"github.com/spf13/cobra"
configlib "github.com/vmware-tanzu/tanzu-plugin-runtime/config"
"github.com/vmware-tanzu/tanzu-plugin-runtime/log"
"github.com/vmware-tanzu/tanzu-cli/pkg/cli"
"github.com/vmware-tanzu/tanzu-cli/pkg/config"
)
func newEULACmd() *cobra.Command {
var eulaCmd = &cobra.Command{
Use: "eula",
Short: "Manage EULA acceptance",
Long: "Manage EULA acceptance for Tanzu CLI use",
}
eulaCmd.SetUsageFunc(cli.SubCmdUsageFunc)
showEULACmd := newShowEULACmd()
acceptEULACmd := newAcceptEULACmd()
eulaCmd.AddCommand(
showEULACmd,
acceptEULACmd,
)
return eulaCmd
}
func newShowEULACmd() *cobra.Command {
var showEULACmd = &cobra.Command{
Use: "show",
Short: "Present EULA",
Long: "Present EULA for review",
ValidArgsFunction: noMoreCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
return config.ConfigureEULA(true)
},
}
return showEULACmd
}
func newAcceptEULACmd() *cobra.Command {
var acceptEULACmd = &cobra.Command{
Use: "accept",
Short: "Accept the EULA",
Long: "Accept the EULA for Tanzu CLI non-interactively.",
ValidArgsFunction: noMoreCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
err := config.UpdateEULAAcceptance(configlib.EULAStatusAccepted)
if err != nil {
return err
}
log.Successf("Marking agreement as accepted.")
return nil
},
}
return acceptEULACmd
}