mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-05 09:35:24 -05:00
68092f27dd
* Move `file`, `ssh` and `user` packages to internal * Rename `SSHKey` to `(ssh.)UserKey` * Rename KeyValue / Publickey to PublicKey * Rename SSH key file from "debugd" to "ssh-keys" * Add CreateSSHUsers function to Core * Call CreateSSHUsers users on first control-plane node, when defined in config Tests: * Make StubUserCreator add entries to /etc/passwd * Add NewLinuxUserManagerFake for unit tests * Add unit tests & adjust existing ones to changes
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"io/fs"
|
|
|
|
"github.com/edgelesssys/constellation/debugd/debugd/deploy"
|
|
"github.com/edgelesssys/constellation/internal/deploy/ssh"
|
|
"github.com/edgelesssys/constellation/internal/file"
|
|
)
|
|
|
|
// CDBGConfig describes the constellation-cli config file.
|
|
type CDBGConfig struct {
|
|
ConstellationDebugConfig ConstellationDebugdConfig `yaml:"cdbg"`
|
|
}
|
|
|
|
// ConstellationDebugdConfig is the cdbg specific configuration.
|
|
type ConstellationDebugdConfig struct {
|
|
AuthorizedKeys []ssh.UserKey `yaml:"authorizedKeys"`
|
|
CoordinatorPath string `yaml:"coordinatorPath"`
|
|
SystemdUnits []deploy.SystemdUnit `yaml:"systemdUnits,omitempty"`
|
|
}
|
|
|
|
// FromFile reads a debug configuration.
|
|
func FromFile(fileHandler file.Handler, name string) (*CDBGConfig, error) {
|
|
conf := &CDBGConfig{}
|
|
if err := fileHandler.ReadYAML(name, conf); err != nil {
|
|
if errors.Is(err, fs.ErrNotExist) {
|
|
return nil, fmt.Errorf("unable to find %s - consult the README on how to setup cdbg", name)
|
|
}
|
|
return nil, fmt.Errorf("could not load config from file %s: %w", name, err)
|
|
}
|
|
return conf, nil
|
|
}
|