From 707f9180e3b0b751ec057bba4aa0f6e9f68a5de5 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Thu, 15 Jun 2023 08:50:06 -0600 Subject: [PATCH] feature(CLI): Analyzer Resource Integration (#2726) * feature(CLI): Analyzer Resource Integration * feature(CLI): including e2e tests * feature(CLI): including e2e tests * feature(CLI): including e2e tests * fixing comments * fixing test file names --- cli/actions/analyzer.go | 58 +++++++++ cli/cmd/config.go | 8 ++ cli/formatters/analyzer.go | 102 +++++++++++++++ cli/parameters/resources.go | 2 +- server/model/yaml/file.go | 1 + .../analyzer/apply_analyzer_test.go | 46 +++++++ .../analyzer/delete_analyzer_test.go | 30 +++++ .../analyzer/get_analyzer_test.go | 108 ++++++++++++++++ .../analyzer/list_analyzer_test.go | 120 ++++++++++++++++++ .../analyzer/resources/new-analyzer.yaml | 16 +++ .../demo/resources/another-demo.yaml | 2 +- .../demo/resources/new-demo.yaml | 2 +- .../demo/resources/updated-new-demo.yaml | 2 +- .../resources/another-environment.yaml | 2 +- .../resources/new-environment.yaml | 2 +- .../resources/one-more-environment.yaml | 2 +- .../resources/updated-new-environment.yaml | 2 +- .../test/resources/environment-file.yaml | 2 +- .../cli-e2etest/testscenarios/types/types.go | 19 +++ 19 files changed, 517 insertions(+), 9 deletions(-) create mode 100644 cli/actions/analyzer.go create mode 100644 cli/formatters/analyzer.go create mode 100644 testing/cli-e2etest/testscenarios/analyzer/apply_analyzer_test.go create mode 100644 testing/cli-e2etest/testscenarios/analyzer/delete_analyzer_test.go create mode 100644 testing/cli-e2etest/testscenarios/analyzer/get_analyzer_test.go create mode 100644 testing/cli-e2etest/testscenarios/analyzer/list_analyzer_test.go create mode 100644 testing/cli-e2etest/testscenarios/analyzer/resources/new-analyzer.yaml diff --git a/cli/actions/analyzer.go b/cli/actions/analyzer.go new file mode 100644 index 0000000000..c9d94bfbed --- /dev/null +++ b/cli/actions/analyzer.go @@ -0,0 +1,58 @@ +package actions + +import ( + "context" + + "github.com/kubeshop/tracetest/cli/file" + "github.com/kubeshop/tracetest/cli/openapi" + "github.com/kubeshop/tracetest/cli/utils" + "github.com/kubeshop/tracetest/server/model/yaml" +) + +type analyzerActions struct { + resourceArgs +} + +var _ ResourceActions = &analyzerActions{} + +func NewAnalyzerActions(options ...ResourceArgsOption) analyzerActions { + args := NewResourceArgs(options...) + + return analyzerActions{ + resourceArgs: args, + } +} + +func (analyzerActions) FileType() yaml.FileType { + return yaml.FileTypeAnalyzer +} + +func (analyzerActions) Name() string { + return "analyzer" +} + +func (analyzer analyzerActions) GetID(file *file.File) (string, error) { + resource, err := analyzer.formatter.ToStruct(file) + if err != nil { + return "", err + } + + return *resource.(openapi.LinterResource).Spec.Id, nil +} + +func (analyzer analyzerActions) Apply(ctx context.Context, fileContent file.File) (result *file.File, err error) { + result, err = analyzer.resourceClient.Update(ctx, fileContent, currentConfigID) + return result, err +} + +func (analyzer analyzerActions) Get(ctx context.Context, ID string) (*file.File, error) { + return analyzer.resourceClient.Get(ctx, currentConfigID) +} + +func (analyzer analyzerActions) List(ctx context.Context, listArgs utils.ListArgs) (*file.File, error) { + return analyzer.resourceClient.List(ctx, listArgs) +} + +func (analyzer analyzerActions) Delete(ctx context.Context, ID string) (string, error) { + return "", ErrNotSupportedResourceAction +} diff --git a/cli/cmd/config.go b/cli/cmd/config.go index efc7c71776..fb2ca35f1d 100644 --- a/cli/cmd/config.go +++ b/cli/cmd/config.go @@ -73,6 +73,14 @@ func setupCommand(options ...setupOption) func(cmd *cobra.Command, args []string configActions := actions.NewConfigActions(configOptions...) resourceRegistry.Register(configActions) + analyzerOptions := append( + baseOptions, + actions.WithClient(utils.GetResourceAPIClient("analyzers", cliConfig)), + actions.WithFormatter(formatters.NewAnalyzerFormatter()), + ) + analyzerActions := actions.NewAnalyzerActions(analyzerOptions...) + resourceRegistry.Register(analyzerActions) + pollingOptions := append( baseOptions, actions.WithClient(utils.GetResourceAPIClient("pollingprofiles", cliConfig)), diff --git a/cli/formatters/analyzer.go b/cli/formatters/analyzer.go new file mode 100644 index 0000000000..1a1db23fe5 --- /dev/null +++ b/cli/formatters/analyzer.go @@ -0,0 +1,102 @@ +package formatters + +import ( + "fmt" + + "github.com/alexeyco/simpletable" + "github.com/goccy/go-yaml" + "github.com/kubeshop/tracetest/cli/file" + "github.com/kubeshop/tracetest/cli/openapi" +) + +type AnalyzerFormatter struct{} + +var _ ResourceFormatter = AnalyzerFormatter{} + +func NewAnalyzerFormatter() AnalyzerFormatter { + return AnalyzerFormatter{} +} + +func (f AnalyzerFormatter) ToTable(file *file.File) (*simpletable.Header, *simpletable.Body, error) { + rawConfig, err := f.ToStruct(file) + if err != nil { + return nil, nil, err + } + + linterResource := rawConfig.(openapi.LinterResource) + row, err := f.getTableRow(linterResource) + if err != nil { + return nil, nil, err + } + + body := simpletable.Body{} + body.Cells = [][]*simpletable.Cell{row} + + return f.getTableHeader(), &body, nil +} + +func (f AnalyzerFormatter) ToListTable(file *file.File) (*simpletable.Header, *simpletable.Body, error) { + rawConfigList, err := f.ToListStruct(file) + if err != nil { + return nil, nil, err + } + + body := simpletable.Body{} + for _, rawConfig := range rawConfigList { + linterResource := rawConfig.(openapi.LinterResource) + row, err := f.getTableRow(linterResource) + if err != nil { + return nil, nil, err + } + + body.Cells = append(body.Cells, row) + } + + return f.getTableHeader(), &body, nil +} + +func (f AnalyzerFormatter) ToStruct(file *file.File) (interface{}, error) { + var linterResource openapi.LinterResource + err := yaml.Unmarshal([]byte(file.Contents()), &linterResource) + if err != nil { + return nil, err + } + + return linterResource, nil +} + +func (f AnalyzerFormatter) ToListStruct(file *file.File) ([]interface{}, error) { + var analyzerList openapi.LinterResourceList + + err := yaml.Unmarshal([]byte(file.Contents()), &analyzerList) + if err != nil { + return nil, err + } + + items := make([]interface{}, len(analyzerList.Items)) + for i, item := range analyzerList.Items { + items[i] = item + } + + return items, nil +} + +func (f AnalyzerFormatter) getTableHeader() *simpletable.Header { + return &simpletable.Header{ + Cells: []*simpletable.Cell{ + {Text: "ID"}, + {Text: "NAME"}, + {Text: "ENABLED"}, + {Text: "MINIMUM SCORE"}, + }, + } +} + +func (f AnalyzerFormatter) getTableRow(t openapi.LinterResource) ([]*simpletable.Cell, error) { + return []*simpletable.Cell{ + {Text: *t.Spec.Id}, + {Text: *t.Spec.Name}, + {Text: fmt.Sprintf("%t", *t.Spec.Enabled)}, + {Text: fmt.Sprintf("%d", *t.Spec.MinimumScore)}, + }, nil +} diff --git a/cli/parameters/resources.go b/cli/parameters/resources.go index b246388391..9ca797eacd 100644 --- a/cli/parameters/resources.go +++ b/cli/parameters/resources.go @@ -87,7 +87,7 @@ type ResourceParams struct { } var _ Params = &ResourceParams{} -var ValidResources = []string{"config", "datastore", "demo", "environment", "pollingprofile", "transaction"} +var ValidResources = []string{"config", "datastore", "demo", "environment", "pollingprofile", "transaction", "analyzer"} func (p *ResourceParams) Validate(cmd *cobra.Command, args []string) []ParamError { errors := make([]ParamError, 0) diff --git a/server/model/yaml/file.go b/server/model/yaml/file.go index 92eb4c6943..fac856bb59 100644 --- a/server/model/yaml/file.go +++ b/server/model/yaml/file.go @@ -20,6 +20,7 @@ const ( FileTypeConfig FileType = "Config" FileTypeDemo FileType = "Demo" FileTypePollingProfile FileType = "PollingProfile" + FileTypeAnalyzer FileType = "Analyzer" ) type File struct { diff --git a/testing/cli-e2etest/testscenarios/analyzer/apply_analyzer_test.go b/testing/cli-e2etest/testscenarios/analyzer/apply_analyzer_test.go new file mode 100644 index 0000000000..dff50f0860 --- /dev/null +++ b/testing/cli-e2etest/testscenarios/analyzer/apply_analyzer_test.go @@ -0,0 +1,46 @@ +package analyzer + +import ( + "fmt" + "testing" + + "github.com/kubeshop/tracetest/cli-e2etest/environment" + "github.com/kubeshop/tracetest/cli-e2etest/helpers" + "github.com/kubeshop/tracetest/cli-e2etest/testscenarios/types" + "github.com/kubeshop/tracetest/cli-e2etest/tracetestcli" + "github.com/stretchr/testify/require" +) + +func TestApplyAnalyzer(t *testing.T) { + // instantiate require with testing helper + require := require.New(t) + + // setup isolated e2e environment + env := environment.CreateAndStart(t) + defer env.Close(t) + + cliConfig := env.GetCLIConfigPath(t) + + // Given I am a Tracetest CLI user + // And I have my server recently created + + // When I try to set up a new analyzer + // Then it should be applied with success + configPath := env.GetTestResourcePath(t, "new-analyzer") + + result := tracetestcli.Exec(t, fmt.Sprintf("apply analyzer --file %s", configPath), tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + + // When I try to get a analyzer again + // Then it should return the analyzer applied on the last step, with analytics disabled + result = tracetestcli.Exec(t, "get analyzer --id current", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + + analyzer := helpers.UnmarshalYAML[types.AnalyzerResource](t, result.StdOut) + require.Equal("Analyzer", analyzer.Type) + require.Equal("current", analyzer.Spec.Id) + require.Equal("analyzer", analyzer.Spec.Name) + require.True(analyzer.Spec.Enabled) + require.Equal(analyzer.Spec.MinimumScore, 95) + require.Len(analyzer.Spec.Plugins, 3) +} diff --git a/testing/cli-e2etest/testscenarios/analyzer/delete_analyzer_test.go b/testing/cli-e2etest/testscenarios/analyzer/delete_analyzer_test.go new file mode 100644 index 0000000000..90459824b9 --- /dev/null +++ b/testing/cli-e2etest/testscenarios/analyzer/delete_analyzer_test.go @@ -0,0 +1,30 @@ +package analyzer + +import ( + "testing" + + "github.com/kubeshop/tracetest/cli-e2etest/environment" + "github.com/kubeshop/tracetest/cli-e2etest/helpers" + "github.com/kubeshop/tracetest/cli-e2etest/tracetestcli" + "github.com/stretchr/testify/require" +) + +func TestDeleteAnalyzer(t *testing.T) { + // instantiate require with testing helper + require := require.New(t) + + // setup isolated e2e environment + env := environment.CreateAndStart(t) + defer env.Close(t) + + cliConfig := env.GetCLIConfigPath(t) + + // Given I am a Tracetest CLI user + // And I have my server recently created + + // When I try to delete the analyzer + // Then it should return a error message, showing that we cannot delete a analyzer + result := tracetestcli.Exec(t, "delete analyzer --id current", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 1) + require.Contains(result.StdErr, "the specified resource type doesn't support the action") +} diff --git a/testing/cli-e2etest/testscenarios/analyzer/get_analyzer_test.go b/testing/cli-e2etest/testscenarios/analyzer/get_analyzer_test.go new file mode 100644 index 0000000000..cd3ce84ffb --- /dev/null +++ b/testing/cli-e2etest/testscenarios/analyzer/get_analyzer_test.go @@ -0,0 +1,108 @@ +package analyzer + +import ( + "fmt" + "strings" + "testing" + + "github.com/kubeshop/tracetest/cli-e2etest/environment" + "github.com/kubeshop/tracetest/cli-e2etest/helpers" + "github.com/kubeshop/tracetest/cli-e2etest/testscenarios/types" + "github.com/kubeshop/tracetest/cli-e2etest/tracetestcli" + "github.com/stretchr/testify/require" +) + +func addGetAnalyzerPreReqs(t *testing.T, env environment.Manager) { + cliConfig := env.GetCLIConfigPath(t) + + // When I try to set up a analyzer + // Then it should be applied with success + configPath := env.GetTestResourcePath(t, "new-analyzer") + + result := tracetestcli.Exec(t, fmt.Sprintf("apply analyzer --file %s", configPath), tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) +} + +func TestGetAnalyzer(t *testing.T) { + // instantiate require with testing helper + require := require.New(t) + + env := environment.CreateAndStart(t) + defer env.Close(t) + + cliConfig := env.GetCLIConfigPath(t) + + t.Run("get with no analyzer initialized", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And no analyzer previously registered + + // When I try to get a analyzer on yaml mode + // Then it should print a YAML with the default analyzer + result := tracetestcli.Exec(t, "get analyzer --id current --output yaml", tracetestcli.WithCLIConfig(cliConfig)) + require.Equal(0, result.ExitCode) + + analyzer := helpers.UnmarshalYAML[types.AnalyzerResource](t, result.StdOut) + require.Equal("Analyzer", analyzer.Type) + require.Equal("current", analyzer.Spec.Id) + require.Equal("analyzer", analyzer.Spec.Name) + require.True(analyzer.Spec.Enabled) + require.Equal(analyzer.Spec.MinimumScore, 0) + require.Len(analyzer.Spec.Plugins, 3) + }) + + addGetAnalyzerPreReqs(t, env) + + t.Run("get with YAML format", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And I have a config already set + + // When I try to get a config on yaml mode + // Then it should print a YAML + result := tracetestcli.Exec(t, "get analyzer --id current --output yaml", tracetestcli.WithCLIConfig(cliConfig)) + require.Equal(0, result.ExitCode) + + analyzer := helpers.UnmarshalYAML[types.AnalyzerResource](t, result.StdOut) + require.Equal("Analyzer", analyzer.Type) + require.Equal("current", analyzer.Spec.Id) + require.Equal("analyzer", analyzer.Spec.Name) + require.True(analyzer.Spec.Enabled) + require.Equal(analyzer.Spec.MinimumScore, 95) + require.Len(analyzer.Spec.Plugins, 3) + }) + + t.Run("get with JSON format", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And I have a analyzer already set + + // When I try to get a analyzer on json mode + // Then it should print a json + result := tracetestcli.Exec(t, "get analyzer --id current --output json", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + + analyzer := helpers.UnmarshalJSON[types.AnalyzerResource](t, result.StdOut) + require.Equal("Analyzer", analyzer.Type) + require.Equal("current", analyzer.Spec.Id) + require.Equal("analyzer", analyzer.Spec.Name) + require.True(analyzer.Spec.Enabled) + require.Equal(analyzer.Spec.MinimumScore, 95) + require.Len(analyzer.Spec.Plugins, 3) + }) + + t.Run("get with pretty format", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And I have a analyzer already set + + // When I try to get a analyzer on pretty mode + // Then it should print a table with 4 lines printed: header, separator, a analyzer item and empty line + result := tracetestcli.Exec(t, "get analyzer --id current --output pretty", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + require.Contains(result.StdOut, "current") + + lines := strings.Split(result.StdOut, "\n") + require.Len(lines, 4) + }) +} diff --git a/testing/cli-e2etest/testscenarios/analyzer/list_analyzer_test.go b/testing/cli-e2etest/testscenarios/analyzer/list_analyzer_test.go new file mode 100644 index 0000000000..cb411e96aa --- /dev/null +++ b/testing/cli-e2etest/testscenarios/analyzer/list_analyzer_test.go @@ -0,0 +1,120 @@ +package analyzer + +import ( + "fmt" + "strings" + "testing" + + "github.com/kubeshop/tracetest/cli-e2etest/environment" + "github.com/kubeshop/tracetest/cli-e2etest/helpers" + "github.com/kubeshop/tracetest/cli-e2etest/testscenarios/types" + "github.com/kubeshop/tracetest/cli-e2etest/tracetestcli" + "github.com/stretchr/testify/require" +) + +func addListAnalyzerPreReqs(t *testing.T, env environment.Manager) { + cliConfig := env.GetCLIConfigPath(t) + + // When I try to set up a new analyzer + // Then it should be applied with success + configPath := env.GetTestResourcePath(t, "new-analyzer") + + result := tracetestcli.Exec(t, fmt.Sprintf("apply analyzer --file %s", configPath), tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) +} + +func TestListAnalyzer(t *testing.T) { + // instantiate require with testing helper + require := require.New(t) + + env := environment.CreateAndStart(t) + defer env.Close(t) + + cliConfig := env.GetCLIConfigPath(t) + + t.Run("list with no analyzer initialized", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + + // When I try to list analyzer on pretty mode and there is no analyzer previously registered + // Then it should print an empty table + // Then it should print a table with 4 lines printed: header, separator, the default analyzer item and empty line + result := tracetestcli.Exec(t, "list analyzer --sortBy name --output pretty", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + require.Contains(result.StdOut, "current") + + lines := strings.Split(result.StdOut, "\n") + require.Len(lines, 4) + }) + + addListAnalyzerPreReqs(t, env) + + t.Run("list with invalid sortBy field", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And I already have a analyzer created + + // When I try to list a analyzer by an invalid field + // Then I should receive an error + result := tracetestcli.Exec(t, "list analyzer --sortBy id --output yaml", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 1) + require.Contains(result.StdErr, "invalid sort field: id") // TODO: think on how to improve this error handling + }) + + t.Run("list with YAML format", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And I already have a analyzer created + + // When I try to list analyzer again on yaml mode + // Then it should print a YAML list with one item + result := tracetestcli.Exec(t, "list analyzer --sortBy name --output yaml", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + + analyzerYAML := helpers.UnmarshalYAMLSequence[types.AnalyzerResource](t, result.StdOut) + + require.Len(analyzerYAML, 1) + require.Equal("Analyzer", analyzerYAML[0].Type) + require.Equal("current", analyzerYAML[0].Spec.Id) + require.Equal("analyzer", analyzerYAML[0].Spec.Name) + require.True(analyzerYAML[0].Spec.Enabled) + require.Equal(analyzerYAML[0].Spec.MinimumScore, 95) + require.Len(analyzerYAML[0].Spec.Plugins, 3) + }) + + t.Run("list with JSON format", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And I already have a analyzer created + + // When I try to list analyzer again on json mode + // Then it should print a JSON list with one item + result := tracetestcli.Exec(t, "list analyzer --sortBy name --output json", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + + analyzerYAML := helpers.UnmarshalJSON[[]types.AnalyzerResource](t, result.StdOut) + + require.Len(analyzerYAML, 1) + require.Equal("Analyzer", analyzerYAML[0].Type) + require.Equal("current", analyzerYAML[0].Spec.Id) + require.Equal("analyzer", analyzerYAML[0].Spec.Name) + require.True(analyzerYAML[0].Spec.Enabled) + require.Equal(analyzerYAML[0].Spec.MinimumScore, 95) + require.Len(analyzerYAML[0].Spec.Plugins, 3) + }) + + t.Run("list with pretty format", func(t *testing.T) { + // Given I am a Tracetest CLI user + // And I have my server recently created + // And I already have a analyzer created + + // When I try to list analyzer again on pretty mode + // Then it should print a table with 4 lines printed: header, separator, analyzer item and empty line + result := tracetestcli.Exec(t, "list analyzer --sortBy name --output pretty", tracetestcli.WithCLIConfig(cliConfig)) + helpers.RequireExitCodeEqual(t, result, 0) + require.Contains(result.StdOut, "current") + + lines := strings.Split(result.StdOut, "\n") + require.Len(lines, 4) + }) +} diff --git a/testing/cli-e2etest/testscenarios/analyzer/resources/new-analyzer.yaml b/testing/cli-e2etest/testscenarios/analyzer/resources/new-analyzer.yaml new file mode 100644 index 0000000000..86b06e8063 --- /dev/null +++ b/testing/cli-e2etest/testscenarios/analyzer/resources/new-analyzer.yaml @@ -0,0 +1,16 @@ +type: Analyzer +spec: + id: current + name: analyzer + enabled: true + minimumScore: 95 + plugins: + - name: standards + enabled: true + required: true + - name: security + enabled: true + required: true + - name: common + enabled: true + required: true diff --git a/testing/cli-e2etest/testscenarios/demo/resources/another-demo.yaml b/testing/cli-e2etest/testscenarios/demo/resources/another-demo.yaml index 6411835f79..f4e72d2b16 100644 --- a/testing/cli-e2etest/testscenarios/demo/resources/another-demo.yaml +++ b/testing/cli-e2etest/testscenarios/demo/resources/another-demo.yaml @@ -1,6 +1,6 @@ type: Demo spec: - id: A_MsWrlVg + id: 2fnji3_VR name: another-dev type: pokeshop enabled: true diff --git a/testing/cli-e2etest/testscenarios/demo/resources/new-demo.yaml b/testing/cli-e2etest/testscenarios/demo/resources/new-demo.yaml index 466e667c3d..bcfd60d7d9 100644 --- a/testing/cli-e2etest/testscenarios/demo/resources/new-demo.yaml +++ b/testing/cli-e2etest/testscenarios/demo/resources/new-demo.yaml @@ -1,6 +1,6 @@ type: Demo spec: - id: z_GsWrlVR + id: NBnjm3_4R name: dev type: otelstore enabled: true diff --git a/testing/cli-e2etest/testscenarios/demo/resources/updated-new-demo.yaml b/testing/cli-e2etest/testscenarios/demo/resources/updated-new-demo.yaml index e0fe4ddad2..136a922e35 100644 --- a/testing/cli-e2etest/testscenarios/demo/resources/updated-new-demo.yaml +++ b/testing/cli-e2etest/testscenarios/demo/resources/updated-new-demo.yaml @@ -1,6 +1,6 @@ type: Demo spec: - id: 7fTPWr_4R + id: _889i3l4g name: dev-updated type: otelstore enabled: true diff --git a/testing/cli-e2etest/testscenarios/environment/resources/another-environment.yaml b/testing/cli-e2etest/testscenarios/environment/resources/another-environment.yaml index 31176a34d9..278d208042 100644 --- a/testing/cli-e2etest/testscenarios/environment/resources/another-environment.yaml +++ b/testing/cli-e2etest/testscenarios/environment/resources/another-environment.yaml @@ -3,7 +3,7 @@ spec: id: another-env name: another-env description: "" - createdAt: 2023-06-13T03:06:16.595942814Z + createdAt: 2023-06-13T21:30:23.736515668Z values: - key: Here value: We diff --git a/testing/cli-e2etest/testscenarios/environment/resources/new-environment.yaml b/testing/cli-e2etest/testscenarios/environment/resources/new-environment.yaml index 1bb4f25573..0153c854c0 100644 --- a/testing/cli-e2etest/testscenarios/environment/resources/new-environment.yaml +++ b/testing/cli-e2etest/testscenarios/environment/resources/new-environment.yaml @@ -3,7 +3,7 @@ spec: id: .env name: .env description: "" - createdAt: 2023-06-13T03:06:16.436643933Z + createdAt: 2023-06-13T21:30:23.72888471Z values: - key: FIRST_VAR value: some-value diff --git a/testing/cli-e2etest/testscenarios/environment/resources/one-more-environment.yaml b/testing/cli-e2etest/testscenarios/environment/resources/one-more-environment.yaml index ab042fd6dc..f633f144ca 100644 --- a/testing/cli-e2etest/testscenarios/environment/resources/one-more-environment.yaml +++ b/testing/cli-e2etest/testscenarios/environment/resources/one-more-environment.yaml @@ -3,7 +3,7 @@ spec: id: one-more-env name: one-more-env description: "" - createdAt: 2023-06-13T03:06:16.687232256Z + createdAt: 2023-06-13T21:30:23.743358168Z values: - key: This value: Is diff --git a/testing/cli-e2etest/testscenarios/environment/resources/updated-new-environment.yaml b/testing/cli-e2etest/testscenarios/environment/resources/updated-new-environment.yaml index f86b888453..dacd7f4b60 100644 --- a/testing/cli-e2etest/testscenarios/environment/resources/updated-new-environment.yaml +++ b/testing/cli-e2etest/testscenarios/environment/resources/updated-new-environment.yaml @@ -3,7 +3,7 @@ spec: id: .env name: .env description: "" - createdAt: 2023-06-13T03:05:55.969497Z + createdAt: 2023-06-13T21:30:10.439432Z values: - key: FIRST_VAR value: some-value diff --git a/testing/cli-e2etest/testscenarios/test/resources/environment-file.yaml b/testing/cli-e2etest/testscenarios/test/resources/environment-file.yaml index f16c3b67be..c5af472b7d 100644 --- a/testing/cli-e2etest/testscenarios/test/resources/environment-file.yaml +++ b/testing/cli-e2etest/testscenarios/test/resources/environment-file.yaml @@ -3,7 +3,7 @@ spec: id: pokeapi-env name: pokeapi-env description: "" - createdAt: 2023-06-13T03:08:45.057506Z + createdAt: 2023-06-13T21:32:12.710038Z values: - key: POKEMON_NAME value: snorlax diff --git a/testing/cli-e2etest/testscenarios/types/types.go b/testing/cli-e2etest/testscenarios/types/types.go index b153b1dcbe..c05a1812f2 100644 --- a/testing/cli-e2etest/testscenarios/types/types.go +++ b/testing/cli-e2etest/testscenarios/types/types.go @@ -96,3 +96,22 @@ type DemoResource struct { Type string `json:"type"` Spec Demo `json:"spec"` } + +type AnalyzerResource struct { + Type string `json:"type"` + Spec Analyzer `json:"spec"` +} + +type Analyzer struct { + Id string `json:"id"` + Name string `json:"name"` + Enabled bool `json:"enabled"` + MinimumScore int `json:"minimumScore"` + Plugins []AnalyzerPlugin `json:"plugins"` +} + +type AnalyzerPlugin struct { + Name string `json:"name"` + Enabled bool `json:"enabled"` + Required bool `json:"required"` +}