cli: fix and tweak config file wording

This commit is contained in:
Thomas Tendyck 2022-05-24 11:57:48 +02:00 committed by Thomas Tendyck
parent 9f0c751f1b
commit 42fc497477
5 changed files with 58 additions and 59 deletions

View File

@ -468,7 +468,7 @@ func getGCPInstances(stat state.ConstellationState, config *config.Config) (coor
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
nodes = ScalingGroup{ nodes = ScalingGroup{
Instances: nodeInstances, Instances: nodeInstances,
GroupID: gcp.AutoscalingNodeGroup(stat.GCPProject, stat.GCPZone, stat.GCPNodeInstanceGroup, config.AutoscalingNodeGroupsMin, config.AutoscalingNodeGroupsMax), GroupID: gcp.AutoscalingNodeGroup(stat.GCPProject, stat.GCPZone, stat.GCPNodeInstanceGroup, config.AutoscalingNodeGroupMin, config.AutoscalingNodeGroupMax),
} }
return return
@ -501,7 +501,7 @@ func getAzureInstances(stat state.ConstellationState, config *config.Config) (co
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
nodes = ScalingGroup{ nodes = ScalingGroup{
Instances: nodeInstances, Instances: nodeInstances,
GroupID: azure.AutoscalingNodeGroup(stat.AzureNodesScaleSet, config.AutoscalingNodeGroupsMin, config.AutoscalingNodeGroupsMax), GroupID: azure.AutoscalingNodeGroup(stat.AzureNodesScaleSet, config.AutoscalingNodeGroupMin, config.AutoscalingNodeGroupMax),
} }
return return
} }

View File

