Path: blob/main/components/registry-facade/cmd/root.go
2496 views
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package cmd56import (7"fmt"8"os"910"github.com/spf13/cobra"1112"github.com/gitpod-io/gitpod/common-go/log"13"github.com/gitpod-io/gitpod/common-go/tracing"14)1516var (17// ServiceName is the name we use for tracing/logging18ServiceName = "registry-facade"19// Version of this service - set during build20Version = ""21)2223// rootCmd represents the base command when called without any subcommands24var rootCmd = &cobra.Command{25Use: "registry-facade",26Short: "This service acts as image registry augmenting images with workspace content and Theia",27Args: cobra.MinimumNArgs(1),28PersistentPreRun: func(cmd *cobra.Command, args []string) {29log.Init(ServiceName, Version, jsonLog, verbose)30},31}3233// Execute adds all child commands to the root command and sets flags appropriately.34// This is called by main.main(). It only needs to happen once to the rootCmd.35func Execute() {36closer := tracing.Init("registry-facade")37if closer != nil {38defer closer.Close()39}40if err := rootCmd.Execute(); err != nil {41fmt.Println(err)42os.Exit(1)43}44}4546func init() {47rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")48rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")49}505152