Skip to content

Commit bf25baa

Browse files
authored
Merge pull request #275 from shalb/validate
validate command
2 parents 41ae298 + 21efa31 commit bf25baa

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

internal/backend/s3/s3.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ func (b *Backend) Configure() error {
127127
}
128128

129129
ctx := context.TODO()
130-
_, awsConfig, diags := awsbase.GetAwsConfig(ctx, cfg)
130+
_, awsConfig, _ := awsbase.GetAwsConfig(ctx, cfg)
131131

132-
if diags.HasError() {
133-
diagError := fmt.Sprintln("s3 configuration diagnostics returns errors:")
134-
for _, diag := range diags {
135-
diagError = fmt.Sprintf("%s\nSummary: %s\nDetails: %s", diagError, diag.Summary(), diag.Detail())
136-
}
137-
return fmt.Errorf(diagError)
138-
}
132+
// if diags.HasError() {
133+
// diagError := "s3 configuration diagnostics returns errors:"
134+
// for _, diag := range diags {
135+
// diagError = fmt.Sprintf("%s\nSummary: %s\nDetails: %s", diagError, diag.Summary(), diag.Detail())
136+
// }
137+
// return fmt.Errorf(diagError)
138+
// }
139139

140140
b.s3Client = s3.NewFromConfig(awsConfig,
141141
func(o *s3.Options) {

internal/cmd/cdev/project.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66

77
"github.com/apex/log"
8+
"github.com/gookit/color"
89
"github.com/shalb/cluster.dev/internal/config"
910
"github.com/shalb/cluster.dev/internal/project"
1011
"github.com/shalb/cluster.dev/internal/project/ui"
@@ -20,24 +21,26 @@ var listAllTemplates bool
2021

2122
func init() {
2223
rootCmd.AddCommand(projectCmd)
23-
projectCmd.AddCommand(projectLs)
24+
projectCmd.AddCommand(projectInfo)
2425
projectCmd.AddCommand(projectCreate)
2526
projectCreate.Flags().BoolVar(&config.Global.Interactive, "interactive", false, "Use interactive mode for project generation")
2627
projectCreate.Flags().BoolVar(&listAllTemplates, "list-templates", false, "Show all available templates for project generation")
2728
}
2829

2930
// projectsCmd represents the plan command
30-
var projectLs = &cobra.Command{
31+
var projectInfo = &cobra.Command{
3132
Use: "info",
3233
Short: "Shows detailed information about the current project, such as the number of units and their types. Number of stacks, etc",
3334
Run: func(cmd *cobra.Command, args []string) {
35+
config.Global.IgnoreState = true
3436
p, err := project.LoadProjectFull()
3537
if err != nil {
3638
log.Errorf("Project configuration error: %v", err.Error())
3739
return
3840
}
3941
log.Info("Project info:")
4042
p.PrintInfo()
43+
log.Infof("Project configuration check: %v", color.Style{color.FgGreen, color.OpBold}.Sprintf("valid"))
4144
},
4245
}
4346

internal/cmd/cdev/validate.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package cdev
2+
3+
import (
4+
"github.com/apex/log"
5+
"github.com/gookit/color"
6+
"github.com/shalb/cluster.dev/internal/config"
7+
"github.com/shalb/cluster.dev/internal/project"
8+
"github.com/spf13/cobra"
9+
)
10+
11+
// projectsCmd represents the plan command
12+
var projectValidate = &cobra.Command{
13+
Use: "validate",
14+
Short: "Validates the configuration files in a project directory, referring only to the configuration and not accessing remote state bucket",
15+
Run: func(cmd *cobra.Command, args []string) {
16+
config.Global.IgnoreState = true
17+
_, err := project.LoadProjectFull()
18+
if err != nil {
19+
log.Fatalf("Project configuration check: %v\n%v", color.Style{color.FgGreen, color.OpBold}.Sprintf("fail"), err.Error())
20+
}
21+
log.Infof("Project configuration check: %v", color.Style{color.FgGreen, color.OpBold}.Sprintf("valid"))
22+
},
23+
}
24+
25+
func init() {
26+
rootCmd.AddCommand(projectValidate)
27+
}

0 commit comments

Comments
 (0)