Skip to content

Commit

Permalink
Merge pull request #275 from shalb/validate
Browse files Browse the repository at this point in the history
validate command
  • Loading branch information
romanprog authored Jul 26, 2024
2 parents 41ae298 + 21efa31 commit bf25baa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
16 changes: 8 additions & 8 deletions internal/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ func (b *Backend) Configure() error {
}

ctx := context.TODO()
_, awsConfig, diags := awsbase.GetAwsConfig(ctx, cfg)
_, awsConfig, _ := awsbase.GetAwsConfig(ctx, cfg)

if diags.HasError() {
diagError := fmt.Sprintln("s3 configuration diagnostics returns errors:")
for _, diag := range diags {
diagError = fmt.Sprintf("%s\nSummary: %s\nDetails: %s", diagError, diag.Summary(), diag.Detail())
}
return fmt.Errorf(diagError)
}
// if diags.HasError() {
// diagError := "s3 configuration diagnostics returns errors:"
// for _, diag := range diags {
// diagError = fmt.Sprintf("%s\nSummary: %s\nDetails: %s", diagError, diag.Summary(), diag.Detail())
// }
// return fmt.Errorf(diagError)
// }

b.s3Client = s3.NewFromConfig(awsConfig,
func(o *s3.Options) {
Expand Down
7 changes: 5 additions & 2 deletions internal/cmd/cdev/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/apex/log"
"github.com/gookit/color"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/internal/project/ui"
Expand All @@ -20,24 +21,26 @@ var listAllTemplates bool

func init() {
rootCmd.AddCommand(projectCmd)
projectCmd.AddCommand(projectLs)
projectCmd.AddCommand(projectInfo)
projectCmd.AddCommand(projectCreate)
projectCreate.Flags().BoolVar(&config.Global.Interactive, "interactive", false, "Use interactive mode for project generation")
projectCreate.Flags().BoolVar(&listAllTemplates, "list-templates", false, "Show all available templates for project generation")
}

// projectsCmd represents the plan command
var projectLs = &cobra.Command{
var projectInfo = &cobra.Command{
Use: "info",
Short: "Shows detailed information about the current project, such as the number of units and their types. Number of stacks, etc",
Run: func(cmd *cobra.Command, args []string) {
config.Global.IgnoreState = true
p, err := project.LoadProjectFull()
if err != nil {
log.Errorf("Project configuration error: %v", err.Error())
return
}
log.Info("Project info:")
p.PrintInfo()
log.Infof("Project configuration check: %v", color.Style{color.FgGreen, color.OpBold}.Sprintf("valid"))
},
}

Expand Down
27 changes: 27 additions & 0 deletions internal/cmd/cdev/validate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cdev

import (
"github.com/apex/log"
"github.com/gookit/color"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/spf13/cobra"
)

// projectsCmd represents the plan command
var projectValidate = &cobra.Command{
Use: "validate",
Short: "Validates the configuration files in a project directory, referring only to the configuration and not accessing remote state bucket",
Run: func(cmd *cobra.Command, args []string) {
config.Global.IgnoreState = true
_, err := project.LoadProjectFull()
if err != nil {
log.Fatalf("Project configuration check: %v\n%v", color.Style{color.FgGreen, color.OpBold}.Sprintf("fail"), err.Error())
}
log.Infof("Project configuration check: %v", color.Style{color.FgGreen, color.OpBold}.Sprintf("valid"))
},
}

func init() {
rootCmd.AddCommand(projectValidate)
}

0 comments on commit bf25baa

Please sign in to comment.