mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-11-11 16:25:05 -05:00
AB#2064 Feat/config/dev config to config (#139)
Renamed dev-config to config, additionally changed cdbg config to yaml.
This commit is contained in:
parent
fde7304d78
commit
83857b142c
20 changed files with 175 additions and 189 deletions
|
|
@ -28,20 +28,20 @@ var deployCmd = &cobra.Command{
|
|||
Use: "deploy",
|
||||
Short: "Deploys a self-compiled coordinator binary and SSH keys on the current constellation",
|
||||
Long: `Deploys a self-compiled coordinator binary and SSH keys on the current constellation.
|
||||
Uses dev-config provided by --dev-config and reads constellation config from its default location.
|
||||
Uses config provided by --config and reads constellation config from its default location.
|
||||
If required, you can override the IP addresses that are used for a deployment by specifying "--ips" and a list of IP addresses.
|
||||
Specifying --coordinator will upload the coordinator from the specified path.`,
|
||||
RunE: runDeploy,
|
||||
Example: "cdbg deploy --dev-config /path/to/dev-config\ncdbg deploy --coordinator /path/to/coordinator --ips 192.0.2.1,192.0.2.2,192.0.2.3 --dev-config /path/to/dev-config",
|
||||
Example: "cdbg deploy --config /path/to/config\ncdbg deploy --coordinator /path/to/coordinator --ips 192.0.2.1,192.0.2.2,192.0.2.3 --config /path/to/config",
|
||||
}
|
||||
|
||||
func runDeploy(cmd *cobra.Command, args []string) error {
|
||||
devConfigName, err := cmd.Flags().GetString("dev-config")
|
||||
configName, err := cmd.Flags().GetString("config")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fileHandler := file.NewHandler(afero.NewOsFs())
|
||||
config, err := config.FromFile(fileHandler, devConfigName)
|
||||
config, err := config.FromFile(fileHandler, configName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ func init() {
|
|||
rootCmd.AddCommand(deployCmd)
|
||||
|
||||
deployCmd.Flags().StringSlice("ips", nil, "override the ips that the coordinator will be uploaded to (defaults to ips from constellation config)")
|
||||
deployCmd.Flags().String("coordinator", "", "override the path to the coordinator binary uploaded to instances (defaults to path set in dev-config)")
|
||||
deployCmd.Flags().String("coordinator", "", "override the path to the coordinator binary uploaded to instances (defaults to path set in config)")
|
||||
}
|
||||
|
||||
type fileToStreamReader interface {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package cmd
|
|||
import (
|
||||
"os"
|
||||
|
||||
"github.com/edgelesssys/constellation/internal/constants"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
|
@ -21,6 +22,5 @@ func Execute() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().String("dev-config", "", "debugd config file (required)")
|
||||
_ = rootCmd.MarkPersistentFlagRequired("dev-config")
|
||||
rootCmd.PersistentFlags().String("config", constants.ConfigFilename, "debugd config file")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ import (
|
|||
|
||||
// CDBGConfig describes the constellation-cli config file and extends it with a new field "cdbg".
|
||||
type CDBGConfig struct {
|
||||
ConstellationDebugConfig ConstellationDebugdConfig `json:"cdbg"`
|
||||
configc.Config ``
|
||||
ConstellationDebugConfig ConstellationDebugdConfig `yaml:"cdbg"`
|
||||
configc.Config
|
||||
}
|
||||
|
||||
// ConstellationDebugdConfig is the cdbg specific configuration.
|
||||
type ConstellationDebugdConfig struct {
|
||||
AuthorizedKeys []ssh.SSHKey `json:"authorized_keys"`
|
||||
CoordinatorPath string `json:"coordinator_path"`
|
||||
SystemdUnits []deploy.SystemdUnit `json:"systemd_units,omitempty"`
|
||||
AuthorizedKeys []ssh.SSHKey `yaml:"authorizedKeys"`
|
||||
CoordinatorPath string `yaml:"coordinatorPath"`
|
||||
SystemdUnits []deploy.SystemdUnit `yaml:"systemdUnits,omitempty"`
|
||||
}
|
||||
|
||||
// Default returns a struct with the default config.
|
||||
|
|
@ -42,7 +42,7 @@ func FromFile(fileHandler file.Handler, name string) (*CDBGConfig, error) {
|
|||
return conf, nil
|
||||
}
|
||||
|
||||
if err := fileHandler.ReadJSON(name, conf); err != nil {
|
||||
if err := fileHandler.ReadYAML(name, conf); err != nil {
|
||||
return nil, fmt.Errorf("could not load config from file %s: %w", name, err)
|
||||
}
|
||||
return conf, nil
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ type ServiceManagerRequest struct {
|
|||
|
||||
// SystemdUnit describes a systemd service file including the unit name and contents.
|
||||
type SystemdUnit struct {
|
||||
Name string `json:"name"`
|
||||
Contents string `json:"contents"`
|
||||
Name string `yaml:"name"`
|
||||
Contents string `yaml:"contents"`
|
||||
}
|
||||
|
||||
// ServiceManager receives ServiceManagerRequests and units via channels and performs the requests / creates the unit files.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ package ssh
|
|||
|
||||
// SSHKey describes a public ssh key.
|
||||
type SSHKey struct {
|
||||
Username string `json:"user"`
|
||||
KeyValue string `json:"pubkey"`
|
||||
Username string `yaml:"user"`
|
||||
KeyValue string `yaml:"pubkey"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue