From d3d1a18a80a81ffa05d0e71f9256c9e6b3658d71 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:32:29 -0600 Subject: [PATCH] (feat): show descriptions for params/creds at gen time Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- pkg/generator/credentials.go | 8 ++++---- pkg/generator/generator.go | 18 ++++++++++++------ pkg/generator/generator_test.go | 4 ++-- pkg/generator/parameters.go | 4 ++-- pkg/porter/credentials.go | 5 +++-- pkg/porter/credentials_test.go | 12 ++++++------ pkg/porter/lifecycle_test.go | 4 ++-- pkg/porter/parameters_test.go | 12 ++++++------ .../testdata/credentials/kool-kreds.json | 1 + pkg/porter/testdata/credentials/kool-kreds.txt | 1 + .../testdata/credentials/kool-kreds.yaml | 1 + .../testdata/credentials/list-output.txt | 6 +++--- .../testdata/credentials/show-output.json | 1 + .../testdata/credentials/show-output.txt | 8 ++++---- .../testdata/credentials/show-output.yaml | 1 + pkg/porter/testdata/parameters/mypset.json | 1 + pkg/porter/testdata/parameters/mypset.yaml | 1 + pkg/storage/credential_store_test.go | 8 ++++---- pkg/storage/credentialset.go | 6 +++++- pkg/storage/credentialset_test.go | 4 ++-- pkg/storage/parameter_store_test.go | 10 +++++----- pkg/storage/parameters_test.go | 2 +- pkg/storage/parameterset.go | 8 ++++++-- pkg/storage/parameterset_test.go | 4 ++-- pkg/storage/run_test.go | 2 +- pkg/storage/sanitizer_test.go | 2 +- pkg/storage/testdata/marshaled_run.json | 2 +- .../credentials/create/credential-set.json | 1 + .../credentials/create/credential-set.yaml | 1 + tests/integration/dependenciesv1_test.go | 2 +- tests/integration/install_test.go | 2 +- 31 files changed, 83 insertions(+), 59 deletions(-) diff --git a/pkg/generator/credentials.go b/pkg/generator/credentials.go index e2d22c129..7859ac0f7 100644 --- a/pkg/generator/credentials.go +++ b/pkg/generator/credentials.go @@ -28,7 +28,7 @@ func GenerateCredentials(opts GenerateCredentialsOptions) (storage.CredentialSet if opts.Silent { generator = genEmptySet } - credSet, err := genCredentialSet(opts.Namespace, opts.Name, opts.Credentials, generator) + credSet, err := genCredentialSet(opts.Namespace, opts.Name, opts.Description, opts.Credentials, generator) if err != nil { return storage.CredentialSet{}, err } @@ -37,8 +37,8 @@ func GenerateCredentials(opts GenerateCredentialsOptions) (storage.CredentialSet return credSet, nil } -func genCredentialSet(namespace string, name string, creds map[string]bundle.Credential, fn generator) (storage.CredentialSet, error) { - cs := storage.NewCredentialSet(namespace, name) +func genCredentialSet(namespace string, name string, description string, creds map[string]bundle.Credential, fn generator) (storage.CredentialSet, error) { + cs := storage.NewCredentialSet(namespace, name, description) cs.Credentials = []secrets.SourceMap{} if strings.ContainsAny(name, "./\\") { @@ -53,7 +53,7 @@ func genCredentialSet(namespace string, name string, creds map[string]bundle.Cre sort.Strings(credentialNames) for _, name := range credentialNames { - c, err := fn(name, surveyCredentials) + c, err := fn(name, "", surveyCredentials) if err != nil { return cs, err } diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index c3d69e34a..141dd5c82 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -13,9 +13,10 @@ import ( // GenerateOptions are the options to generate a parameter or credential set type GenerateOptions struct { // Name of the parameter or credential set. - Name string - Namespace string - Labels map[string]string + Name string + Namespace string + Description string + Labels map[string]string // Should we survey? Silent bool @@ -35,16 +36,20 @@ const ( questionCommand = "shell command" ) -type generator func(name string, surveyType SurveyType) (secrets.SourceMap, error) +type generator func(name string, description string, surveyType SurveyType) (secrets.SourceMap, error) -func genEmptySet(name string, surveyType SurveyType) (secrets.SourceMap, error) { +func genEmptySet(name string, description string, surveyType SurveyType) (secrets.SourceMap, error) { return secrets.SourceMap{ Name: name, Source: secrets.Source{Hint: "TODO"}, }, nil } -func genSurvey(name string, surveyType SurveyType) (secrets.SourceMap, error) { +func genSurvey(name string, description string, surveyType SurveyType) (secrets.SourceMap, error) { + if description != "" { + fmt.Printf("Description: %s", description) + } + if surveyType != surveyCredentials && surveyType != surveyParameters { return secrets.SourceMap{}, fmt.Errorf("unsupported survey type: %s", surveyType) } @@ -109,6 +114,7 @@ func genSurvey(name string, surveyType SurveyType) (secrets.SourceMap, error) { c.Source.Strategy = host.SourceCommand c.Source.Hint = value } + return c, nil } diff --git a/pkg/generator/generator_test.go b/pkg/generator/generator_test.go index 464fd2446..859dbfe60 100644 --- a/pkg/generator/generator_test.go +++ b/pkg/generator/generator_test.go @@ -15,13 +15,13 @@ func Test_genEmptySet(t *testing.T) { Source: secrets.Source{Hint: "TODO"}, } - got, err := genEmptySet("emptyset", surveyParameters) + got, err := genEmptySet("emptyset", "", surveyParameters) require.NoError(t, err) require.Equal(t, expected, got) } func Test_genSurvey_unsupported(t *testing.T) { - got, err := genSurvey("myturtleset", SurveyType("turtles")) + got, err := genSurvey("myturtleset", "my turtle description", SurveyType("turtles")) require.EqualError(t, err, "unsupported survey type: turtles") require.Equal(t, secrets.SourceMap{}, got) } diff --git a/pkg/generator/parameters.go b/pkg/generator/parameters.go index 3007fabc8..a98abed12 100644 --- a/pkg/generator/parameters.go +++ b/pkg/generator/parameters.go @@ -37,7 +37,7 @@ func (opts *GenerateParametersOptions) GenerateParameters() (storage.ParameterSe } func (opts *GenerateParametersOptions) genParameterSet(fn generator) (storage.ParameterSet, error) { - pset := storage.NewParameterSet(opts.Namespace, opts.Name) + pset := storage.NewParameterSet(opts.Namespace, opts.Name, opts.Description) if strings.ContainsAny(opts.Name, "./\\") { return pset, fmt.Errorf("parameter set name '%s' cannot contain the following characters: './\\'", opts.Name) @@ -54,7 +54,7 @@ func (opts *GenerateParametersOptions) genParameterSet(fn generator) (storage.Pa if opts.Bundle.IsInternalParameter(name) { continue } - c, err := fn(name, surveyParameters) + c, err := fn(name, "", surveyParameters) if err != nil { return pset, err } diff --git a/pkg/porter/credentials.go b/pkg/porter/credentials.go index 8dcf261b1..78f46c494 100644 --- a/pkg/porter/credentials.go +++ b/pkg/porter/credentials.go @@ -81,10 +81,10 @@ func (p *Porter) PrintCredentials(ctx context.Context, opts ListOptions) error { if !ok { return nil } - return []string{cr.Namespace, cr.Name, tp.Format(cr.Status.Modified)} + return []string{cr.Namespace, cr.Name, cr.Description, tp.Format(cr.Status.Modified)} } return printer.PrintTable(p.Out, creds, printCredRow, - "NAMESPACE", "NAME", "MODIFIED") + "NAMESPACE", "NAME", "DESCRIPTION", "MODIFIED") default: return span.Error(fmt.Errorf("invalid format: %s", opts.Format)) } @@ -288,6 +288,7 @@ func (p *Porter) ShowCredential(ctx context.Context, opts CredentialShowOptions) // Note that we are not using span.Info because the command's output must go to standard out fmt.Fprintf(p.Out, "Name: %s\n", credSet.Name) fmt.Fprintf(p.Out, "Namespace: %s\n", credSet.Namespace) + fmt.Fprintf(p.Out, "Description: %s\n", credSet.Description) fmt.Fprintf(p.Out, "Created: %s\n", tp.Format(credSet.Status.Created)) fmt.Fprintf(p.Out, "Modified: %s\n\n", tp.Format(credSet.Status.Modified)) diff --git a/pkg/porter/credentials_test.go b/pkg/porter/credentials_test.go index cd28c824b..7f91b4bbe 100644 --- a/pkg/porter/credentials_test.go +++ b/pkg/porter/credentials_test.go @@ -189,12 +189,12 @@ func TestPorter_ListCredentials(t *testing.T) { defer p.Close() ctx := context.Background() - p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("", "shared-mysql")) - p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("dev", "carolyn-wordpress")) - p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("dev", "vaughn-wordpress")) - p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("test", "staging-wordpress")) - p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("test", "iat-wordpress")) - p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("test", "shared-mysql")) + p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("", "shared-mysql", "")) + p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("dev", "carolyn-wordpress", "")) + p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("dev", "vaughn-wordpress", "")) + p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("test", "jeremy-wordpress", "")) + p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("test", "iat-wordpress", "")) + p.TestCredentials.InsertCredentialSet(ctx, storage.NewCredentialSet("test", "shared-mysql", "")) t.Run("all-namespaces", func(t *testing.T) { opts := ListOptions{AllNamespaces: true} diff --git a/pkg/porter/lifecycle_test.go b/pkg/porter/lifecycle_test.go index 5186b2e6b..35db80ff7 100644 --- a/pkg/porter/lifecycle_test.go +++ b/pkg/porter/lifecycle_test.go @@ -338,7 +338,7 @@ func TestPorter_applyActionOptionsToInstallation_FollowsParameterHierarchy(t *te bun, err := configadapter.ConvertToTestBundle(ctx, p.Config, m) require.NoError(t, err) - err = p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("", "myps", + err = p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("", "myps", "", storage.ValueStrategy("my-second-param", "via_paramset"))) require.NoError(t, err, "Create my-second-param parameter set failed") @@ -515,7 +515,7 @@ func TestPorter_applyActionOptionsToInstallation_PreservesExistingParams(t *test opts.Params = []string{nonsensitiveParamName + "=" + nonsensitiveParamValue} i := storage.NewInstallation("", bun.Name) - i.Parameters = storage.NewParameterSet("", "internal-ps", + i.Parameters = storage.NewParameterSet("", "internal-ps", "", storage.ValueStrategy("my-first-param", "1"), storage.ValueStrategy("my-second-param", "2"), ) diff --git a/pkg/porter/parameters_test.go b/pkg/porter/parameters_test.go index 89e010a0c..1879f667d 100644 --- a/pkg/porter/parameters_test.go +++ b/pkg/porter/parameters_test.go @@ -63,12 +63,12 @@ func TestPorter_ListParameters(t *testing.T) { p := NewTestPorter(t) defer p.Close() ctx := context.Background() - p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("", "shared-mysql")) - p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("dev", "carolyn-wordpress")) - p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("dev", "vaughn-wordpress")) - p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("test", "staging-wordpress")) - p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("test", "iat-wordpress")) - p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("test", "shared-mysql")) + p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("", "", "shared-mysql")) + p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("dev", "", "carolyn-wordpress")) + p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("dev", "", "vaughn-wordpress")) + p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("test", "", "staging-wordpress")) + p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("test", "", "iat-wordpress")) + p.TestParameters.InsertParameterSet(ctx, storage.NewParameterSet("test", "", "shared-mysql")) t.Run("all-namespaces", func(t *testing.T) { opts := ListOptions{AllNamespaces: true} diff --git a/pkg/porter/testdata/credentials/kool-kreds.json b/pkg/porter/testdata/credentials/kool-kreds.json index 997e887af..2f0837d37 100644 --- a/pkg/porter/testdata/credentials/kool-kreds.json +++ b/pkg/porter/testdata/credentials/kool-kreds.json @@ -3,6 +3,7 @@ "schemaVersion": "1.0.1", "namespace": "dev", "name": "kool-kreds", + "description": "", "credentials": [ { "name": "kool-config", diff --git a/pkg/porter/testdata/credentials/kool-kreds.txt b/pkg/porter/testdata/credentials/kool-kreds.txt index ebe168f74..d28230eee 100644 --- a/pkg/porter/testdata/credentials/kool-kreds.txt +++ b/pkg/porter/testdata/credentials/kool-kreds.txt @@ -1,5 +1,6 @@ Name: kool-kreds Namespace: dev +Description: Created: 2019-06-24 Modified: 2019-06-24 diff --git a/pkg/porter/testdata/credentials/kool-kreds.yaml b/pkg/porter/testdata/credentials/kool-kreds.yaml index 59fa51b3b..fd311e5d8 100644 --- a/pkg/porter/testdata/credentials/kool-kreds.yaml +++ b/pkg/porter/testdata/credentials/kool-kreds.yaml @@ -2,6 +2,7 @@ schemaType: CredentialSet schemaVersion: 1.0.1 namespace: dev name: kool-kreds +description: "" credentials: - name: kool-config source: diff --git a/pkg/porter/testdata/credentials/list-output.txt b/pkg/porter/testdata/credentials/list-output.txt index 0d579321b..9d10679d2 100644 --- a/pkg/porter/testdata/credentials/list-output.txt +++ b/pkg/porter/testdata/credentials/list-output.txt @@ -1,3 +1,3 @@ ------------------------------ - NAMESPACE NAME MODIFIED ------------------------------ +------------------------------------------ + NAMESPACE NAME DESCRIPTION MODIFIED +------------------------------------------ diff --git a/pkg/porter/testdata/credentials/show-output.json b/pkg/porter/testdata/credentials/show-output.json index ec73a0826..54028fa6c 100644 --- a/pkg/porter/testdata/credentials/show-output.json +++ b/pkg/porter/testdata/credentials/show-output.json @@ -4,6 +4,7 @@ "schemaVersion": "1.0.1", "namespace": "dev", "name": "kool-kreds", + "description": "", "credentials": [ { "name": "kool-config", diff --git a/pkg/porter/testdata/credentials/show-output.txt b/pkg/porter/testdata/credentials/show-output.txt index 088260b25..a9075cfad 100644 --- a/pkg/porter/testdata/credentials/show-output.txt +++ b/pkg/porter/testdata/credentials/show-output.txt @@ -1,4 +1,4 @@ -------------------------------------- - NAMESPACE NAME MODIFIED -------------------------------------- - dev kool-kreds 2019-06-24 +-------------------------------------------------- + NAMESPACE NAME DESCRIPTION MODIFIED +-------------------------------------------------- + dev kool-kreds 2019-06-24 diff --git a/pkg/porter/testdata/credentials/show-output.yaml b/pkg/porter/testdata/credentials/show-output.yaml index 292b13314..4a7f51a6d 100644 --- a/pkg/porter/testdata/credentials/show-output.yaml +++ b/pkg/porter/testdata/credentials/show-output.yaml @@ -2,6 +2,7 @@ schemaVersion: 1.0.1 namespace: dev name: kool-kreds + description: "" credentials: - name: kool-config source: diff --git a/pkg/porter/testdata/parameters/mypset.json b/pkg/porter/testdata/parameters/mypset.json index a34ea08c6..3ad6a7ed6 100644 --- a/pkg/porter/testdata/parameters/mypset.json +++ b/pkg/porter/testdata/parameters/mypset.json @@ -3,6 +3,7 @@ "schemaVersion": "1.0.1", "namespace": "", "name": "mypset", + "description": "", "parameters": [ { "name": "foo", diff --git a/pkg/porter/testdata/parameters/mypset.yaml b/pkg/porter/testdata/parameters/mypset.yaml index 9aa261736..75084d23f 100644 --- a/pkg/porter/testdata/parameters/mypset.yaml +++ b/pkg/porter/testdata/parameters/mypset.yaml @@ -2,6 +2,7 @@ schemaType: ParameterSet schemaVersion: 1.0.1 namespace: "" name: mypset +description: "" parameters: - name: foo source: diff --git a/pkg/storage/credential_store_test.go b/pkg/storage/credential_store_test.go index fd1a8dbf7..50358dc0f 100644 --- a/pkg/storage/credential_store_test.go +++ b/pkg/storage/credential_store_test.go @@ -10,7 +10,7 @@ import ( ) func TestCredentialStorage_CRUD(t *testing.T) { - cs := NewCredentialSet("dev", "sekrets", secrets.SourceMap{ + cs := NewCredentialSet("dev", "sekrets", "", secrets.SourceMap{ Name: "password", Source: secrets.Source{ Strategy: "secret", Hint: "dbPassword"}}) @@ -45,7 +45,7 @@ func TestCredentialStorage_CRUD(t *testing.T) { require.NoError(t, err) assert.Len(t, cs.Credentials, 2) - cs2 := NewCredentialSet("dev", "sekrets-2", secrets.SourceMap{ + cs2 := NewCredentialSet("dev", "sekrets-2", "", secrets.SourceMap{ Name: "password-2", Source: secrets.Source{ Strategy: "secret-2", Hint: "dbPassword-2"}}) @@ -73,7 +73,7 @@ func TestCredentialStorage_CRUD(t *testing.T) { func TestCredentialStorage_Validate_GoodSources(t *testing.T) { s := CredentialStore{} - testCreds := NewCredentialSet("dev", "mycreds", + testCreds := NewCredentialSet("dev", "mycreds", "", secrets.SourceMap{ Source: secrets.Source{ Strategy: "env", @@ -93,7 +93,7 @@ func TestCredentialStorage_Validate_GoodSources(t *testing.T) { func TestCredentialStorage_Validate_BadSources(t *testing.T) { s := CredentialStore{} - testCreds := NewCredentialSet("dev", "mycreds", + testCreds := NewCredentialSet("dev", "mycreds", "", secrets.SourceMap{ Source: secrets.Source{ Strategy: "wrongthing", diff --git a/pkg/storage/credentialset.go b/pkg/storage/credentialset.go index 71f5f2588..eb13b43c8 100644 --- a/pkg/storage/credentialset.go +++ b/pkg/storage/credentialset.go @@ -48,6 +48,9 @@ type CredentialSetSpec struct { // Name of the credential set. Name string `json:"name" yaml:"name" toml:"name"` + // Description fo teh credential set. + Description string `json:"description" yaml:"description" toml:"description"` + // Labels applied to the credential set. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" toml:"labels,omitempty"` @@ -74,13 +77,14 @@ func NewInternalCredentialSet(creds ...secrets.SourceMap) CredentialSet { } // NewCredentialSet creates a new CredentialSet with the required fields initialized. -func NewCredentialSet(namespace string, name string, creds ...secrets.SourceMap) CredentialSet { +func NewCredentialSet(namespace string, name string, description string, creds ...secrets.SourceMap) CredentialSet { now := time.Now() cs := CredentialSet{ CredentialSetSpec: CredentialSetSpec{ SchemaType: SchemaTypeCredentialSet, SchemaVersion: DefaultCredentialSetSchemaVersion, Name: name, + Description: description, Namespace: namespace, Credentials: creds, }, diff --git a/pkg/storage/credentialset_test.go b/pkg/storage/credentialset_test.go index 0a2f486d9..e6ed13980 100644 --- a/pkg/storage/credentialset_test.go +++ b/pkg/storage/credentialset_test.go @@ -17,7 +17,7 @@ import ( ) func TestNewCredentialSet(t *testing.T) { - cs := NewCredentialSet("dev", "mycreds", secrets.SourceMap{ + cs := NewCredentialSet("dev", "mycreds", "", secrets.SourceMap{ Name: "password", Source: secrets.Source{ Strategy: "env", @@ -140,7 +140,7 @@ func TestDisplayCredentials_Validate(t *testing.T) { } func TestCredentialSet_Validate_DefaultSchemaType(t *testing.T) { - cs := NewCredentialSet("", "mycs") + cs := NewCredentialSet("", "mycs", "") cs.SchemaType = "" require.NoError(t, cs.Validate(context.Background(), schema.CheckStrategyExact)) assert.Equal(t, SchemaTypeCredentialSet, cs.SchemaType) diff --git a/pkg/storage/parameter_store_test.go b/pkg/storage/parameter_store_test.go index 7fa4be96d..36178a9f3 100644 --- a/pkg/storage/parameter_store_test.go +++ b/pkg/storage/parameter_store_test.go @@ -18,7 +18,7 @@ func TestParameterStore_CRUD(t *testing.T) { require.NoError(t, err) require.Empty(t, params, "Find should return no entries") - myParamSet := NewParameterSet("dev", "myparams", + myParamSet := NewParameterSet("dev", "myparams", "", secrets.SourceMap{ Name: "myparam", Source: secrets.Source{ @@ -49,7 +49,7 @@ func TestParameterStore_CRUD(t *testing.T) { require.NoError(t, err) require.Equal(t, myParamSet, pset, "Get should return the saved parameter set") - myParamSet2 := NewParameterSet("dev", "myparams2", + myParamSet2 := NewParameterSet("dev", "myparams2", "", secrets.SourceMap{ Name: "myparam2", Source: secrets.Source{ @@ -93,7 +93,7 @@ func TestParameterStore_CRUD(t *testing.T) { func TestParameterStorage_ResolveAll(t *testing.T) { // The inmemory secret store currently only supports secret sources // So all of these have this same source - testParameterSet := NewParameterSet("", "myparamset", + testParameterSet := NewParameterSet("", "myparamset", "", secrets.SourceMap{ Name: "param1", Source: secrets.Source{ @@ -148,7 +148,7 @@ func TestParameterStorage_Validate(t *testing.T) { t.Run("valid sources", func(t *testing.T) { s := ParameterStore{} - testParameterSet := NewParameterSet("", "myparams", + testParameterSet := NewParameterSet("", "myparams", "", secrets.SourceMap{ Source: secrets.Source{ Strategy: "env", @@ -186,7 +186,7 @@ func TestParameterStorage_Validate(t *testing.T) { t.Run("invalid sources", func(t *testing.T) { s := ParameterStore{} - testParameterSet := NewParameterSet("", "myparams", + testParameterSet := NewParameterSet("", "myparams", "", secrets.SourceMap{ Source: secrets.Source{ Strategy: "wrongthing", diff --git a/pkg/storage/parameters_test.go b/pkg/storage/parameters_test.go index ec5cec1f7..c8dd4b286 100644 --- a/pkg/storage/parameters_test.go +++ b/pkg/storage/parameters_test.go @@ -66,7 +66,7 @@ func TestTestParameterProvider_Load(t *testing.T) { }) t.Run("successful load, successful unmarshal", func(t *testing.T) { - expected := NewParameterSet("", "mybun", + expected := NewParameterSet("", "mybun", "", secrets.SourceMap{ Name: "param_env", Source: secrets.Source{ diff --git a/pkg/storage/parameterset.go b/pkg/storage/parameterset.go index 4355d34b1..9ad8b639f 100644 --- a/pkg/storage/parameterset.go +++ b/pkg/storage/parameterset.go @@ -41,6 +41,9 @@ type ParameterSetSpec struct { // Name is the name of the parameter set. Name string `json:"name" yaml:"name" toml:"name"` + // Description is the description of the parameter set. + Description string `json:"description" yaml:"description" toml:"description"` + // Labels applied to the parameter set. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" toml:"labels,omitempty"` @@ -58,7 +61,7 @@ type ParameterSetStatus struct { } // NewParameterSet creates a new ParameterSet with the required fields initialized. -func NewParameterSet(namespace string, name string, params ...secrets.SourceMap) ParameterSet { +func NewParameterSet(namespace string, name string, description string, params ...secrets.SourceMap) ParameterSet { now := time.Now() ps := ParameterSet{ ParameterSetSpec: ParameterSetSpec{ @@ -66,6 +69,7 @@ func NewParameterSet(namespace string, name string, params ...secrets.SourceMap) SchemaVersion: DefaultParameterSetSchemaVersion, Namespace: namespace, Name: name, + Description: description, Parameters: params, }, Status: ParameterSetStatus{ @@ -79,7 +83,7 @@ func NewParameterSet(namespace string, name string, params ...secrets.SourceMap) // NewInternalParameterSet creates a new internal ParameterSet with the required fields initialized. func NewInternalParameterSet(namespace string, name string, params ...secrets.SourceMap) ParameterSet { - return NewParameterSet(namespace, INTERNAL_PARAMETERER_SET+"-"+name, params...) + return NewParameterSet(namespace, INTERNAL_PARAMETERER_SET+"-"+name, "", params...) } func (s ParameterSet) DefaultDocumentFilter() map[string]interface{} { diff --git a/pkg/storage/parameterset_test.go b/pkg/storage/parameterset_test.go index 9f2ed9fc1..a3d4834db 100644 --- a/pkg/storage/parameterset_test.go +++ b/pkg/storage/parameterset_test.go @@ -15,7 +15,7 @@ import ( ) func TestNewParameterSet(t *testing.T) { - ps := NewParameterSet("dev", "myparams", + ps := NewParameterSet("dev", "myparams", "", secrets.SourceMap{ Name: "password", Source: secrets.Source{ @@ -107,7 +107,7 @@ func TestDisplayParameterSet_Validate(t *testing.T) { } func TestParameterSet_Validate_DefaultSchemaType(t *testing.T) { - ps := NewParameterSet("", "myps") + ps := NewParameterSet("", "myps", "") ps.SchemaType = "" require.NoError(t, ps.Validate(context.Background(), schema.CheckStrategyExact)) assert.Equal(t, SchemaTypeParameterSet, ps.SchemaType) diff --git a/pkg/storage/run_test.go b/pkg/storage/run_test.go index 902414cd2..45cf43768 100644 --- a/pkg/storage/run_test.go +++ b/pkg/storage/run_test.go @@ -171,7 +171,7 @@ func TestRun_TypedParameterValues(t *testing.T) { run := NewRun("dev", "mybuns") run.Bundle = bun - run.Parameters = NewParameterSet(run.Namespace, run.Bundle.Name, + run.Parameters = NewParameterSet(run.Namespace, run.Bundle.Name, "", ValueStrategy("baz", "baz-test"), ValueStrategy("name", "porter-test"), ValueStrategy("porter-state", ""), diff --git a/pkg/storage/sanitizer_test.go b/pkg/storage/sanitizer_test.go index 135c9b87a..4285a4c50 100644 --- a/pkg/storage/sanitizer_test.go +++ b/pkg/storage/sanitizer_test.go @@ -50,7 +50,7 @@ func TestSanitizer_Parameters(t *testing.T) { require.Truef(t, reflect.DeepEqual(result, expected), "expected: %v, got: %v", expected, result) - pset := storage.NewParameterSet("", "dev", result...) + pset := storage.NewParameterSet("", "dev", "", result...) resolved, err := r.TestSanitizer.RestoreParameterSet(ctx, pset, bun) require.NoError(t, err) diff --git a/pkg/storage/testdata/marshaled_run.json b/pkg/storage/testdata/marshaled_run.json index 8988696e5..ea791bdbf 100644 --- a/pkg/storage/testdata/marshaled_run.json +++ b/pkg/storage/testdata/marshaled_run.json @@ -1 +1 @@ -{"schemaVersion":"","_id":"foo","created":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z","namespace":"","installation":"","revision":"","action":"","bundleReference":"","bundleDigest":"","parameterOverrides":{"schemaVersion":"","namespace":"","name":"","parameters":null,"status":{"created":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z"}},"parameters":{"schemaVersion":"","namespace":"","name":"","parameters":null,"status":{"created":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z"}},"custom":null,"credentials":{"schemaVersion":"","namespace":"","name":"","status":{}},"bundle":"{\"actions\":{\"logs\":{},\"test\":{\"modifies\":true}},\"description\":\"this is my bundle\",\"invocationImages\":[],\"name\":\"mybun\",\"schemaVersion\":\"schemaVersion\",\"version\":\"v0.1.0\"}"} \ No newline at end of file +{"schemaVersion":"","_id":"foo","created":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z","namespace":"","installation":"","revision":"","action":"","bundleReference":"","bundleDigest":"","parameterOverrides":{"schemaVersion":"","namespace":"","name":"","description":"","parameters":null,"status":{"created":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z"}},"parameters":{"schemaVersion":"","namespace":"","name":"","description":"","parameters":null,"status":{"created":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z"}},"custom":null,"credentials":{"schemaVersion":"","namespace":"","name":"","description":"","status":{}},"bundle":"{\"actions\":{\"logs\":{},\"test\":{\"modifies\":true}},\"description\":\"this is my bundle\",\"invocationImages\":[],\"name\":\"mybun\",\"schemaVersion\":\"schemaVersion\",\"version\":\"v0.1.0\"}"} \ No newline at end of file diff --git a/pkg/templates/templates/credentials/create/credential-set.json b/pkg/templates/templates/credentials/create/credential-set.json index 94b47e2d6..cb5407260 100644 --- a/pkg/templates/templates/credentials/create/credential-set.json +++ b/pkg/templates/templates/credentials/create/credential-set.json @@ -9,6 +9,7 @@ "credentials": [ { "name": "credential-path", + "description": "the credential path", "source": { "path": "/path/to/credential-path-file.txt" } diff --git a/pkg/templates/templates/credentials/create/credential-set.yaml b/pkg/templates/templates/credentials/create/credential-set.yaml index 8fa231b92..6d42a90ae 100644 --- a/pkg/templates/templates/credentials/create/credential-set.yaml +++ b/pkg/templates/templates/credentials/create/credential-set.yaml @@ -13,6 +13,7 @@ labels: # Allowed sources are: value, path, env, secret, and command. credentials: - name: credential-path + - description: the credential path source: # Resolve the credential value from the contents of the specified file. path: /path/to/credential-path-file.txt diff --git a/tests/integration/dependenciesv1_test.go b/tests/integration/dependenciesv1_test.go index 2732bf987..38a847343 100644 --- a/tests/integration/dependenciesv1_test.go +++ b/tests/integration/dependenciesv1_test.go @@ -73,7 +73,7 @@ func installWordpressBundle(ctx context.Context, p *porter.TestPorter) (namespac // Add a supplemental parameter set to vet dep param resolution installOpts.ParameterSets = []string{"myparam"} - testParamSets := storage.NewParameterSet(namespace, "myparam", secrets.SourceMap{ + testParamSets := storage.NewParameterSet(namespace, "myparam", "", secrets.SourceMap{ Name: "mysql#probe-timeout", Source: secrets.Source{ Strategy: host.SourceValue, diff --git a/tests/integration/install_test.go b/tests/integration/install_test.go index 60d4bb66c..cc0190a33 100644 --- a/tests/integration/install_test.go +++ b/tests/integration/install_test.go @@ -53,7 +53,7 @@ func TestInstall_fileParam(t *testing.T) { installOpts := porter.NewInstallOptions() installOpts.Params = []string{"myfile=./myfile"} installOpts.ParameterSets = []string{"myparam"} - testParamSets := storage.NewParameterSet("", "myparam", secrets.SourceMap{ + testParamSets := storage.NewParameterSet("", "myparam", "", secrets.SourceMap{ Name: "myotherfile", Source: secrets.Source{ Strategy: host.SourcePath,