mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-31 11:08:50 -04:00
AB#2117 cli: validate config (#170)
* AB#2117 cli: validate config * update hack/go.mod
This commit is contained in:
parent
45bf9f15fb
commit
2ba3c153de
12 changed files with 312 additions and 58 deletions
|
@ -75,7 +75,17 @@ func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, ser
|
|||
return err
|
||||
}
|
||||
|
||||
config, err := config.FromFile(fileHandler, flags.configPath)
|
||||
var stat state.ConstellationState
|
||||
err = fileHandler.ReadJSON(constants.StateFilename, &stat)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return fmt.Errorf("nothing to initialize: %w", err)
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
provider := cloudprovider.FromString(stat.CloudProvider)
|
||||
|
||||
config, err := readConfig(cmd.OutOrStdout(), fileHandler, flags.configPath, provider)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -88,17 +98,7 @@ func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, ser
|
|||
})
|
||||
}
|
||||
|
||||
protoSSHUserKeys := ssh.ToProtoSlice(sshUsers)
|
||||
|
||||
var stat state.ConstellationState
|
||||
err = fileHandler.ReadJSON(constants.StateFilename, &stat)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return fmt.Errorf("nothing to initialize: %w", err)
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
validators, err := cloudcmd.NewValidators(cloudprovider.FromString(stat.CloudProvider), config)
|
||||
validators, err := cloudcmd.NewValidators(provider, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, ser
|
|||
coordinatorPrivIPs: coordinators.PrivateIPs()[1:],
|
||||
autoscalingNodeGroups: autoscalingNodeGroups,
|
||||
cloudServiceAccountURI: serviceAccount,
|
||||
sshUserKeys: protoSSHUserKeys,
|
||||
sshUserKeys: ssh.ToProtoSlice(sshUsers),
|
||||
}
|
||||
result, err := activate(ctx, cmd, protCl, input, validators.V())
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue