Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add katenary schema, cleanup and refactorization #81

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
.venv
dist/*
.cache/*
chart/*
*.yaml
*.yml
!.markdownlint.yaml
!generator/*.yaml
doc/venv/*
!doc/mkdocs.yaml
!.readthedocs.yaml
./katenary
*.env
docker-compose*
!examples/**/docker-compose*
.credentials
release.id
configs/
cover*
.sq
./katenary
.aider*
.python_history
.bash_history
katenary

.cache/
.aider/
.config/
*/venv

# local binary
./katenary

# will be treated later
/examples/*
5 changes: 4 additions & 1 deletion .markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
default: true

MD013: # Line length
line_length: 240
line_length: 120

MD010: # Hard tabs
code_blocks: false
Expand All @@ -16,3 +16,6 @@ MD041: false
# list indentation
MD007:
indent: 4

# no problem using several code blocks styles
MD046: false
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ tests: test
test:
@echo -e "\033[1;33mTesting katenary $(VERSION)...\033[0m"
go test -coverprofile=cover.out ./...
$(MAKE) cover

cover:
go tool cover -func=cover.out | grep "total:"
go tool cover -html=cover.out -o cover.html
if [ "$(BROWSER)" = "xdg-open" ]; then
Expand Down
29 changes: 22 additions & 7 deletions cmd/katenary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package main
import (
"fmt"
"katenary/generator"
"katenary/generator/katenaryfile"
"katenary/generator/labels"
"katenary/utils"
"os"
"strings"
Expand Down Expand Up @@ -43,6 +45,7 @@ func buildRootCmd() *cobra.Command {
generateConvertCommand(),
generateHashComposefilesCommand(),
generateLabelHelpCommand(),
generateSchemaCommand(),
)

return rootCmd
Expand Down Expand Up @@ -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))
},
}

Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion cmd/katenary/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
49 changes: 0 additions & 49 deletions examples/cronjobs/chart/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions examples/cronjobs/chart/templates/NOTES.txt

This file was deleted.

36 changes: 0 additions & 36 deletions examples/cronjobs/chart/templates/_helpers.tpl

This file was deleted.

37 changes: 0 additions & 37 deletions examples/multidir/chart/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions examples/multidir/chart/templates/NOTES.txt

This file was deleted.

36 changes: 0 additions & 36 deletions examples/multidir/chart/templates/_helpers.tpl

This file was deleted.

1 change: 0 additions & 1 deletion examples/multidir/conf/example1.conf

This file was deleted.

2 changes: 0 additions & 2 deletions examples/multidir/conf/otherdir/example.conf

This file was deleted.

Loading