Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/node-labeler/cmd/root.go
2498 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
"fmt"
9
"os"
10
11
"github.com/gitpod-io/gitpod/common-go/log"
12
"github.com/spf13/cobra"
13
)
14
15
var (
16
// ServiceName is the name we use for tracing/logging
17
ServiceName = "node-labeler"
18
// Version of this service - set during build
19
Version = ""
20
)
21
22
var (
23
jsonLog bool
24
verbose bool
25
26
registryFacadePort int
27
wsdaemonPort int
28
29
namespace string
30
)
31
32
// rootCmd represents the base command when called without any subcommands
33
var rootCmd = &cobra.Command{
34
Use: ServiceName,
35
Short: "node-labeler is in charge of maintaining the node labels that workspaces require to run in a node",
36
PersistentPreRun: func(cmd *cobra.Command, args []string) {
37
log.Init(ServiceName, Version, jsonLog, verbose)
38
},
39
}
40
41
// Execute adds all child commands to the root command and sets flags appropriately.
42
// This is called by main.main(). It only needs to happen once to the rootCmd.
43
func Execute() {
44
if err := rootCmd.Execute(); err != nil {
45
fmt.Println(err)
46
os.Exit(1)
47
}
48
}
49
50
func init() {
51
rootCmd.PersistentFlags().IntVar(&registryFacadePort, "registry-facade-port", 31750, "registry-facade node port")
52
rootCmd.PersistentFlags().IntVar(&wsdaemonPort, "ws-daemon-port", 8080, "ws-daemon service port")
53
rootCmd.PersistentFlags().StringVar(&namespace, "namespace", "default", "Namespace where Gitpod components are running")
54
55
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
56
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
57
58
}
59
60