Skip to content

Commit 8aaea72

Browse files
committed
fix: Raise error if config is there
1 parent 39f5e0c commit 8aaea72

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

agent/cli.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,10 @@ var startCmd = &cobra.Command{
6565
var setupCmd = &cobra.Command{
6666
Use: "setup",
6767
Run: func(cmd *cobra.Command, args []string) {
68-
existingConfig, err := GetConfig()
68+
_, err := GetConfig()
6969
if err == nil {
70-
fmt.Println(existingConfig)
71-
if existingConfig.WireguardConfig.PrivateKey != "" {
72-
cmd.Println("Sorry, you can't change any config")
73-
return
74-
}
70+
cmd.Println("Sorry, you can't change any config")
71+
return
7572
}
7673

7774
wireguard_cidr, err := strconv.Atoi(cmd.Flag("wireguard-cidr").Value.String())

agent/config.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,7 @@ type DockerNetworkConfig struct {
2828
func GetConfig() (*AgentConfig, error) {
2929
var config AgentConfig
3030
if err := rDB.First(&config).Error; err != nil {
31-
if errors.Is(err, gorm.ErrRecordNotFound) {
32-
return &AgentConfig{
33-
WireguardConfig: WireguardConfig{},
34-
DockerNetwork: DockerNetworkConfig{},
35-
}, nil
36-
} else {
37-
return nil, errors.New("error getting config")
38-
}
31+
return nil, errors.New("error getting config")
3932
}
4033
return &config, nil
4134
}

0 commit comments

Comments
 (0)