Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/local-app/cmd/config-get.go
2497 views
1
// Copyright (c) 2023 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
"github.com/gitpod-io/local-app/pkg/config"
9
"github.com/gitpod-io/local-app/pkg/prettyprint"
10
"github.com/spf13/cobra"
11
)
12
13
var configGetCmd = &cobra.Command{
14
Use: "get",
15
Short: "Get an individual config value in the config file",
16
RunE: func(cmd *cobra.Command, args []string) error {
17
cmd.SilenceUsage = true
18
19
cfg := config.FromContext(cmd.Context())
20
21
host := "not set"
22
organizationID := "not set"
23
24
gpctx, ok := cfg.Contexts[cfg.ActiveContext]
25
if !ok {
26
gpctx = &config.ConnectionContext{}
27
} else {
28
host = gpctx.Host.Host
29
organizationID = gpctx.OrganizationID
30
}
31
32
return WriteTabular([]struct {
33
Telemetry bool `header:"Telemetry"`
34
Autoupdate bool `header:"Autoupdate"`
35
Host string `header:"Host"`
36
OrganizationID string `header:"OrganizationID" print:"organization id"`
37
}{
38
{Telemetry: cfg.Telemetry.Enabled, Autoupdate: cfg.Autoupdate, Host: host, OrganizationID: organizationID},
39
}, configGetOpts.Format, prettyprint.WriterFormatNarrow)
40
},
41
}
42
43
var configGetOpts struct {
44
Format formatOpts
45
}
46
47
func init() {
48
configCmd.AddCommand(configGetCmd)
49
addFormatFlags(configGetCmd, &configGetOpts.Format)
50
}
51
52