Skip to content

Commit 49045a2

Browse files
authored
Merge pull request #81 from metal3d/develop
Cleanup, re-factorization and allow the use of a katenary.yaml file. Fixing a wrapping string problem. Move the label management in a package.
2 parents 315f5da + af8dabb commit 49045a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+411
-617
lines changed

.gitignore

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
.venv
21
dist/*
3-
.cache/*
4-
chart/*
5-
*.yaml
6-
*.yml
7-
!.markdownlint.yaml
8-
!generator/*.yaml
9-
doc/venv/*
10-
!doc/mkdocs.yaml
11-
!.readthedocs.yaml
12-
./katenary
132
*.env
14-
docker-compose*
15-
!examples/**/docker-compose*
163
.credentials
174
release.id
18-
configs/
195
cover*
206
.sq
21-
./katenary
227
.aider*
238
.python_history
249
.bash_history
25-
katenary
10+
11+
.cache/
12+
.aider/
13+
.config/
14+
*/venv
15+
16+
# local binary
17+
./katenary
18+
19+
# will be treated later
20+
/examples/*

.markdownlint.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
default: true
33

44
MD013: # Line length
5-
line_length: 240
5+
line_length: 120
66

77
MD010: # Hard tabs
88
code_blocks: false
@@ -16,3 +16,6 @@ MD041: false
1616
# list indentation
1717
MD007:
1818
indent: 4
19+
20+
# no problem using several code blocks styles
21+
MD046: false

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ tests: test
169169
test:
170170
@echo -e "\033[1;33mTesting katenary $(VERSION)...\033[0m"
171171
go test -coverprofile=cover.out ./...
172+
$(MAKE) cover
173+
174+
cover:
172175
go tool cover -func=cover.out | grep "total:"
173176
go tool cover -html=cover.out -o cover.html
174177
if [ "$(BROWSER)" = "xdg-open" ]; then

cmd/katenary/main.go

+22-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package main
77
import (
88
"fmt"
99
"katenary/generator"
10+
"katenary/generator/katenaryfile"
11+
"katenary/generator/labels"
1012
"katenary/utils"
1113
"os"
1214
"strings"
@@ -43,6 +45,7 @@ func buildRootCmd() *cobra.Command {
4345
generateConvertCommand(),
4446
generateHashComposefilesCommand(),
4547
generateLabelHelpCommand(),
48+
generateSchemaCommand(),
4649
)
4750

4851
return rootCmd
@@ -245,31 +248,31 @@ func generateLabelHelpCommand() *cobra.Command {
245248
If no label is specified, the help for all labels is printed.
246249
If a label is specified, the help for this label is printed.
247250
248-
The name of the label must be specified without the prefix ` + generator.Prefix() + `.
251+
The name of the label must be specified without the prefix ` + labels.Prefix() + `.
249252
250253
e.g.
251254
kanetary help-labels
252255
katenary help-labels ingress
253256
katenary help-labels map-env
254257
`,
255-
ValidArgs: generator.GetLabelNames(),
258+
ValidArgs: labels.GetLabelNames(),
256259
Run: func(cmd *cobra.Command, args []string) {
257260
if len(args) > 0 {
258-
fmt.Println(generator.GetLabelHelpFor(args[0], markdown))
261+
fmt.Println(labels.GetLabelHelpFor(args[0], markdown))
259262
return
260263
}
261264
if all {
262265
// show the help for all labels
263-
l := len(generator.GetLabelNames())
264-
for i, label := range generator.GetLabelNames() {
265-
fmt.Println(generator.GetLabelHelpFor(label, markdown))
266+
l := len(labels.GetLabelNames())
267+
for i, label := range labels.GetLabelNames() {
268+
fmt.Println(labels.GetLabelHelpFor(label, markdown))
266269
if !markdown && i < l-1 {
267270
fmt.Println(strings.Repeat("-", 80))
268271
}
269272
}
270273
return
271274
}
272-
fmt.Println(generator.GetLabelHelp(markdown))
275+
fmt.Println(labels.GetLabelHelp(markdown))
273276
},
274277
}
275278

@@ -298,3 +301,15 @@ If no composefile is specified, the hash of all composefiles is printed.`,
298301
}
299302
return cmd
300303
}
304+
305+
func generateSchemaCommand() *cobra.Command {
306+
cmd := &cobra.Command{
307+
Use: "schema",
308+
Short: "Print the schema of the katenary file",
309+
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.",
310+
Run: func(cmd *cobra.Command, args []string) {
311+
fmt.Println(katenaryfile.GenerateSchema())
312+
},
313+
}
314+
return cmd
315+
}

cmd/katenary/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func TestBuildCommand(t *testing.T) {
1010
if rootCmd.Use != "katenary" {
1111
t.Errorf("Expected rootCmd.Use to be katenary, got %s", rootCmd.Use)
1212
}
13-
numCommands := 5
13+
numCommands := 6
1414
if len(rootCmd.Commands()) != numCommands {
1515
t.Errorf("Expected %d command, got %d", numCommands, len(rootCmd.Commands()))
1616
}

examples/cronjobs/chart/README.md

-49
This file was deleted.

examples/cronjobs/chart/templates/NOTES.txt

-27
This file was deleted.

examples/cronjobs/chart/templates/_helpers.tpl

-36
This file was deleted.

examples/multidir/chart/README.md

-37
This file was deleted.

examples/multidir/chart/templates/NOTES.txt

-27
This file was deleted.

examples/multidir/chart/templates/_helpers.tpl

-36
This file was deleted.

examples/multidir/conf/example1.conf

-1
This file was deleted.

examples/multidir/conf/otherdir/example.conf

-2
This file was deleted.

0 commit comments

Comments
 (0)