Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Commit 9591ac7

Browse files
committed
feat(cli): validate cli and module configurations
1 parent 4d25f16 commit 9591ac7

File tree

13 files changed

+156
-65
lines changed

13 files changed

+156
-65
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
bin
2-
cli
2+
./cli
33
.stackhead-cli.yml

commands/cli/cli.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cli
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
func GetCommands() *cobra.Command {
8+
command := &cobra.Command{
9+
Use: "cli",
10+
Short: "StackHead CLI commands",
11+
}
12+
command.AddCommand(Validate)
13+
return command
14+
}

commands/cli/validate.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cli
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"github.com/getstackhead/stackhead/cli/routines"
7+
)
8+
9+
// Validate is a command object for Cobra that provides the validate command
10+
var Validate = &cobra.Command{
11+
Use: "validate [path to StackHead CLI configuration file]",
12+
Example: "validate ./stackhead-module.yml",
13+
Short: "Validate a StackHead module file",
14+
Long: `validate is used to make sure your StackHead CLI configuration file meets the required syntax.`,
15+
Args: cobra.ExactArgs(1),
16+
Run: func(cmd *cobra.Command, args []string) {
17+
routines.Validate(args[0], "cli-config.schema.json")
18+
},
19+
}

commands/module/module.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package module
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
func GetCommands() *cobra.Command {
8+
command := &cobra.Command{
9+
Use: "module",
10+
Short: "StackHead module commands",
11+
}
12+
command.AddCommand(Validate)
13+
return command
14+
}

commands/module/validate.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package module
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"github.com/getstackhead/stackhead/cli/routines"
7+
)
8+
9+
// Validate is a command object for Cobra that provides the validate command
10+
var Validate = &cobra.Command{
11+
Use: "validate [path to StackHead module file]",
12+
Example: "validate ./stackhead-module.yml",
13+
Short: "Validate a StackHead module file",
14+
Long: `validate is used to make sure your StackHead module file meets the required syntax.`,
15+
Args: cobra.ExactArgs(1),
16+
Run: func(cmd *cobra.Command, args []string) {
17+
routines.Validate(args[0], "module-config.schema.json")
18+
},
19+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package commands
1+
package project
22

33
import (
44
"fmt"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package commands
1+
package project
22

33
import (
44
"fmt"

commands/project/project.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package project
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
func GetCommands() *cobra.Command {
8+
command := &cobra.Command{
9+
Use: "project",
10+
Short: "Project commands",
11+
}
12+
command.AddCommand(DeployApplication, DestroyApplication, SetupServer, Validate)
13+
return command
14+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package commands
1+
package project
22

33
import (
44
"fmt"

commands/project/validate.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package project
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"github.com/getstackhead/stackhead/cli/routines"
7+
)
8+
9+
// Validate is a command object for Cobra that provides the validate command
10+
var Validate = &cobra.Command{
11+
Use: "validate [path to project definition file]",
12+
Example: "validate ./my-project-definition.yml",
13+
Short: "Validate a project definition file",
14+
Long: `validate is used to make sure your project definition file meets the StackHead project definition syntax.`,
15+
Args: cobra.ExactArgs(1),
16+
Run: func(cmd *cobra.Command, args []string) {
17+
routines.Validate(args[0], "project-definition.schema.json")
18+
},
19+
}

0 commit comments

Comments
 (0)