mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-01 11:36:10 -04:00
cli: state file validation (#2523)
* re-use `ReadFromFile` in `CreateOrRead` Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * [wip]: add constraints Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * [wip] error formatting Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * wip Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * formatted error messages Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * state file validation Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * linter fixes Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * allow overriding the constraints Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * dont validate on read Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * add pre-create constraints Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * [wip] Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * finish pre-init validation test Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * finish post-init validation Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * use state file validation in CLI Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * fix apply tests Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * Update internal/validation/errors.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * use transformator for tests * tidy * use empty check directly Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * Update cli/internal/state/state.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * Update cli/internal/state/state.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * Update cli/internal/state/state.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * Update cli/internal/state/state.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * conditional validation per CSP Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * tidy Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * fix rebase Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * add default case Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * validate state-file as last input Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> --------- Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>
This commit is contained in:
parent
eaec73cca4
commit
744a605602
21 changed files with 1779 additions and 247 deletions
|
@ -18,18 +18,21 @@ import (
|
|||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// defaultState returns a valid default state for testing.
|
||||
func defaultState() *State {
|
||||
return &State{
|
||||
Version: "v1",
|
||||
Infrastructure: Infrastructure{
|
||||
UID: "123",
|
||||
ClusterEndpoint: "test-cluster-endpoint",
|
||||
InitSecret: []byte{0x41},
|
||||
UID: "123",
|
||||
Name: "test-cluster",
|
||||
ClusterEndpoint: "0.0.0.0",
|
||||
InClusterEndpoint: "0.0.0.0",
|
||||
InitSecret: []byte{0x41},
|
||||
APIServerCertSANs: []string{
|
||||
"api-server-cert-san-test",
|
||||
"api-server-cert-san-test-2",
|
||||
"127.0.0.1",
|
||||
"www.example.com",
|
||||
},
|
||||
IPCidrNode: "test-cidr-node",
|
||||
IPCidrNode: "0.0.0.0/24",
|
||||
Azure: &Azure{
|
||||
ResourceGroup: "test-rg",
|
||||
SubscriptionID: "test-sub",
|
||||
|
@ -40,7 +43,7 @@ func defaultState() *State {
|
|||
},
|
||||
GCP: &GCP{
|
||||
ProjectID: "test-project",
|
||||
IPCidrPod: "test-cidr-pod",
|
||||
IPCidrPod: "0.0.0.0/24",
|
||||
},
|
||||
},
|
||||
ClusterValues: ClusterValues{
|
||||
|
@ -51,6 +54,18 @@ func defaultState() *State {
|
|||
}
|
||||
}
|
||||
|
||||
func defaultAzureState() *State {
|
||||
s := defaultState()
|
||||
s.Infrastructure.GCP = nil
|
||||
return s
|
||||
}
|
||||
|
||||
func defaultGCPState() *State {
|
||||
s := defaultState()
|
||||
s.Infrastructure.Azure = nil
|
||||
return s
|
||||
}
|
||||
|
||||
func TestWriteToFile(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
state *State
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue