Import config as config

This commit is contained in:
katexochen 2022-06-07 16:50:12 +02:00
parent 6a9419e89c
commit 87b9203110

View File

@ -4,14 +4,14 @@ import (
"errors" "errors"
cmdc "github.com/edgelesssys/constellation/cli/cmd" cmdc "github.com/edgelesssys/constellation/cli/cmd"
configc "github.com/edgelesssys/constellation/internal/config" "github.com/edgelesssys/constellation/internal/config"
"github.com/edgelesssys/constellation/internal/state" "github.com/edgelesssys/constellation/internal/state"
) )
// Code in this file is mostly copied from constellation-coordinator // Code in this file is mostly copied from constellation-coordinator
// TODO: import as package from coordinator once it is properly refactored // TODO: import as package from coordinator once it is properly refactored
func GetScalingGroupsFromConfig(stat state.ConstellationState, config *configc.Config) (coordinators, nodes cmdc.ScalingGroup, err error) { func GetScalingGroupsFromConfig(stat state.ConstellationState, config *config.Config) (coordinators, nodes cmdc.ScalingGroup, err error) {
switch { switch {
case len(stat.GCPCoordinators) != 0: case len(stat.GCPCoordinators) != 0:
return getGCPInstances(stat, config) return getGCPInstances(stat, config)
@ -24,7 +24,7 @@ func GetScalingGroupsFromConfig(stat state.ConstellationState, config *configc.C
} }
} }
func getGCPInstances(stat state.ConstellationState, config *configc.Config) (coordinators, nodes cmdc.ScalingGroup, err error) { func getGCPInstances(stat state.ConstellationState, config *config.Config) (coordinators, nodes cmdc.ScalingGroup, err error) {
coordinatorMap := stat.GCPCoordinators coordinatorMap := stat.GCPCoordinators
if len(coordinatorMap) == 0 { if len(coordinatorMap) == 0 {
return cmdc.ScalingGroup{}, cmdc.ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance") return cmdc.ScalingGroup{}, cmdc.ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance")
@ -55,7 +55,7 @@ func getGCPInstances(stat state.ConstellationState, config *configc.Config) (coo
return return
} }
func getAzureInstances(stat state.ConstellationState, _ *configc.Config) (coordinators, nodes cmdc.ScalingGroup, err error) { func getAzureInstances(stat state.ConstellationState, _ *config.Config) (coordinators, nodes cmdc.ScalingGroup, err error) {
coordinatorMap := stat.AzureCoordinators coordinatorMap := stat.AzureCoordinators
if len(coordinatorMap) == 0 { if len(coordinatorMap) == 0 {
return cmdc.ScalingGroup{}, cmdc.ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance") return cmdc.ScalingGroup{}, cmdc.ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance")
@ -84,7 +84,7 @@ func getAzureInstances(stat state.ConstellationState, _ *configc.Config) (coordi
return return
} }
func getQEMUInstances(stat state.ConstellationState, _ *configc.Config) (coordinators, nodes cmdc.ScalingGroup, err error) { func getQEMUInstances(stat state.ConstellationState, _ *config.Config) (coordinators, nodes cmdc.ScalingGroup, err error) {
coordinatorMap := stat.QEMUCoordinators coordinatorMap := stat.QEMUCoordinators
if len(coordinatorMap) == 0 { if len(coordinatorMap) == 0 {
return cmdc.ScalingGroup{}, cmdc.ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance") return cmdc.ScalingGroup{}, cmdc.ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance")