Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ee/agent-smith/cmd/config-schema.go
2500 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
"encoding/json"
9
"fmt"
10
"github.com/gitpod-io/gitpod/agent-smith/pkg/config"
11
12
"github.com/alecthomas/jsonschema"
13
"github.com/gitpod-io/gitpod/common-go/log"
14
"github.com/spf13/cobra"
15
)
16
17
// configSchemaCmd represents the configSchema command
18
var configSchemaCmd = &cobra.Command{
19
Use: "config-schema",
20
Short: "Generates the JSON schema validating the configuration",
21
Run: func(cmd *cobra.Command, args []string) {
22
schema := jsonschema.Reflect(&config.ServiceConfig{})
23
schema.Title = "agent-smith config schema - generated using agent-smith config-schema"
24
out, err := json.MarshalIndent(schema, "", " ")
25
if err != nil {
26
log.WithError(err).Fatal()
27
return
28
}
29
fmt.Print(string(out))
30
},
31
}
32
33
func init() {
34
rootCmd.AddCommand(configSchemaCmd)
35
}
36
37