chore(refacto): fix secret and use katenary schema

- add possibility to use a katenary.yaml file to setup values
- fix secret generation
This commit is contained in:
2024-11-18 17:12:12 +01:00
parent 14877fbfa3
commit cc1019b5a8
39 changed files with 375 additions and 155 deletions

View File

@@ -7,6 +7,8 @@ package main
import (
"fmt"
"katenary/generator"
"katenary/generator/katenaryfile"
"katenary/generator/labels"
"katenary/utils"
"os"
"strings"
@@ -43,6 +45,7 @@ func buildRootCmd() *cobra.Command {
generateConvertCommand(),
generateHashComposefilesCommand(),
generateLabelHelpCommand(),
generateSchemaCommand(),
)
return rootCmd
@@ -245,31 +248,31 @@ func generateLabelHelpCommand() *cobra.Command {
If no label is specified, the help for all labels is printed.
If a label is specified, the help for this label is printed.
The name of the label must be specified without the prefix ` + generator.Prefix() + `.
The name of the label must be specified without the prefix ` + labels.Prefix() + `.
e.g.
kanetary help-labels
katenary help-labels ingress
katenary help-labels map-env
`,
ValidArgs: generator.GetLabelNames(),
ValidArgs: labels.GetLabelNames(),
Run: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
fmt.Println(generator.GetLabelHelpFor(args[0], markdown))
fmt.Println(labels.GetLabelHelpFor(args[0], markdown))
return
}
if all {
// show the help for all labels
l := len(generator.GetLabelNames())
for i, label := range generator.GetLabelNames() {
fmt.Println(generator.GetLabelHelpFor(label, markdown))
l := len(labels.GetLabelNames())
for i, label := range labels.GetLabelNames() {
fmt.Println(labels.GetLabelHelpFor(label, markdown))
if !markdown && i < l-1 {
fmt.Println(strings.Repeat("-", 80))
}
}
return
}
fmt.Println(generator.GetLabelHelp(markdown))
fmt.Println(labels.GetLabelHelp(markdown))
},
}
@@ -298,3 +301,15 @@ If no composefile is specified, the hash of all composefiles is printed.`,
}
return cmd
}
func generateSchemaCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "schema",
Short: "Print the schema of the katenary file",
Long: "Generate a schama for katenary.yaml file that can be used to validate the file or to use with yaml LSP to complete and check your configuration.",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(katenaryfile.GenerateSchema())
},
}
return cmd
}

View File

@@ -10,7 +10,7 @@ func TestBuildCommand(t *testing.T) {
if rootCmd.Use != "katenary" {
t.Errorf("Expected rootCmd.Use to be katenary, got %s", rootCmd.Use)
}
numCommands := 5
numCommands := 6
if len(rootCmd.Commands()) != numCommands {
t.Errorf("Expected %d command, got %d", numCommands, len(rootCmd.Commands()))
}