Files
Dimitri Herzog 63f8d9a91e build: upgrade Go to 1.26.2 and golangci-lint to v2.12.2 (#2062)
- Update go.mod to Go 1.26.2
- Bump golangci-lint from v2.11.3 to v2.12.2 in Makefile
- Rename gomodguard → gomodguard_v2 in .golangci.yml (v2 linter name)
- Extract repeated string literals to constants to satisfy the stricter
  goconst checks introduced by the new linter version (19 issues fixed)
2026-05-19 13:15:03 +02:00

41 lines
769 B
Go

package cmd
import (
"errors"
"os"
"github.com/0xERR0R/blocky/log"
"github.com/spf13/cobra"
)
const validateCmdName = "validate"
// NewValidateCommand creates new command instance
func NewValidateCommand() *cobra.Command {
return &cobra.Command{
Use: validateCmdName,
Args: cobra.NoArgs,
Short: "Validates the configuration",
RunE: validateConfiguration,
}
}
func validateConfiguration(_ *cobra.Command, _ []string) error {
log.Log().Infof("Validating configuration file: %s", configPath)
_, err := os.Stat(configPath)
if err != nil && errors.Is(err, os.ErrNotExist) {
return errors.New("configuration path does not exist")
}
err = initConfig()
if err != nil {
return err
}
log.Log().Info("Configuration is valid")
return nil
}