@ -87,7 +87,7 @@ func getGCPInstances(stat state.ConstellationState, config *configc.Config) (coo
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
nodes = cmdc.ScalingGroup{ nodes = cmdc.ScalingGroup{
Instances: nodeInstances, Instances: nodeInstances,
GroupID: gcp.AutoscalingNodeGroup(stat.GCPProject, stat.GCPZone, stat.GCPNodeInstanceGroup, config.AutoscalingNodeGroupsMin, config.AutoscalingNodeGroupsMax), GroupID: gcp.AutoscalingNodeGroup(stat.GCPProject, stat.GCPZone, stat.GCPNodeInstanceGroup, config.AutoscalingNodeGroupMin, config.AutoscalingNodeGroupMax),
} }
return return

View File

@ -27,16 +27,14 @@ type Config struct {
// Schema version of this configuration file. // Schema version of this configuration file.
Version string `yaml:"version" validate:"eq=v1"` Version string `yaml:"version" validate:"eq=v1"`
// description: | // description: |
// Minimum number of nodes in autoscaling group. // Minimum number of worker nodes in autoscaling group.
// worker nodes. AutoscalingNodeGroupMin int `yaml:"autoscalingNodeGroupMin" validate:"min=0"`
AutoscalingNodeGroupsMin int `yaml:"autoscalingNodeGroupsMin" validate:"min=0"`
// description: | // description: |
// Maximum number of nodes in autoscaling group. // Maximum number of worker nodes in autoscaling group.
// worker nodes. AutoscalingNodeGroupMax int `yaml:"autoscalingNodeGroupMax" validate:"gtefield=AutoscalingNodeGroupMin"`
AutoscalingNodeGroupsMax int `yaml:"autoscalingNodeGroupsMax" validate:"gtefield=AutoscalingNodeGroupsMin"`
// description: | // description: |
// Size (in GB) of data disk used for nodes. // Size (in GB) of a node's disk to store the non-volatile state.
StateDiskSizeGB int `yaml:"stateDisksizeGB" validate:"min=0"` StateDiskSizeGB int `yaml:"stateDiskSizeGB" validate:"min=0"`
// description: | // description: |
// Ingress firewall rules for node network. // Ingress firewall rules for node network.
IngressFirewall Firewall `yaml:"ingressFirewall,omitempty" validate:"dive"` IngressFirewall Firewall `yaml:"ingressFirewall,omitempty" validate:"dive"`
@ -55,7 +53,7 @@ type Config struct {
// }' // }'
EgressFirewall Firewall `yaml:"egressFirewall,omitempty" validate:"dive"` EgressFirewall Firewall `yaml:"egressFirewall,omitempty" validate:"dive"`
// description: | // description: |
// Supported cloud providers & their specific configurations. // Supported cloud providers and their specific configurations.
Provider ProviderConfig `yaml:"provider" validate:"dive"` Provider ProviderConfig `yaml:"provider" validate:"dive"`
// description: | // description: |
// Create SSH users on Constellation nodes. // Create SSH users on Constellation nodes.
@ -88,10 +86,10 @@ type FirewallRule struct {
// CIDR range for which this rule is applied. // CIDR range for which this rule is applied.
IPRange string `yaml:"iprange" validate:"required"` IPRange string `yaml:"iprange" validate:"required"`
// description: | // description: |
// Port of start port of a range. // Start port of a range.
FromPort int `yaml:"fromport" validate:"min=0,max=65535"` FromPort int `yaml:"fromport" validate:"min=0,max=65535"`
// description: | // description: |
// End port of a range, or 0 if a single port is given by FromPort. // End port of a range, or 0 if a single port is given by fromport.
ToPort int `yaml:"toport" validate:"omitempty,gtefield=FromPort,max=65535"` ToPort int `yaml:"toport" validate:"omitempty,gtefield=FromPort,max=65535"`
} }
@ -103,13 +101,13 @@ type Firewall []FirewallRule
type ProviderConfig struct { type ProviderConfig struct {
// description: | // description: |
// Configuration for Azure as provider. // Configuration for Azure as provider.
Azure *AzureConfig `yaml:"azureConfig,omitempty" validate:"omitempty,dive"` Azure *AzureConfig `yaml:"azure,omitempty" validate:"omitempty,dive"`
// description: | // description: |
// Configuration for Google Cloud as provider. // Configuration for Google Cloud as provider.
GCP *GCPConfig `yaml:"gcpConfig,omitempty" validate:"omitempty,dive"` GCP *GCPConfig `yaml:"gcp,omitempty" validate:"omitempty,dive"`
// description: | // description: |
// Configuration for QEMU as provider. // Configuration for QEMU as provider.
QEMU *QEMUConfig `yaml:"qemuConfig,omitempty" validate:"omitempty,dive"` QEMU *QEMUConfig `yaml:"qemu,omitempty" validate:"omitempty,dive"`
} }
// AzureConfig are Azure specific configuration values used by the CLI. // AzureConfig are Azure specific configuration values used by the CLI.
@ -131,7 +129,7 @@ type AzureConfig struct {
Measurements Measurements `yaml:"measurements"` Measurements Measurements `yaml:"measurements"`
// description: | // description: |
// Authorize spawned VMs to access Azure API. See: https://constellation-docs.edgeless.systems/6c320851-bdd2-41d5-bf10-e27427398692/#/getting-started/install?id=azure // Authorize spawned VMs to access Azure API. See: https://constellation-docs.edgeless.systems/6c320851-bdd2-41d5-bf10-e27427398692/#/getting-started/install?id=azure
UserAssignedIdentity string `yaml:"userassignedIdentity" validate:"required"` UserAssignedIdentity string `yaml:"userAssignedIdentity" validate:"required"`
} }
// GCPConfig are GCP specific configuration values used by the CLI. // GCPConfig are GCP specific configuration values used by the CLI.
@ -152,7 +150,7 @@ type GCPConfig struct {
// Roles added to service account. // Roles added to service account.
ServiceAccountRoles []string `yaml:"serviceAccountRoles"` ServiceAccountRoles []string `yaml:"serviceAccountRoles"`
// description: | // description: |
// Measurement used to enable measured boot. // Expected confidential VM measurements.
Measurements Measurements `yaml:"measurements"` Measurements Measurements `yaml:"measurements"`
} }
@ -165,10 +163,10 @@ type QEMUConfig struct {
// Default returns a struct with the default config. // Default returns a struct with the default config.
func Default() *Config { func Default() *Config {
return &Config{ return &Config{
Version: Version1, Version: Version1,
AutoscalingNodeGroupsMin: 1, AutoscalingNodeGroupMin: 1,
AutoscalingNodeGroupsMax: 10, AutoscalingNodeGroupMax: 10,
StateDiskSizeGB: 30, StateDiskSizeGB: 30,
IngressFirewall: Firewall{ IngressFirewall: Firewall{
{ {
Name: "coordinator", Name: "coordinator",
@ -201,6 +199,7 @@ func Default() *Config {
}, },
}, },
Provider: ProviderConfig{ Provider: ProviderConfig{
// TODO remove our subscriptions from the default config
Azure: &AzureConfig{ Azure: &AzureConfig{
SubscriptionID: "0d202bbb-4fa7-4af8-8125-58c269a05435", SubscriptionID: "0d202bbb-4fa7-4af8-8125-58c269a05435",
TenantID: "adb650a8-5da3-4b15-b4b0-3daf65ff7626", TenantID: "adb650a8-5da3-4b15-b4b0-3daf65ff7626",

View File

@ -30,21 +30,21 @@ func init() {
ConfigDoc.Fields[0].Note = "" ConfigDoc.Fields[0].Note = ""
ConfigDoc.Fields[0].Description = "Schema version of this configuration file." ConfigDoc.Fields[0].Description = "Schema version of this configuration file."
ConfigDoc.Fields[0].Comments[encoder.LineComment] = "Schema version of this configuration file." ConfigDoc.Fields[0].Comments[encoder.LineComment] = "Schema version of this configuration file."
ConfigDoc.Fields[1].Name = "autoscalingNodeGroupsMin" ConfigDoc.Fields[1].Name = "autoscalingNodeGroupMin"
ConfigDoc.Fields[1].Type = "int" ConfigDoc.Fields[1].Type = "int"
ConfigDoc.Fields[1].Note = "" ConfigDoc.Fields[1].Note = ""
ConfigDoc.Fields[1].Description = "Minimum number of nodes in autoscaling group.\nworker nodes." ConfigDoc.Fields[1].Description = "Minimum number of worker nodes in autoscaling group."
ConfigDoc.Fields[1].Comments[encoder.LineComment] = "Minimum number of nodes in autoscaling group." ConfigDoc.Fields[1].Comments[encoder.LineComment] = "Minimum number of worker nodes in autoscaling group."
ConfigDoc.Fields[2].Name = "autoscalingNodeGroupsMax" ConfigDoc.Fields[2].Name = "autoscalingNodeGroupMax"
ConfigDoc.Fields[2].Type = "int" ConfigDoc.Fields[2].Type = "int"
ConfigDoc.Fields[2].Note = "" ConfigDoc.Fields[2].Note = ""
ConfigDoc.Fields[2].Description = "Maximum number of nodes in autoscaling group.\nworker nodes." ConfigDoc.Fields[2].Description = "Maximum number of worker nodes in autoscaling group."
ConfigDoc.Fields[2].Comments[encoder.LineComment] = "Maximum number of nodes in autoscaling group." ConfigDoc.Fields[2].Comments[encoder.LineComment] = "Maximum number of worker nodes in autoscaling group."
ConfigDoc.Fields[3].Name = "stateDisksizeGB" ConfigDoc.Fields[3].Name = "stateDiskSizeGB"
ConfigDoc.Fields[3].Type = "int" ConfigDoc.Fields[3].Type = "int"
ConfigDoc.Fields[3].Note = "" ConfigDoc.Fields[3].Note = ""
ConfigDoc.Fields[3].Description = "Size (in GB) of data disk used for nodes." ConfigDoc.Fields[3].Description = "Size (in GB) of a node's disk to store the non-volatile state."
ConfigDoc.Fields[3].Comments[encoder.LineComment] = "Size (in GB) of data disk used for nodes." ConfigDoc.Fields[3].Comments[encoder.LineComment] = "Size (in GB) of a node's disk to store the non-volatile state."
ConfigDoc.Fields[4].Name = "ingressFirewall" ConfigDoc.Fields[4].Name = "ingressFirewall"
ConfigDoc.Fields[4].Type = "Firewall" ConfigDoc.Fields[4].Type = "Firewall"
ConfigDoc.Fields[4].Note = "" ConfigDoc.Fields[4].Note = ""
@ -60,8 +60,8 @@ func init() {
ConfigDoc.Fields[6].Name = "provider" ConfigDoc.Fields[6].Name = "provider"
ConfigDoc.Fields[6].Type = "ProviderConfig" ConfigDoc.Fields[6].Type = "ProviderConfig"
ConfigDoc.Fields[6].Note = "" ConfigDoc.Fields[6].Note = ""
ConfigDoc.Fields[6].Description = "Supported cloud providers & their specific configurations." ConfigDoc.Fields[6].Description = "Supported cloud providers and their specific configurations."
ConfigDoc.Fields[6].Comments[encoder.LineComment] = "Supported cloud providers & their specific configurations." ConfigDoc.Fields[6].Comments[encoder.LineComment] = "Supported cloud providers and their specific configurations."
ConfigDoc.Fields[7].Name = "sshUsers" ConfigDoc.Fields[7].Name = "sshUsers"
ConfigDoc.Fields[7].Type = "[]UserKey" ConfigDoc.Fields[7].Type = "[]UserKey"
ConfigDoc.Fields[7].Note = "" ConfigDoc.Fields[7].Note = ""
@ -120,13 +120,13 @@ func init() {
FirewallRuleDoc.Fields[4].Name = "fromport" FirewallRuleDoc.Fields[4].Name = "fromport"
FirewallRuleDoc.Fields[4].Type = "int" FirewallRuleDoc.Fields[4].Type = "int"
FirewallRuleDoc.Fields[4].Note = "" FirewallRuleDoc.Fields[4].Note = ""
FirewallRuleDoc.Fields[4].Description = "Port of start port of a range." FirewallRuleDoc.Fields[4].Description = "Start port of a range."
FirewallRuleDoc.Fields[4].Comments[encoder.LineComment] = "Port of start port of a range." FirewallRuleDoc.Fields[4].Comments[encoder.LineComment] = "Start port of a range."
FirewallRuleDoc.Fields[5].Name = "toport" FirewallRuleDoc.Fields[5].Name = "toport"
FirewallRuleDoc.Fields[5].Type = "int" FirewallRuleDoc.Fields[5].Type = "int"
FirewallRuleDoc.Fields[5].Note = "" FirewallRuleDoc.Fields[5].Note = ""
FirewallRuleDoc.Fields[5].Description = "End port of a range, or 0 if a single port is given by FromPort." FirewallRuleDoc.Fields[5].Description = "End port of a range, or 0 if a single port is given by fromport."
FirewallRuleDoc.Fields[5].Comments[encoder.LineComment] = "End port of a range, or 0 if a single port is given by FromPort." FirewallRuleDoc.Fields[5].Comments[encoder.LineComment] = "End port of a range, or 0 if a single port is given by fromport."
ProviderConfigDoc.Type = "ProviderConfig" ProviderConfigDoc.Type = "ProviderConfig"
ProviderConfigDoc.Comments[encoder.LineComment] = "ProviderConfig are cloud-provider specific configuration values used by the CLI." ProviderConfigDoc.Comments[encoder.LineComment] = "ProviderConfig are cloud-provider specific configuration values used by the CLI."
@ -138,17 +138,17 @@ func init() {
}, },
} }
ProviderConfigDoc.Fields = make([]encoder.Doc, 3) ProviderConfigDoc.Fields = make([]encoder.Doc, 3)
ProviderConfigDoc.Fields[0].Name = "azureConfig" ProviderConfigDoc.Fields[0].Name = "azure"
ProviderConfigDoc.Fields[0].Type = "AzureConfig" ProviderConfigDoc.Fields[0].Type = "AzureConfig"
ProviderConfigDoc.Fields[0].Note = "" ProviderConfigDoc.Fields[0].Note = ""
ProviderConfigDoc.Fields[0].Description = "Configuration for Azure as provider." ProviderConfigDoc.Fields[0].Description = "Configuration for Azure as provider."
ProviderConfigDoc.Fields[0].Comments[encoder.LineComment] = "Configuration for Azure as provider." ProviderConfigDoc.Fields[0].Comments[encoder.LineComment] = "Configuration for Azure as provider."
ProviderConfigDoc.Fields[1].Name = "gcpConfig" ProviderConfigDoc.Fields[1].Name = "gcp"
ProviderConfigDoc.Fields[1].Type = "GCPConfig" ProviderConfigDoc.Fields[1].Type = "GCPConfig"
ProviderConfigDoc.Fields[1].Note = "" ProviderConfigDoc.Fields[1].Note = ""
ProviderConfigDoc.Fields[1].Description = "Configuration for Google Cloud as provider." ProviderConfigDoc.Fields[1].Description = "Configuration for Google Cloud as provider."
ProviderConfigDoc.Fields[1].Comments[encoder.LineComment] = "Configuration for Google Cloud as provider." ProviderConfigDoc.Fields[1].Comments[encoder.LineComment] = "Configuration for Google Cloud as provider."
ProviderConfigDoc.Fields[2].Name = "qemuConfig" ProviderConfigDoc.Fields[2].Name = "qemu"
ProviderConfigDoc.Fields[2].Type = "QEMUConfig" ProviderConfigDoc.Fields[2].Type = "QEMUConfig"
ProviderConfigDoc.Fields[2].Note = "" ProviderConfigDoc.Fields[2].Note = ""
ProviderConfigDoc.Fields[2].Description = "Configuration for QEMU as provider." ProviderConfigDoc.Fields[2].Description = "Configuration for QEMU as provider."
@ -160,7 +160,7 @@ func init() {
AzureConfigDoc.AppearsIn = []encoder.Appearance{ AzureConfigDoc.AppearsIn = []encoder.Appearance{
{ {
TypeName: "ProviderConfig", TypeName: "ProviderConfig",
FieldName: "azureConfig", FieldName: "azure",
}, },
} }
AzureConfigDoc.Fields = make([]encoder.Doc, 6) AzureConfigDoc.Fields = make([]encoder.Doc, 6)
@ -189,7 +189,7 @@ func init() {
AzureConfigDoc.Fields[4].Note = "" AzureConfigDoc.Fields[4].Note = ""
AzureConfigDoc.Fields[4].Description = "Expected confidential VM measurements." AzureConfigDoc.Fields[4].Description = "Expected confidential VM measurements."
AzureConfigDoc.Fields[4].Comments[encoder.LineComment] = "Expected confidential VM measurements." AzureConfigDoc.Fields[4].Comments[encoder.LineComment] = "Expected confidential VM measurements."
AzureConfigDoc.Fields[5].Name = "userassignedIdentity" AzureConfigDoc.Fields[5].Name = "userAssignedIdentity"
AzureConfigDoc.Fields[5].Type = "string" AzureConfigDoc.Fields[5].Type = "string"
AzureConfigDoc.Fields[5].Note = "" AzureConfigDoc.Fields[5].Note = ""
AzureConfigDoc.Fields[5].Description = "Authorize spawned VMs to access Azure API. See: https://constellation-docs.edgeless.systems/6c320851-bdd2-41d5-bf10-e27427398692/#/getting-started/install?id=azure" AzureConfigDoc.Fields[5].Description = "Authorize spawned VMs to access Azure API. See: https://constellation-docs.edgeless.systems/6c320851-bdd2-41d5-bf10-e27427398692/#/getting-started/install?id=azure"
@ -201,7 +201,7 @@ func init() {
GCPConfigDoc.AppearsIn = []encoder.Appearance{ GCPConfigDoc.AppearsIn = []encoder.Appearance{
{ {
TypeName: "ProviderConfig", TypeName: "ProviderConfig",
FieldName: "gcpConfig", FieldName: "gcp",
}, },
} }
GCPConfigDoc.Fields = make([]encoder.Doc, 6) GCPConfigDoc.Fields = make([]encoder.Doc, 6)
@ -233,8 +233,8 @@ func init() {
GCPConfigDoc.Fields[5].Name = "measurements" GCPConfigDoc.Fields[5].Name = "measurements"
GCPConfigDoc.Fields[5].Type = "Measurements" GCPConfigDoc.Fields[5].Type = "Measurements"
GCPConfigDoc.Fields[5].Note = "" GCPConfigDoc.Fields[5].Note = ""
GCPConfigDoc.Fields[5].Description = "Measurement used to enable measured boot." GCPConfigDoc.Fields[5].Description = "Expected confidential VM measurements."
GCPConfigDoc.Fields[5].Comments[encoder.LineComment] = "Measurement used to enable measured boot." GCPConfigDoc.Fields[5].Comments[encoder.LineComment] = "Expected confidential VM measurements."
QEMUConfigDoc.Type = "QEMUConfig" QEMUConfigDoc.Type = "QEMUConfig"
QEMUConfigDoc.Comments[encoder.LineComment] = "" QEMUConfigDoc.Comments[encoder.LineComment] = ""
@ -242,7 +242,7 @@ func init() {
QEMUConfigDoc.AppearsIn = []encoder.Appearance{ QEMUConfigDoc.AppearsIn = []encoder.Appearance{
{ {
TypeName: "ProviderConfig", TypeName: "ProviderConfig",
FieldName: "qemuConfig", FieldName: "qemu",
}, },
} }
QEMUConfigDoc.Fields = make([]encoder.Doc, 1) QEMUConfigDoc.Fields = make([]encoder.Doc, 1)

View File

@ -46,15 +46,15 @@ func TestFromFile(t *testing.T) {
}, },
"custom config from default file": { "custom config from default file": {
config: &Config{ config: &Config{
Version: Version1, Version: Version1,
AutoscalingNodeGroupsMin: 42, AutoscalingNodeGroupMin: 42,
AutoscalingNodeGroupsMax: 1337, AutoscalingNodeGroupMax: 1337,
}, },
configName: constants.ConfigFilename, configName: constants.ConfigFilename,
wantResult: &Config{ wantResult: &Config{
Version: Version1, Version: Version1,
AutoscalingNodeGroupsMin: 42, AutoscalingNodeGroupMin: 42,
AutoscalingNodeGroupsMax: 1337, AutoscalingNodeGroupMax: 1337,
}, },
}, },
"modify default config": { "modify default config": {
@ -103,15 +103,15 @@ func TestFromFileStrictErrors(t *testing.T) {
}{ }{
"valid config": { "valid config": {
yamlConfig: ` yamlConfig: `
autoscalingNodeGroupsMin: 5 autoscalingNodeGroupMin: 5
autoscalingNodeGroupsMax: 10 autoscalingNodeGroupMax: 10
stateDisksizeGB: 25 stateDisksizeGB: 25
`, `,
}, },
"typo": { "typo": {
yamlConfig: ` yamlConfig: `
autoscalingNodeGroupsMini: 5 autoscalingNodeGroupMini: 5
autoscalingNodeGroupsMax: 10 autoscalingNodeGroupMax: 10
stateDisksizeGB: 25 stateDisksizeGB: 25
`, `,
wantErr: true, wantErr: true,
@ -119,8 +119,8 @@ func TestFromFileStrictErrors(t *testing.T) {
"unsupported version": { "unsupported version": {
yamlConfig: ` yamlConfig: `
version: v5 version: v5
autoscalingNodeGroupsMin: 1 autoscalingNodeGroupMin: 1
autoscalingNodeGroupsMax: 10 autoscalingNodeGroupMax: 10
stateDisksizeGB: 30 stateDisksizeGB: 30
`, `,
wantErr: true, wantErr: true,