MCPcopy Create free account
hub / github.com/compozy/agh / newConfigValidateCommandNamed

Function newConfigValidateCommandNamed

internal/cli/config.go:615–684  ·  view source on GitHub ↗
(deps commandDeps, name string)

Source from the content-addressed store, hash-verified

613}
614
615func newConfigValidateCommandNamed(deps commandDeps, name string) *cobra.Command {
616 var workspaceRoot string
617 var repairEnv bool
618 cmd := &cobra.Command{
619 Use: name,
620 Short: "Validate AGH configuration",
621 Args: cobra.NoArgs,
622 RunE: func(cmd *cobra.Command, _ []string) error {
623 workspace, err := resolveOptionalConfigWorkspaceRoot(workspaceRoot)
624 if err != nil {
625 return err
626 }
627 homeWorkspace := workspace
628 if homeWorkspace == "" {
629 homeWorkspace, err = currentWorkingDirectory(deps)
630 if err != nil {
631 return err
632 }
633 }
634 homePaths, err := deps.resolveHomeForWorkspace(homeWorkspace)
635 if err != nil {
636 return err
637 }
638 var dotenvReport *aghconfig.DotEnvRepairReport
639 if repairEnv {
640 if workspace == "" {
641 workspace, err = currentWorkingDirectory(deps)
642 if err != nil {
643 return err
644 }
645 }
646 report, err := aghconfig.RepairDotEnvFile(aghconfig.WorkspaceDotEnvFile(workspace))
647 dotenvReport = &report
648 if err != nil {
649 return err
650 }
651 }
652 loadOptions := []aghconfig.LoadOption{}
653 if workspace != "" {
654 loadOptions = append(loadOptions, aghconfig.WithWorkspaceRoot(workspace))
655 }
656 if _, err := aghconfig.LoadForHome(homePaths, loadOptions...); err != nil {
657 record := configValidateRecord{
658 Status: configInvalidKey,
659 Scope: scopeForWorkspace(workspace),
660 WorkspaceRoot: workspace,
661 ConfigFile: homePaths.ConfigFile,
662 Redacted: true,
663 Errors: configValidationErrors(err),
664 DotEnv: dotenvReport,
665 }
666 if writeErr := writeCommandOutput(cmd, configValidateBundle(record)); writeErr != nil {
667 return writeErr
668 }
669 return configValidationFailedError{err: err}
670 }
671 return writeCommandOutput(cmd, configValidateBundle(configValidateRecord{
672 Status: configValidKey,

Callers 2

newConfigValidateCommandFunction · 0.85
newConfigCheckCommandFunction · 0.85

Calls 7

currentWorkingDirectoryFunction · 0.85
appendFunction · 0.85
scopeForWorkspaceFunction · 0.85
configValidationErrorsFunction · 0.85
writeCommandOutputFunction · 0.85
configValidateBundleFunction · 0.85

Tested by

no test coverage detected