Path: blob/main/components/ws-daemon/cmd/validate-config.go
2498 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"encoding/json"8"fmt"9"io"10"os"1112"github.com/spf13/cobra"1314"github.com/gitpod-io/gitpod/common-go/log"15"github.com/gitpod-io/gitpod/ws-daemon/pkg/config"16)1718// can be used with the helm-template like so:19// helm template ../../chart/ | sed -n '/ws-daemon-configmap.yaml/,$p' | sed '/---/q' | yq r - 'data[config.json]' | go run main.go validate-config2021var validateConfigCmd = &cobra.Command{22Use: "validate-config",23Short: "reads a ws-daemon configuration from STDIN and validates it",24Run: func(cmd *cobra.Command, args []string) {25ctnt, err := io.ReadAll(os.Stdin)26if err != nil {27log.WithError(err).Fatal("cannot read configuration")28}2930var cfg config.Config31err = json.Unmarshal(ctnt, &cfg)32if err != nil {33fmt.Println(string(ctnt))34log.WithError(err).Fatal("cannot unmarshal configuration")35}3637enc := json.NewEncoder(os.Stdout)38enc.SetIndent("", " ")39_ = enc.Encode(cfg)40},41}4243func init() {44rootCmd.AddCommand(validateConfigCmd)45}464748