Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/cmd/config_init.go
2498 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
"fmt"
9
10
"github.com/gitpod-io/gitpod/installer/pkg/config"
11
"github.com/spf13/cobra"
12
)
13
14
var configInitOpts struct {
15
OverwriteConfig bool
16
}
17
18
// configInitCmd represents the validate command
19
var configInitCmd = &cobra.Command{
20
Use: "init",
21
Short: "Create a base config file",
22
Long: `Create a base config file
23
24
This file contains all the credentials to install a Gitpod instance and
25
be saved to a repository.`,
26
Example: ` # Save config to config.yaml.
27
gitpod-installer config init -c ./gitpod.config.yaml`,
28
RunE: func(cmd *cobra.Command, args []string) error {
29
// Check file isn't present
30
exists, err := configFileExists()
31
if err != nil {
32
return err
33
}
34
if *exists && !configInitOpts.OverwriteConfig {
35
return fmt.Errorf("file %s exists - to overwrite add --overwrite flag", configOpts.ConfigFile)
36
}
37
38
cfg, err := config.NewDefaultConfig()
39
if err != nil {
40
return err
41
}
42
43
return saveConfigFile(cfg)
44
},
45
}
46
47
func init() {
48
configCmd.AddCommand(configInitCmd)
49
50
configInitCmd.Flags().BoolVar(&configInitOpts.OverwriteConfig, "overwrite", false, "overwrite config file if it exists")
51
}
52
53