mirror of
https://github.com/0xERR0R/blocky.git
synced 2026-10-12 02:01:13 +00:00
- 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)
41 lines
769 B
Go
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
|
|
}
|