From f77b0bf0fc614951a199fb049db07832d833f4da Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Tue, 30 Apr 2024 11:52:42 -0400 Subject: [PATCH] Feature: Deployment scopes field and filter (#237) * deployment scopes field Signed-off-by: Michael Valdron * deployment scopes validation Signed-off-by: Michael Valdron * stack version deployment scopes Signed-off-by: Michael Valdron * deployment scope validation test cases Signed-off-by: Michael Valdron * deployment scopes and filter added to openapi spec Signed-off-by: Michael Valdron * update index/generator to include deployment scope schema field Signed-off-by: Michael Valdron * add deployment scopes parameter from openapi spec Signed-off-by: Michael Valdron * deployment scope filter logic and test cases Signed-off-by: Michael Valdron * fix naming convention of filter parameter name constants Signed-off-by: Michael Valdron * add deployment scopes parameter to RESTful API docs Signed-off-by: Michael Valdron * bump index/generator revision for registry library Signed-off-by: Michael Valdron * go mod index server Signed-off-by: Michael Valdron * bump index/generator revision for integration test suite Signed-off-by: Michael Valdron --------- Signed-off-by: Michael Valdron --- index/generator/library/library.go | 48 +++ index/generator/library/library_test.go | 126 ++++++++ index/generator/schema/schema.go | 75 +++-- index/server/go.mod | 1 + index/server/go.sum | 3 +- index/server/openapi.yaml | 22 ++ index/server/pkg/server/endpoint.gen.go | 121 ++++--- index/server/pkg/server/filter_test.go | 137 +++++++- index/server/pkg/server/types.gen.go | 17 + index/server/pkg/server/types.go | 2 + index/server/pkg/util/filter.go | 174 +++++----- index/server/pkg/util/filter_test.go | 304 ++++++++++++++++-- index/server/registry-REST-API.adoc | 9 + .../index/generator/library/library.go | 48 +++ .../index/generator/schema/schema.go | 75 +++-- index/server/vendor/modules.txt | 2 + registry-library/go.mod | 5 +- registry-library/go.sum | 1 - .../index/generator/schema/schema.go | 75 +++-- registry-library/vendor/modules.txt | 4 +- tests/integration/go.mod | 3 +- tests/integration/go.sum | 5 +- 22 files changed, 992 insertions(+), 265 deletions(-) diff --git a/index/generator/library/library.go b/index/generator/library/library.go index fb7e3f20a..b13927ff4 100644 --- a/index/generator/library/library.go +++ b/index/generator/library/library.go @@ -75,6 +75,35 @@ func (e *IconUrlBrokenError) Error() string { return fmt.Sprintf("Devfile %s has broken or not existing icon\n", e.devfile) } +// InvalidDeploymentScopes error type for when deploymentScopes contains any incorrect kinds +type InvalidDeploymentScopes struct { + devfile string + deploymentScopeKind schema.DeploymentScopeKind +} + +func (e *InvalidDeploymentScopes) Error() string { + return fmt.Sprintf("Deployment scope %s is incorrect for devfile %s, can only be '%s' or '%s'\n", + e.deploymentScopeKind, e.devfile, schema.InnerloopKind, schema.OuterloopKind) +} + +// TooManyDeploymentScopes error type for when there are deploymentScopes set at once +type TooManyDeploymentScopes struct { + devfile string +} + +func (e *TooManyDeploymentScopes) Error() string { + deploymentScopeKinds := []any{ + schema.InnerloopKind, + schema.OuterloopKind, + } + params := []any{ + e.devfile, + } + params = append(params, len(deploymentScopeKinds)) + params = append(params, deploymentScopeKinds...) + return fmt.Sprintf("Devfile %s has too many deployment scopes, can only be %s at most, '%s' or '%s'\n", params...) +} + // GenerateIndexStruct parses registry then generates index struct according to the schema func GenerateIndexStruct(registryDirPath string, force bool) ([]schema.Schema, error) { // Parse devfile registry then populate index struct @@ -193,6 +222,25 @@ func validateIndexComponent(indexComponent schema.Schema, componentType schema.D if len(indexComponent.Architectures) == 0 { return &MissingArchError{devfile: indexComponent.Name} } + if len(indexComponent.DeploymentScopes) > 2 { + return &TooManyDeploymentScopes{devfile: indexComponent.Name} + } + for kind := range indexComponent.DeploymentScopes { + if kind != schema.InnerloopKind && kind != schema.OuterloopKind { + return &InvalidDeploymentScopes{devfile: indexComponent.Name, deploymentScopeKind: kind} + } + } + for _, version := range indexComponent.Versions { + if len(version.DeploymentScopes) > 2 { + return &TooManyDeploymentScopes{devfile: indexComponent.Name} + } + + for kind := range version.DeploymentScopes { + if kind != schema.InnerloopKind && kind != schema.OuterloopKind { + return &InvalidDeploymentScopes{devfile: indexComponent.Name, deploymentScopeKind: kind} + } + } + } return nil } diff --git a/index/generator/library/library_test.go b/index/generator/library/library_test.go index 9bd15e2fe..72fdc2250 100644 --- a/index/generator/library/library_test.go +++ b/index/generator/library/library_test.go @@ -47,6 +47,8 @@ func TestValidateIndexComponent(t *testing.T) { schemaVersionEmptyErr := ".*schema version is empty.*" multipleVersionErr := ".*has multiple default versions.*" iconUrlBrokenErr := ".*has broken or not existing icon.*" + invalidDeploymentScopeErr := ".*Deployment scope \\S+ is incorrect for devfile \\S+.*" + tooManyDeploymentScopesErr := ".*has too many deployment scopes.*" tests := []struct { name string @@ -530,6 +532,130 @@ func TestValidateIndexComponent(t *testing.T) { schema.StackDevfileType, &iconUrlBrokenErr, }, + { + name: "Case 23: deployment scope has invalid kind", + indexComponent: schema.Schema{ + Name: "java-maven", + Icon: "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/java-maven.jpg", + Provider: "Red Hat", + SupportUrl: "https://devfile.io", + Architectures: []string{ + "amd64", + }, + Versions: []schema.Version{ + { + Version: "1.0.0", + SchemaVersion: "2.0.0", + Default: true, + Links: map[string]string{ + "self": "devfile-catalog/java-maven:latest", + }, + Resources: []string{ + "devfile.yaml", + }, + }, + }, + DeploymentScopes: map[schema.DeploymentScopeKind]bool{ + "foo": true, + }, + }, + componentType: schema.StackDevfileType, + wantErr: &invalidDeploymentScopeErr, + }, + { + name: "Case 24: deployment scope has invalid kind", + indexComponent: schema.Schema{ + Name: "java-maven", + Icon: "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/java-maven.jpg", + Provider: "Red Hat", + SupportUrl: "https://devfile.io", + Architectures: []string{ + "amd64", + }, + Versions: []schema.Version{ + { + Version: "1.0.0", + SchemaVersion: "2.0.0", + Default: true, + Links: map[string]string{ + "self": "devfile-catalog/java-maven:latest", + }, + Resources: []string{ + "devfile.yaml", + }, + }, + }, + DeploymentScopes: map[schema.DeploymentScopeKind]bool{ + schema.InnerloopKind: true, + schema.OuterloopKind: false, + "foo": false, + }, + }, + componentType: schema.StackDevfileType, + wantErr: &tooManyDeploymentScopesErr, + }, + { + name: "Case 25: version deployment scope has invalid kind", + indexComponent: schema.Schema{ + Name: "java-maven", + Icon: "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/java-maven.jpg", + Provider: "Red Hat", + SupportUrl: "https://devfile.io", + Architectures: []string{ + "amd64", + }, + Versions: []schema.Version{ + { + Version: "1.0.0", + SchemaVersion: "2.0.0", + Default: true, + Links: map[string]string{ + "self": "devfile-catalog/java-maven:latest", + }, + Resources: []string{ + "devfile.yaml", + }, + DeploymentScopes: map[schema.DeploymentScopeKind]bool{ + "foo": true, + }, + }, + }, + }, + componentType: schema.StackDevfileType, + wantErr: &invalidDeploymentScopeErr, + }, + { + name: "Case 26: version deployment scope has invalid kind", + indexComponent: schema.Schema{ + Name: "java-maven", + Icon: "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/java-maven.jpg", + Provider: "Red Hat", + SupportUrl: "https://devfile.io", + Architectures: []string{ + "amd64", + }, + Versions: []schema.Version{ + { + Version: "1.0.0", + SchemaVersion: "2.0.0", + Default: true, + Links: map[string]string{ + "self": "devfile-catalog/java-maven:latest", + }, + Resources: []string{ + "devfile.yaml", + }, + DeploymentScopes: map[schema.DeploymentScopeKind]bool{ + schema.InnerloopKind: true, + schema.OuterloopKind: false, + "foo": false, + }, + }, + }, + }, + componentType: schema.StackDevfileType, + wantErr: &tooManyDeploymentScopesErr, + }, } for _, tt := range tests { diff --git a/index/generator/schema/schema.go b/index/generator/schema/schema.go index 5abfaab11..126c90705 100644 --- a/index/generator/schema/schema.go +++ b/index/generator/schema/schema.go @@ -130,6 +130,7 @@ projectType: string - The project framework that is used in the devfile language: string - The project language that is used in the devfile links: map[string]string - Links related to the devfile commandGroups: map[CommandGroupKind]bool - The command groups that are used in the devfile +deploymentScopes: map[DeploymentScopeKind]bool - The deployment scope that are detected in the devfile resources: []string - The file resources that compose a devfile stack. starterProjects: string[] - The project templates that can be used in the devfile git: *git - The information of remote repositories @@ -139,26 +140,27 @@ versions: []Version - The list of stack versions information // Schema is the index file schema type Schema struct { - Name string `yaml:"name,omitempty" json:"name,omitempty"` - Version string `yaml:"version,omitempty" json:"version,omitempty"` - Attributes map[string]apiext.JSON `yaml:"attributes,omitempty" json:"attributes,omitempty"` - DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"` - Description string `yaml:"description,omitempty" json:"description,omitempty"` - Type DevfileType `yaml:"type,omitempty" json:"type,omitempty"` - Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` - Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` - Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` - GlobalMemoryLimit string `yaml:"globalMemoryLimit,omitempty" json:"globalMemoryLimit,omitempty"` - ProjectType string `yaml:"projectType,omitempty" json:"projectType,omitempty"` - Language string `yaml:"language,omitempty" json:"language,omitempty"` - Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` - CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` - Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` - StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` - Git *Git `yaml:"git,omitempty" json:"git,omitempty"` - Provider string `yaml:"provider,omitempty" json:"provider,omitempty"` - SupportUrl string `yaml:"supportUrl,omitempty" json:"supportUrl,omitempty"` - Versions []Version `yaml:"versions,omitempty" json:"versions,omitempty"` + Name string `yaml:"name,omitempty" json:"name,omitempty"` + Version string `yaml:"version,omitempty" json:"version,omitempty"` + Attributes map[string]apiext.JSON `yaml:"attributes,omitempty" json:"attributes,omitempty"` + DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + Type DevfileType `yaml:"type,omitempty" json:"type,omitempty"` + Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` + Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` + Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` + GlobalMemoryLimit string `yaml:"globalMemoryLimit,omitempty" json:"globalMemoryLimit,omitempty"` + ProjectType string `yaml:"projectType,omitempty" json:"projectType,omitempty"` + Language string `yaml:"language,omitempty" json:"language,omitempty"` + Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` + CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` + DeploymentScopes map[DeploymentScopeKind]bool `yaml:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` + StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` + Git *Git `yaml:"git,omitempty" json:"git,omitempty"` + Provider string `yaml:"provider,omitempty" json:"provider,omitempty"` + SupportUrl string `yaml:"supportUrl,omitempty" json:"supportUrl,omitempty"` + Versions []Version `yaml:"versions,omitempty" json:"versions,omitempty"` } // DevfileType describes the type of devfile @@ -183,6 +185,14 @@ const ( DeployCommandGroupKind CommandGroupKind = "deploy" ) +// DeploymentScopeKind describes the kind of deployment scope +type DeploymentScopeKind string + +const ( + InnerloopKind DeploymentScopeKind = "innerloop" + OuterloopKind DeploymentScopeKind = "outerloop" +) + // StarterProject is the devfile starter project type StarterProject struct { Name string `yaml:"name,omitempty" json:"name,omitempty"` @@ -241,16 +251,17 @@ type StackInfo struct { // Version stores the information for each stack version type Version struct { - Version string `yaml:"version,omitempty" json:"version,omitempty"` - SchemaVersion string `yaml:"schemaVersion,omitempty" json:"schemaVersion,omitempty"` - Default bool `yaml:"default,omitempty" json:"default,omitempty"` - Git *Git `yaml:"git,omitempty" json:"git,omitempty"` - Description string `yaml:"description,omitempty" json:"description,omitempty"` - Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` - Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` - Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` - Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` - CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` - Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` - StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` + Version string `yaml:"version,omitempty" json:"version,omitempty"` + SchemaVersion string `yaml:"schemaVersion,omitempty" json:"schemaVersion,omitempty"` + Default bool `yaml:"default,omitempty" json:"default,omitempty"` + Git *Git `yaml:"git,omitempty" json:"git,omitempty"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` + Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` + Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` + Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` + CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` + DeploymentScopes map[DeploymentScopeKind]bool `yaml:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` + StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` } diff --git a/index/server/go.mod b/index/server/go.mod index 70c620171..d1a59057c 100644 --- a/index/server/go.mod +++ b/index/server/go.mod @@ -127,6 +127,7 @@ require ( go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.uber.org/atomic v1.9.0 // indirect golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.16.0 // indirect diff --git a/index/server/go.sum b/index/server/go.sum index a56f2b359..0915d33b4 100644 --- a/index/server/go.sum +++ b/index/server/go.sum @@ -540,7 +540,8 @@ go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGX go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= diff --git a/index/server/openapi.yaml b/index/server/openapi.yaml index b0f9a8f8e..317a4b16c 100644 --- a/index/server/openapi.yaml +++ b/index/server/openapi.yaml @@ -268,6 +268,7 @@ paths: - $ref: '#/components/parameters/linkNamesParam' - $ref: '#/components/parameters/linksParam' - $ref: '#/components/parameters/commandGroupsParam' + - $ref: '#/components/parameters/deploymentScopesParam' - $ref: '#/components/parameters/gitRemoteNamesParam' - $ref: '#/components/parameters/gitRemotesParam' - $ref: '#/components/parameters/gitUrlParam' @@ -339,6 +340,7 @@ paths: - $ref: '#/components/parameters/linkNamesParam' - $ref: '#/components/parameters/linksParam' - $ref: '#/components/parameters/commandGroupsParam' + - $ref: '#/components/parameters/deploymentScopesParam' - $ref: '#/components/parameters/gitRemoteNamesParam' - $ref: '#/components/parameters/gitRemotesParam' - $ref: '#/components/parameters/gitUrlParam' @@ -860,6 +862,8 @@ components: $ref: '#/components/schemas/Links' commandGroups: $ref: '#/components/schemas/CommandGroups' + deploymentScopes: + $ref: '#/components/schemas/DeploymentScopes' gitRemoteNames: $ref: '#/components/schemas/GitRemoteNames' gitRemotes: @@ -979,6 +983,15 @@ components: - test - debug - deploy + DeploymentScopes: + description: List of deployment scopes that are detected in the devfile + type: array + uniqueItems: true + items: + type: string + enum: + - innerloop + - outerloop GitRemoteName: description: Git repository remote name type: string @@ -1167,6 +1180,15 @@ components: groups schema: $ref: '#/components/schemas/CommandGroups' + deploymentScopesParam: + name: deploymentScopes + in: query + required: false + description: |- + Collection of search strings to filter stacks by their present deployment + scopes + schema: + $ref: '#/components/schemas/DeploymentScopes' gitRemoteNamesParam: name: gitRemoteNames in: query diff --git a/index/server/pkg/server/endpoint.gen.go b/index/server/pkg/server/endpoint.gen.go index 66a9c4451..746dd1d8d 100644 --- a/index/server/pkg/server/endpoint.gen.go +++ b/index/server/pkg/server/endpoint.gen.go @@ -1483,6 +1483,14 @@ func (siw *ServerInterfaceWrapper) ServeDevfileIndexV2(c *gin.Context) { return } + // ------------- Optional query parameter "deploymentScopes" ------------- + + err = runtime.BindQueryParameter("form", true, false, "deploymentScopes", c.Request.URL.Query(), ¶ms.DeploymentScopes) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter deploymentScopes: %s", err), http.StatusBadRequest) + return + } + // ------------- Optional query parameter "gitRemoteNames" ------------- err = runtime.BindQueryParameter("form", true, false, "gitRemoteNames", c.Request.URL.Query(), ¶ms.GitRemoteNames) @@ -1780,6 +1788,14 @@ func (siw *ServerInterfaceWrapper) ServeDevfileIndexV2WithType(c *gin.Context) { return } + // ------------- Optional query parameter "deploymentScopes" ------------- + + err = runtime.BindQueryParameter("form", true, false, "deploymentScopes", c.Request.URL.Query(), ¶ms.DeploymentScopes) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter deploymentScopes: %s", err), http.StatusBadRequest) + return + } + // ------------- Optional query parameter "gitRemoteNames" ------------- err = runtime.BindQueryParameter("form", true, false, "gitRemoteNames", c.Request.URL.Query(), ¶ms.GitRemoteNames) @@ -2013,58 +2029,59 @@ var swaggerSpec = []string{ "kkCkfkFsigSopkhITuhMIMnQlCQSOBISRx8FmiyRnAPhSDUjEiKZcxBBGBAl61MOfBmEAcUpBBd61CAM", "RDSHFKuRv+EwDS6C/xuWWIfmqRj+VBO4WoUBlpKTSS7hLU5BHBE+UviEaj+mMUwJhRhNOcDZlPEUFcN2", "TquGqzZBIiHVCpfLTDU1QIJV6D7AnOOlnl3E0hTT+A1neSaOuzYZBwFUIjsEGtOZHqVjPjUk3uv1S62X", - "mlEMU5wnsmMuPzOWAKZN2GSqYC8R5oCsCMQ4okx24LWNvJG+su0NxoxDhCXEh8F0UrYhde12AFt0MXgL", - "cB2Ar6tW0WnxlT5Iwn034FK0P+Kyj4ZMRJbgpdoch0AmHFlJZrt2IS5H80dc6aMQz4i8gpSZDX0g5hmR", - "iGthGnYH6tqI3rjf1Ho1kJ/KRapfy2kJnymJ/eYk6pM66oRury73m88ec6nMY0HEgXu3MCojahPcosUO", - "eG0fC/g6n7wi/EC4EvMZSCTySUw4RJLxJRpTph2onUvGBFGfd8/GINllLraHncktT46g9ZwnGwzklife", - "AFVbBY1EneZww2azBBCjCGjEYoUuYlSqUJ5hIXQUaUOiRHrjuIzsaqtet5wcqCQlBeWcbIB2q5/6o1Pt", - "FcAE01mOZ4d65IyzGcdpqlo5kR1oK4/94P7uOmi8hH48kR8udo8aAwmW86jTcRUw/GdR9HDTODIh1ajH", - "dDvu3TAbvCm+v9Yfvge+wdfezAGl+J6keYpiWExJAsgIQwvTsQPXunxviPVeFqo/SK3E7dh2RVXDQ6i3", - "6gjdQ3Vr8g9RHaH+IL1UVwjcS3X0cKq4gR/SXWhhwQYzzv6CSN4ssyP4TCUJ6VNrO8TKYN5I31X6WMAL", - "EsNBfMMuthPVjdY99oZqOiicHKzrOq5bHFMnWLXodIzF6N7gr4oeCr2QmEvgVvmnjE52JGc+XRNaA+Tv", - "Fdb66cnlWcb4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ZufdthVGDhmKIYPugy52r7/ytNl9bsWf7aRWVPFr74SoalptWYcfQyqWVgV", + "iar1zS0VpeijWrWWDz88kmO4Aplzu90ziMiURHbWa8WctqDRsVX/EQoO25VZIh62v4fk07H13S+zpNp9", + "/sziZd1ZNVyBUo5tjSYsXqI0Vz+BSX3qvV6zj9H5+Xb7WK87rsLg5flL736NCu8qDL7bYdx6rb7u3d5A", + "mRucLCt2oeM0nikDcnXT4MNGT/e17u8uF/x16qMtNgztgePMvQqkH1SOOP7Ro340evKurhVO48jm8j+1", + "ANCJtj7/vWFXxaw2P32soPgaZDQH0dCRjZCmilBS4ZKI1QKnPg6NqT0//L8oIimmsUtTCISpKSotAD37", + "m2TPTY7BVTgRNun2325u3lWY4aaw21vmZ7DMz8QmdiUAHUX9kges5UnxDPSrAVMV9gfHjPddW6yI/XaT", + "FBYQ+MT83va/DK+8hcr0y/wlLHMrQ3uw4dKfif2HyHn5nYl/miW4XHL5rroevQVY+YrEftCK74l0fPwF", + "ZBx6UziOKfS5kS88N9JvlCfrM7dQn37lnujKbWYzJ8s89fZwtJDX0/SvNEfW76F+D/XZvJNm85Siw/oN", + "COExUnz91u237pNKRvYG2Rvk6dOm5kvV248M5nvCv8zBGtHjpvcab5DO619bbmVoGyB7BcW175t7B8NG", + "xqUB1mVazOt2WxItp9V8l0s65ajK7vSrmt4nVf3y4/sXwSOfSPQ7rc7kKl9HqaSV64cQtdnRmOp3WWuH", + "iI1niHJ2a15+CwMs72jyoIuNa0t9+qzfzurRp+3KZo9u5d0xPmMUd1l7NC4vJPRsXFwa6NG+cSWVR5/6", + "vX9ey1C/1Nejy9qNTh49Wm9R8plN/VZAzx7+rduugN2l205dimuWdgW2S6/qHaS+41SvWfUzy8rFYz6r", + "v3bN1BMoo9TvIdk7+grruO179DVC6vy22Lv8cbrAtOWscKqBi9g8fND/Kc+22jVOq6OLvThv67mlFjrN", + "NWDtnLuAszfdviwkrDoffHiCFMPVto/CMv7BaxP2jKhnRD0j6hlRz4hOwIgcF6qFHOWyDyVHPRvYndf1", + "OqtT0sVon4TR6LMmjFwKfNTB68a0JXm0F6kb9amjnih1VZf3qCvv3OXINeyTEMDa3yb7qghjy9+Z81Nx", + "y99J6/lpz0+7Auf6/akHMNT3o0dI240+V9puFJyQIx2QuBv1tPMEVE//+Yj2JN5+bK9P4fXMtGemPTPt", + "mWnPTHtm+kSY6anSpz0n24Nf9zqrHA30RaB84TSQ88Re8ykuhsU1yAMh8QwG7m8LETbUW72jca3Zh9X/", + "AgAA//9NQMEQeoAAAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/index/server/pkg/server/filter_test.go b/index/server/pkg/server/filter_test.go index 8bc3ee37c..3bd3b2e12 100644 --- a/index/server/pkg/server/filter_test.go +++ b/index/server/pkg/server/filter_test.go @@ -64,6 +64,10 @@ var testIndexSchema = []indexSchema.Schema{ indexSchema.BuildCommandGroupKind: true, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -80,6 +84,10 @@ var testIndexSchema = []indexSchema.Schema{ indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -106,6 +114,10 @@ var testIndexSchema = []indexSchema.Schema{ indexSchema.BuildCommandGroupKind: true, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Name: "devfileC", @@ -125,6 +137,10 @@ var testIndexSchema = []indexSchema.Schema{ indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v1.0.0", @@ -139,6 +155,10 @@ var testIndexSchema = []indexSchema.Schema{ indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -155,6 +175,10 @@ var testIndexSchema = []indexSchema.Schema{ indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -176,7 +200,7 @@ func TestFilterFieldbyParam(t *testing.T) { name: "Case 1: string parameter", index: testIndexSchema, v1Index: true, - paramName: util.PARAM_ICON, + paramName: util.ParamIcon, paramValue: ".jpg", wantIndex: []indexSchema.Schema{ { @@ -197,6 +221,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v1.0.0", @@ -211,6 +239,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -227,6 +259,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -235,7 +271,7 @@ func TestFilterFieldbyParam(t *testing.T) { { name: "Case 2: string parameter v2", index: testIndexSchema, - paramName: util.PARAM_ICON, + paramName: util.ParamIcon, paramValue: ".png", wantIndex: []indexSchema.Schema{ { @@ -266,6 +302,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -287,6 +327,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v1.0.0", @@ -301,6 +345,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -309,7 +357,7 @@ func TestFilterFieldbyParam(t *testing.T) { { name: "Case 3: Non-string parameter", index: testIndexSchema, - paramName: util.PARAM_DEFAULT, + paramName: util.ParamDefault, paramValue: true, wantIndex: []indexSchema.Schema{ { @@ -340,6 +388,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -361,6 +413,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v1.0.0", @@ -375,6 +431,10 @@ func TestFilterFieldbyParam(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -460,6 +520,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.BuildCommandGroupKind: true, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -476,6 +540,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -497,6 +565,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v1.0.0", @@ -511,6 +583,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -527,6 +603,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -571,6 +651,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.BuildCommandGroupKind: true, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -587,6 +671,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -608,6 +696,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v1.0.0", @@ -622,6 +714,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -638,6 +734,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -675,6 +775,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v1.0.0", @@ -689,6 +793,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -705,6 +813,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -719,6 +831,9 @@ func TestFilterFieldsByParams(t *testing.T) { string(indexSchema.BuildCommandGroupKind), string(indexSchema.RunCommandGroupKind), }, + DeploymentScopes: &[]string{ + string(indexSchema.InnerloopKind), + }, }, wantIndex: []indexSchema.Schema{ { @@ -750,6 +865,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.BuildCommandGroupKind: true, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, { Version: "v2.0.0", @@ -766,6 +885,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, @@ -787,6 +910,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.DeployCommandGroupKind: false, indexSchema.RunCommandGroupKind: true, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, Versions: []indexSchema.Version{ { Version: "v2.0.0", @@ -803,6 +930,10 @@ func TestFilterFieldsByParams(t *testing.T) { indexSchema.RunCommandGroupKind: true, indexSchema.TestCommandGroupKind: false, }, + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, }, }, }, diff --git a/index/server/pkg/server/types.gen.go b/index/server/pkg/server/types.gen.go index 945257b9b..1d9a654c1 100644 --- a/index/server/pkg/server/types.gen.go +++ b/index/server/pkg/server/types.gen.go @@ -32,6 +32,9 @@ type CommandGroups = []string // Default Flag for default devfile registry entry version type Default = bool +// DeploymentScopes List of deployment scopes that are detected in the devfile +type DeploymentScopes = []string + // Deprecated Flag for deprecated devfile registry entry type Deprecated = bool @@ -79,6 +82,9 @@ type IndexParams struct { // Default Flag for default devfile registry entry version Default *Default `json:"default,omitempty"` + // DeploymentScopes List of deployment scopes that are detected in the devfile + DeploymentScopes *DeploymentScopes `json:"deploymentScopes,omitempty"` + // Deprecated Flag for deprecated devfile registry entry Deprecated *Deprecated `json:"deprecated,omitempty"` @@ -206,6 +212,9 @@ type CommandGroupsParam = CommandGroups // DefaultParam Flag for default devfile registry entry version type DefaultParam = Default +// DeploymentScopesParam List of deployment scopes that are detected in the devfile +type DeploymentScopesParam = DeploymentScopes + // DeprecatedParam Flag for deprecated devfile registry entry type DeprecatedParam = Deprecated @@ -578,6 +587,10 @@ type ServeDevfileIndexV2Params struct { // groups CommandGroups *CommandGroupsParam `form:"commandGroups,omitempty" json:"commandGroups,omitempty"` + // DeploymentScopes Collection of search strings to filter stacks by their present deployment + // scopes + DeploymentScopes *DeploymentScopesParam `form:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + // GitRemoteNames Collection of search strings to filter stacks by the names of // the git remotes GitRemoteNames *GitRemoteNamesParam `form:"gitRemoteNames,omitempty" json:"gitRemoteNames,omitempty"` @@ -677,6 +690,10 @@ type ServeDevfileIndexV2WithTypeParams struct { // groups CommandGroups *CommandGroupsParam `form:"commandGroups,omitempty" json:"commandGroups,omitempty"` + // DeploymentScopes Collection of search strings to filter stacks by their present deployment + // scopes + DeploymentScopes *DeploymentScopesParam `form:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + // GitRemoteNames Collection of search strings to filter stacks by the names of // the git remotes GitRemoteNames *GitRemoteNamesParam `form:"gitRemoteNames,omitempty" json:"gitRemoteNames,omitempty"` diff --git a/index/server/pkg/server/types.go b/index/server/pkg/server/types.go index 67383f85a..08cec1662 100644 --- a/index/server/pkg/server/types.go +++ b/index/server/pkg/server/types.go @@ -36,6 +36,7 @@ func (params *ServeDevfileIndexV2Params) toIndexParams() IndexParams { LinkNames: params.LinkNames, Links: params.Links, CommandGroups: params.CommandGroups, + DeploymentScopes: params.DeploymentScopes, GitRemoteNames: params.GitRemoteNames, GitRemotes: params.GitRemotes, GitUrl: params.GitUrl, @@ -70,6 +71,7 @@ func (params *ServeDevfileIndexV2WithTypeParams) toIndexParams() IndexParams { LinkNames: params.LinkNames, Links: params.Links, CommandGroups: params.CommandGroups, + DeploymentScopes: params.DeploymentScopes, GitRemoteNames: params.GitRemoteNames, GitRemotes: params.GitRemotes, GitUrl: params.GitUrl, diff --git a/index/server/pkg/util/filter.go b/index/server/pkg/util/filter.go index f3008b42f..76f574181 100644 --- a/index/server/pkg/util/filter.go +++ b/index/server/pkg/util/filter.go @@ -30,63 +30,65 @@ const ( /* Array empty strategies */ // Filters out entries with empty field - ARRAY_FILTER_IF_EMPTY = iota + ArrayFilterIfEmpty = iota // Omits entries from filtering with empty field (leaves entries in result) - ARRAY_SKIP_IF_EMPTY = iota + ArraySkipIfEmpty = iota /* Parameter Names */ // Parameter 'name' - PARAM_NAME = "name" + ParamName = "name" // Parameter 'displayName' - PARAM_DISPLAY_NAME = "displayName" + ParamDisplayName = "displayName" // Parameter 'description' - PARAM_DESCRIPTION = "description" + ParamDescription = "description" // Parameter 'icon' - PARAM_ICON = "iconUri" + ParamIcon = "iconUri" // Parameter 'projectType' - PARAM_PROJECT_TYPE = "projectType" + ParamProjectType = "projectType" // Parameter 'language' - PARAM_LANGUAGE = "language" + ParamLanguage = "language" // Parameter 'version' - PARAM_VERSION = "version" + ParamVersion = "version" // Parameter 'schemaVersion' - PARAM_SCHEMA_VERSION = "schemaVersion" + ParamSchemaVersion = "schemaVersion" // Parameter 'default' - PARAM_DEFAULT = "default" + ParamDefault = "default" // Parameter 'git.url' - PARAM_GIT_URL = "gitUrl" + ParamGitUrl = "gitUrl" // Parameter 'git.remoteName' - PARAM_GIT_REMOTE_NAME = "gitRemoteName" + ParamGitRemoteName = "gitRemoteName" // Parameter 'git.subDir' - PARAM_GIT_SUBDIR = "gitSubDir" + ParamGitSubDir = "gitSubDir" // Parameter 'git.revision' - PARAM_GIT_REVISION = "gitRevision" + ParamGitRevision = "gitRevision" // Parameter 'provider' - PARAM_PROVIDER = "provider" + ParamProvider = "provider" // Parameter 'supportUrl' - PARAM_SUPPORT_URL = "supportUrl" + ParamSupportUrl = "supportUrl" /* Array Parameter Names */ // Parameter 'attributeNames' - ARRAY_PARAM_ATTRIBUTE_NAMES = "attributeNames" + ArrayParamAttributeNames = "attributeNames" // Parameter 'tags' - ARRAY_PARAM_TAGS = "tags" + ArrayParamTags = "tags" // Parameter 'architectures' - ARRAY_PARAM_ARCHITECTURES = "arch" + ArrayParamArchitectures = "arch" // Parameter 'resources' - ARRAY_PARAM_RESOURCES = "resources" + ArrayParamResources = "resources" // Parameter 'starterProjects' - ARRAY_PARAM_STARTER_PROJECTS = "starterProjects" + ArrayParamStarterProjects = "starterProjects" // Parameter 'links' - ARRAY_PARAM_LINKS = "links" + ArrayParamLinks = "links" // Parameter 'commandGroups' - ARRAY_PARAM_COMMAND_GROUPS = "commandGroups" + ArrayParamCommandGroups = "commandGroups" + // Parameter 'deploymentScopes' + ArrayParamDeploymentScopes = "deploymentScopes" // Parameter 'gitRemoteNames' - ARRAY_PARAM_GIT_REMOTE_NAMES = "gitRemoteNames" + ArrayParamGitRemoteNames = "gitRemoteNames" // Parameter 'gitRemotes' - ARRAY_PARAM_GIT_REMOTES = "gitRemotes" + ArrayParamGitRemotes = "gitRemotes" ) // FilterResult result entity of filtering the index schema @@ -301,21 +303,21 @@ func filterDevfileArrayFuzzy(index []indexSchema.Schema, requestedValues []strin func IsFieldParameter(name string) bool { parameterNames := sets.From([]string{ - PARAM_NAME, - PARAM_DISPLAY_NAME, - PARAM_DESCRIPTION, - PARAM_ICON, - PARAM_PROJECT_TYPE, - PARAM_LANGUAGE, - PARAM_VERSION, - PARAM_SCHEMA_VERSION, - PARAM_DEFAULT, - PARAM_GIT_URL, - PARAM_GIT_REMOTE_NAME, - PARAM_GIT_SUBDIR, - PARAM_GIT_REVISION, - PARAM_PROVIDER, - PARAM_SUPPORT_URL, + ParamName, + ParamDisplayName, + ParamDescription, + ParamIcon, + ParamProjectType, + ParamLanguage, + ParamVersion, + ParamSchemaVersion, + ParamDefault, + ParamGitUrl, + ParamGitRemoteName, + ParamGitSubDir, + ParamGitRevision, + ParamProvider, + ParamSupportUrl, }) return parameterNames.Contains(name) @@ -323,15 +325,16 @@ func IsFieldParameter(name string) bool { func IsArrayParameter(name string) bool { parameterNames := sets.From([]string{ - ARRAY_PARAM_ATTRIBUTE_NAMES, - ARRAY_PARAM_ARCHITECTURES, - ARRAY_PARAM_TAGS, - ARRAY_PARAM_RESOURCES, - ARRAY_PARAM_STARTER_PROJECTS, - ARRAY_PARAM_LINKS, - ARRAY_PARAM_COMMAND_GROUPS, - ARRAY_PARAM_GIT_REMOTE_NAMES, - ARRAY_PARAM_GIT_REMOTES, + ArrayParamAttributeNames, + ArrayParamArchitectures, + ArrayParamTags, + ArrayParamResources, + ArrayParamStarterProjects, + ArrayParamLinks, + ArrayParamCommandGroups, + ArrayParamDeploymentScopes, + ArrayParamGitRemoteNames, + ArrayParamGitRemotes, }) return parameterNames.Contains(name) @@ -469,85 +472,85 @@ func FilterDevfileStrField(index []indexSchema.Schema, paramName, requestedValue V1Index: v1Index, } switch paramName { - case PARAM_NAME: + case ParamName: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Name } - case PARAM_DISPLAY_NAME: + case ParamDisplayName: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.DisplayName } - case PARAM_DESCRIPTION: + case ParamDescription: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Description } options.GetFromVersionField = func(v *indexSchema.Version) string { return v.Description } - case PARAM_ICON: + case ParamIcon: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Icon } options.GetFromVersionField = func(v *indexSchema.Version) string { return v.Icon } - case PARAM_PROJECT_TYPE: + case ParamProjectType: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.ProjectType } - case PARAM_LANGUAGE: + case ParamLanguage: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Language } - case PARAM_VERSION: + case ParamVersion: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Version } options.GetFromVersionField = func(v *indexSchema.Version) string { return v.Version } - case PARAM_SCHEMA_VERSION: + case ParamSchemaVersion: options.GetFromVersionField = func(v *indexSchema.Version) string { return v.SchemaVersion } - case PARAM_DEFAULT: + case ParamDefault: options.GetFromIndexField = nil options.GetFromVersionField = func(v *indexSchema.Version) string { return fmt.Sprintf("%v", v.Default) } - case PARAM_GIT_URL: + case ParamGitUrl: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Git.Url } options.GetFromVersionField = func(v *indexSchema.Version) string { return v.Git.Url } - case PARAM_GIT_REMOTE_NAME: + case ParamGitRemoteName: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Git.RemoteName } options.GetFromVersionField = func(v *indexSchema.Version) string { return v.Git.RemoteName } - case PARAM_GIT_SUBDIR: + case ParamGitSubDir: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Git.SubDir } options.GetFromVersionField = func(v *indexSchema.Version) string { return v.Git.SubDir } - case PARAM_GIT_REVISION: + case ParamGitRevision: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Git.Revision } options.GetFromVersionField = func(v *indexSchema.Version) string { return v.Git.Revision } - case PARAM_PROVIDER: + case ParamProvider: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.Provider } - case PARAM_SUPPORT_URL: + case ParamSupportUrl: options.GetFromIndexField = func(s *indexSchema.Schema) string { return s.SupportUrl } @@ -629,7 +632,7 @@ func FilterDevfileStrArrayField(index []indexSchema.Schema, paramName string, re V1Index: v1Index, } switch paramName { - case ARRAY_PARAM_ATTRIBUTE_NAMES: + case ArrayParamAttributeNames: options.GetFromIndexField = func(s *indexSchema.Schema) []string { names := []string{} @@ -639,7 +642,7 @@ func FilterDevfileStrArrayField(index []indexSchema.Schema, paramName string, re return names } - case ARRAY_PARAM_ARCHITECTURES: + case ArrayParamArchitectures: options.GetFromIndexField = func(s *indexSchema.Schema) []string { return s.Architectures } @@ -647,28 +650,28 @@ func FilterDevfileStrArrayField(index []indexSchema.Schema, paramName string, re return v.Architectures } options.FilterOutEmpty = false - case ARRAY_PARAM_TAGS: + case ArrayParamTags: options.GetFromIndexField = func(s *indexSchema.Schema) []string { return s.Tags } options.GetFromVersionField = func(v *indexSchema.Version) []string { return v.Tags } - case ARRAY_PARAM_RESOURCES: + case ArrayParamResources: options.GetFromIndexField = func(s *indexSchema.Schema) []string { return s.Resources } options.GetFromVersionField = func(v *indexSchema.Version) []string { return v.Resources } - case ARRAY_PARAM_STARTER_PROJECTS: + case ArrayParamStarterProjects: options.GetFromIndexField = func(s *indexSchema.Schema) []string { return s.StarterProjects } options.GetFromVersionField = func(v *indexSchema.Version) []string { return v.StarterProjects } - case ARRAY_PARAM_LINKS: + case ArrayParamLinks: options.GetFromIndexField = func(s *indexSchema.Schema) []string { links := []string{} @@ -687,7 +690,7 @@ func FilterDevfileStrArrayField(index []indexSchema.Schema, paramName string, re return links } - case ARRAY_PARAM_COMMAND_GROUPS: + case ArrayParamCommandGroups: options.GetFromIndexField = func(s *indexSchema.Schema) []string { commandGroups := []string{} @@ -710,7 +713,30 @@ func FilterDevfileStrArrayField(index []indexSchema.Schema, paramName string, re return commandGroups } - case ARRAY_PARAM_GIT_REMOTE_NAMES: + case ArrayParamDeploymentScopes: + options.GetFromIndexField = func(s *indexSchema.Schema) []string { + deploymentScopes := []string{} + + for deploymentScope, isSet := range s.DeploymentScopes { + if isSet { + deploymentScopes = append(deploymentScopes, string(deploymentScope)) + } + } + + return deploymentScopes + } + options.GetFromVersionField = func(v *indexSchema.Version) []string { + deploymentScopes := []string{} + + for deploymentScope, isSet := range v.DeploymentScopes { + if isSet { + deploymentScopes = append(deploymentScopes, string(deploymentScope)) + } + } + + return deploymentScopes + } + case ArrayParamGitRemoteNames: options.GetFromIndexField = func(s *indexSchema.Schema) []string { gitRemoteNames := []string{} @@ -733,7 +759,7 @@ func FilterDevfileStrArrayField(index []indexSchema.Schema, paramName string, re return gitRemoteNames } - case ARRAY_PARAM_GIT_REMOTES: + case ArrayParamGitRemotes: options.GetFromIndexField = func(s *indexSchema.Schema) []string { gitRemotes := []string{} diff --git a/index/server/pkg/util/filter_test.go b/index/server/pkg/util/filter_test.go index d381d9be1..2fdef3405 100644 --- a/index/server/pkg/util/filter_test.go +++ b/index/server/pkg/util/filter_test.go @@ -56,7 +56,7 @@ var ( filterAttributeNamesTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two attribute filters", - FieldName: ARRAY_PARAM_ATTRIBUTE_NAMES, + FieldName: ArrayParamAttributeNames, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -114,7 +114,7 @@ var ( }, { Name: "two attribute filters v2", - FieldName: ARRAY_PARAM_ATTRIBUTE_NAMES, + FieldName: ArrayParamAttributeNames, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -189,7 +189,7 @@ var ( filterArchitecturesTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two arch filters", - FieldName: ARRAY_PARAM_ARCHITECTURES, + FieldName: ArrayParamArchitectures, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -217,7 +217,7 @@ var ( }, { Name: "two arch filters with v2 index", - FieldName: ARRAY_PARAM_ARCHITECTURES, + FieldName: ArrayParamArchitectures, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -263,7 +263,7 @@ var ( filterTagsTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two tag filters", - FieldName: ARRAY_PARAM_TAGS, + FieldName: ArrayParamTags, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -288,7 +288,7 @@ var ( }, { Name: "two tag filters with v2 index", - FieldName: ARRAY_PARAM_TAGS, + FieldName: ArrayParamTags, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -335,7 +335,7 @@ var ( filterResourcesTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two resource filters", - FieldName: ARRAY_PARAM_RESOURCES, + FieldName: ArrayParamResources, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -368,7 +368,7 @@ var ( }, { Name: "two resource filters with v2 index", - FieldName: ARRAY_PARAM_RESOURCES, + FieldName: ArrayParamResources, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -433,7 +433,7 @@ var ( filterStarterProjectsTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two starter project filters", - FieldName: ARRAY_PARAM_STARTER_PROJECTS, + FieldName: ArrayParamStarterProjects, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -462,7 +462,7 @@ var ( }, { Name: "two starter project filters with v2 index", - FieldName: ARRAY_PARAM_STARTER_PROJECTS, + FieldName: ArrayParamStarterProjects, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -535,7 +535,7 @@ var ( filterLinksTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two link filters", - FieldName: ARRAY_PARAM_LINKS, + FieldName: ArrayParamLinks, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -584,7 +584,7 @@ var ( }, { Name: "two link filters with v2 index", - FieldName: ARRAY_PARAM_LINKS, + FieldName: ArrayParamLinks, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -678,7 +678,7 @@ var ( filterCommandGroupsTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two command group filters", - FieldName: ARRAY_PARAM_COMMAND_GROUPS, + FieldName: ArrayParamCommandGroups, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -732,7 +732,7 @@ var ( }, { Name: "two command group filters with v2 index", - FieldName: ARRAY_PARAM_COMMAND_GROUPS, + FieldName: ArrayParamCommandGroups, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -850,10 +850,255 @@ var ( }, }, } + filterDeploymentScopesTestCases = []filterDevfileStrArrayFieldTestCase{ + { + Name: "innerloop filters v2 index", + FieldName: ArrayParamDeploymentScopes, + Index: []indexSchema.Schema{ + { + Name: "devfileA", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileB", + Versions: []indexSchema.Version{ + { + Version: "2.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, + }, + }, + }, + { + Name: "devfileC", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + }, + Versions: []indexSchema.Version{ + { + Version: "1.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + }, + }, + { + Name: "devfileD", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileE", + }, + }, + V1Index: false, + Values: []string{string(indexSchema.InnerloopKind)}, + WantIndex: []indexSchema.Schema{ + { + Name: "devfileA", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileB", + Versions: []indexSchema.Version{ + { + Version: "2.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, + }, + }, + }, + { + Name: "devfileC", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + }, + Versions: []indexSchema.Version{ + { + Version: "1.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + }, + }, + }, + }, + { + Name: "outerloop filters v2 index", + FieldName: ArrayParamDeploymentScopes, + Index: []indexSchema.Schema{ + { + Name: "devfileA", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileB", + Versions: []indexSchema.Version{ + { + Version: "2.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, + }, + }, + }, + { + Name: "devfileC", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + }, + Versions: []indexSchema.Version{ + { + Version: "1.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + }, + }, + { + Name: "devfileD", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileE", + }, + }, + V1Index: false, + Values: []string{string(indexSchema.OuterloopKind)}, + WantIndex: []indexSchema.Schema{ + { + Name: "devfileA", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileC", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + }, + Versions: []indexSchema.Version{ + { + Version: "1.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + }, + }, + { + Name: "devfileD", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.OuterloopKind: true, + }, + }, + }, + }, + { + Name: "all deployment scopes filters v2 index", + FieldName: ArrayParamDeploymentScopes, + Index: []indexSchema.Schema{ + { + Name: "devfileA", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileB", + Versions: []indexSchema.Version{ + { + Version: "2.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: false, + }, + }, + }, + }, + { + Name: "devfileC", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + }, + Versions: []indexSchema.Version{ + { + Version: "1.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + }, + }, + { + Name: "devfileD", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileE", + }, + }, + V1Index: false, + Values: []string{string(indexSchema.InnerloopKind), string(indexSchema.OuterloopKind)}, + WantIndex: []indexSchema.Schema{ + { + Name: "devfileA", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + { + Name: "devfileC", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + }, + Versions: []indexSchema.Version{ + { + Version: "1.0.0", + DeploymentScopes: map[indexSchema.DeploymentScopeKind]bool{ + indexSchema.InnerloopKind: true, + indexSchema.OuterloopKind: true, + }, + }, + }, + }, + }, + }, + } filterGitRemoteNamesTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two git remote name filters", - FieldName: ARRAY_PARAM_GIT_REMOTE_NAMES, + FieldName: ArrayParamGitRemoteNames, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -918,7 +1163,7 @@ var ( }, { Name: "two git remote name filters with v2 index", - FieldName: ARRAY_PARAM_GIT_REMOTE_NAMES, + FieldName: ArrayParamGitRemoteNames, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1036,7 +1281,7 @@ var ( filterGitRemotesTestCases = []filterDevfileStrArrayFieldTestCase{ { Name: "two git remote filters", - FieldName: ARRAY_PARAM_GIT_REMOTES, + FieldName: ArrayParamGitRemotes, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1109,7 +1354,7 @@ var ( }, { Name: "two git remote filters with v2 index", - FieldName: ARRAY_PARAM_GIT_REMOTES, + FieldName: ArrayParamGitRemotes, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1238,7 +1483,7 @@ var ( filterNameFieldTestCases = []filterDevfileStrFieldTestCase{ { Name: "name filter", - FieldName: PARAM_NAME, + FieldName: ParamName, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1267,7 +1512,7 @@ var ( }, { Name: "name filter v2", - FieldName: PARAM_NAME, + FieldName: ParamName, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1297,7 +1542,7 @@ var ( filterDisplayNameFieldTestCases = []filterDevfileStrFieldTestCase{ { Name: "display name filter", - FieldName: PARAM_DISPLAY_NAME, + FieldName: ParamDisplayName, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1332,7 +1577,7 @@ var ( }, { Name: "display name filter v2", - FieldName: PARAM_DISPLAY_NAME, + FieldName: ParamDisplayName, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1368,7 +1613,7 @@ var ( filterDescriptionFieldTestCases = []filterDevfileStrFieldTestCase{ { Name: "description filter", - FieldName: PARAM_DESCRIPTION, + FieldName: ParamDescription, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1409,7 +1654,7 @@ var ( }, { Name: "description filter v2", - FieldName: PARAM_DESCRIPTION, + FieldName: ParamDescription, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1488,7 +1733,7 @@ var ( filterIconFieldTestCases = []filterDevfileStrFieldTestCase{ { Name: "icon filter", - FieldName: PARAM_ICON, + FieldName: ParamIcon, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1529,7 +1774,7 @@ var ( }, { Name: "icon filter v2", - FieldName: PARAM_ICON, + FieldName: ParamIcon, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1596,7 +1841,7 @@ var ( filterProjectTypeFieldTestCases = []filterDevfileStrFieldTestCase{ { Name: "project type filter", - FieldName: PARAM_PROJECT_TYPE, + FieldName: ParamProjectType, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1637,7 +1882,7 @@ var ( }, { Name: "project type filter v2", - FieldName: PARAM_PROJECT_TYPE, + FieldName: ParamProjectType, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -1679,7 +1924,7 @@ var ( filterLanguageFieldTestCases = []filterDevfileStrFieldTestCase{ { Name: "language filter", - FieldName: PARAM_LANGUAGE, + FieldName: ParamLanguage, Index: []indexSchema.Schema{ { Name: "devfileA", @@ -2771,6 +3016,7 @@ func TestFilterDevfileStrArrayField(t *testing.T) { tests = append(tests, filterStarterProjectsTestCases...) tests = append(tests, filterLinksTestCases...) tests = append(tests, filterCommandGroupsTestCases...) + tests = append(tests, filterDeploymentScopesTestCases...) tests = append(tests, filterGitRemoteNamesTestCases...) tests = append(tests, filterGitRemotesTestCases...) diff --git a/index/server/registry-REST-API.adoc b/index/server/registry-REST-API.adoc index 67044c4df..9ccf725e5 100644 --- a/index/server/registry-REST-API.adoc +++ b/index/server/registry-REST-API.adoc @@ -1624,6 +1624,9 @@ curl http://devfile-registry.192.168.1.1.nip.io/v2index?minSchemaVersion=2.1&max |CommandGroups |Collection of search strings to filter stacks by their present command groups +|DeploymentScopes +|Collection of search strings to filter stacks by their present deployment scopes + |GitRemoteNames |Collection of search strings to filter stacks by the names of the git remotes @@ -1971,6 +1974,9 @@ curl http://devfile-registry.192.168.1.1.nip.io/v2index/sample?maxSchemaVersion= |CommandGroups |Collection of search strings to filter samples by their present command groups +|DeploymentScopes +|Collection of search strings to filter stacks by their present deployment scopes + |GitRemoteNames |Collection of search strings to filter samples by the names of the git remotes @@ -2615,6 +2621,9 @@ curl http://devfile-registry.192.168.1.1.nip.io/v2index/sample?minSchemaVersion= |CommandGroups |Collection of search strings to filter stacks/samples by their present command groups +|DeploymentScopes +|Collection of search strings to filter stacks by their present deployment scopes + |GitRemoteNames |Collection of search strings to filter stacks/samples by the names of the git remotes diff --git a/index/server/vendor/github.com/devfile/registry-support/index/generator/library/library.go b/index/server/vendor/github.com/devfile/registry-support/index/generator/library/library.go index fb7e3f20a..b13927ff4 100644 --- a/index/server/vendor/github.com/devfile/registry-support/index/generator/library/library.go +++ b/index/server/vendor/github.com/devfile/registry-support/index/generator/library/library.go @@ -75,6 +75,35 @@ func (e *IconUrlBrokenError) Error() string { return fmt.Sprintf("Devfile %s has broken or not existing icon\n", e.devfile) } +// InvalidDeploymentScopes error type for when deploymentScopes contains any incorrect kinds +type InvalidDeploymentScopes struct { + devfile string + deploymentScopeKind schema.DeploymentScopeKind +} + +func (e *InvalidDeploymentScopes) Error() string { + return fmt.Sprintf("Deployment scope %s is incorrect for devfile %s, can only be '%s' or '%s'\n", + e.deploymentScopeKind, e.devfile, schema.InnerloopKind, schema.OuterloopKind) +} + +// TooManyDeploymentScopes error type for when there are deploymentScopes set at once +type TooManyDeploymentScopes struct { + devfile string +} + +func (e *TooManyDeploymentScopes) Error() string { + deploymentScopeKinds := []any{ + schema.InnerloopKind, + schema.OuterloopKind, + } + params := []any{ + e.devfile, + } + params = append(params, len(deploymentScopeKinds)) + params = append(params, deploymentScopeKinds...) + return fmt.Sprintf("Devfile %s has too many deployment scopes, can only be %s at most, '%s' or '%s'\n", params...) +} + // GenerateIndexStruct parses registry then generates index struct according to the schema func GenerateIndexStruct(registryDirPath string, force bool) ([]schema.Schema, error) { // Parse devfile registry then populate index struct @@ -193,6 +222,25 @@ func validateIndexComponent(indexComponent schema.Schema, componentType schema.D if len(indexComponent.Architectures) == 0 { return &MissingArchError{devfile: indexComponent.Name} } + if len(indexComponent.DeploymentScopes) > 2 { + return &TooManyDeploymentScopes{devfile: indexComponent.Name} + } + for kind := range indexComponent.DeploymentScopes { + if kind != schema.InnerloopKind && kind != schema.OuterloopKind { + return &InvalidDeploymentScopes{devfile: indexComponent.Name, deploymentScopeKind: kind} + } + } + for _, version := range indexComponent.Versions { + if len(version.DeploymentScopes) > 2 { + return &TooManyDeploymentScopes{devfile: indexComponent.Name} + } + + for kind := range version.DeploymentScopes { + if kind != schema.InnerloopKind && kind != schema.OuterloopKind { + return &InvalidDeploymentScopes{devfile: indexComponent.Name, deploymentScopeKind: kind} + } + } + } return nil } diff --git a/index/server/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go b/index/server/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go index 5abfaab11..126c90705 100644 --- a/index/server/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go +++ b/index/server/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go @@ -130,6 +130,7 @@ projectType: string - The project framework that is used in the devfile language: string - The project language that is used in the devfile links: map[string]string - Links related to the devfile commandGroups: map[CommandGroupKind]bool - The command groups that are used in the devfile +deploymentScopes: map[DeploymentScopeKind]bool - The deployment scope that are detected in the devfile resources: []string - The file resources that compose a devfile stack. starterProjects: string[] - The project templates that can be used in the devfile git: *git - The information of remote repositories @@ -139,26 +140,27 @@ versions: []Version - The list of stack versions information // Schema is the index file schema type Schema struct { - Name string `yaml:"name,omitempty" json:"name,omitempty"` - Version string `yaml:"version,omitempty" json:"version,omitempty"` - Attributes map[string]apiext.JSON `yaml:"attributes,omitempty" json:"attributes,omitempty"` - DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"` - Description string `yaml:"description,omitempty" json:"description,omitempty"` - Type DevfileType `yaml:"type,omitempty" json:"type,omitempty"` - Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` - Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` - Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` - GlobalMemoryLimit string `yaml:"globalMemoryLimit,omitempty" json:"globalMemoryLimit,omitempty"` - ProjectType string `yaml:"projectType,omitempty" json:"projectType,omitempty"` - Language string `yaml:"language,omitempty" json:"language,omitempty"` - Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` - CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` - Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` - StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` - Git *Git `yaml:"git,omitempty" json:"git,omitempty"` - Provider string `yaml:"provider,omitempty" json:"provider,omitempty"` - SupportUrl string `yaml:"supportUrl,omitempty" json:"supportUrl,omitempty"` - Versions []Version `yaml:"versions,omitempty" json:"versions,omitempty"` + Name string `yaml:"name,omitempty" json:"name,omitempty"` + Version string `yaml:"version,omitempty" json:"version,omitempty"` + Attributes map[string]apiext.JSON `yaml:"attributes,omitempty" json:"attributes,omitempty"` + DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + Type DevfileType `yaml:"type,omitempty" json:"type,omitempty"` + Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` + Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` + Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` + GlobalMemoryLimit string `yaml:"globalMemoryLimit,omitempty" json:"globalMemoryLimit,omitempty"` + ProjectType string `yaml:"projectType,omitempty" json:"projectType,omitempty"` + Language string `yaml:"language,omitempty" json:"language,omitempty"` + Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` + CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` + DeploymentScopes map[DeploymentScopeKind]bool `yaml:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` + StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` + Git *Git `yaml:"git,omitempty" json:"git,omitempty"` + Provider string `yaml:"provider,omitempty" json:"provider,omitempty"` + SupportUrl string `yaml:"supportUrl,omitempty" json:"supportUrl,omitempty"` + Versions []Version `yaml:"versions,omitempty" json:"versions,omitempty"` } // DevfileType describes the type of devfile @@ -183,6 +185,14 @@ const ( DeployCommandGroupKind CommandGroupKind = "deploy" ) +// DeploymentScopeKind describes the kind of deployment scope +type DeploymentScopeKind string + +const ( + InnerloopKind DeploymentScopeKind = "innerloop" + OuterloopKind DeploymentScopeKind = "outerloop" +) + // StarterProject is the devfile starter project type StarterProject struct { Name string `yaml:"name,omitempty" json:"name,omitempty"` @@ -241,16 +251,17 @@ type StackInfo struct { // Version stores the information for each stack version type Version struct { - Version string `yaml:"version,omitempty" json:"version,omitempty"` - SchemaVersion string `yaml:"schemaVersion,omitempty" json:"schemaVersion,omitempty"` - Default bool `yaml:"default,omitempty" json:"default,omitempty"` - Git *Git `yaml:"git,omitempty" json:"git,omitempty"` - Description string `yaml:"description,omitempty" json:"description,omitempty"` - Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` - Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` - Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` - Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` - CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` - Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` - StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` + Version string `yaml:"version,omitempty" json:"version,omitempty"` + SchemaVersion string `yaml:"schemaVersion,omitempty" json:"schemaVersion,omitempty"` + Default bool `yaml:"default,omitempty" json:"default,omitempty"` + Git *Git `yaml:"git,omitempty" json:"git,omitempty"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` + Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` + Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` + Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` + CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` + DeploymentScopes map[DeploymentScopeKind]bool `yaml:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` + StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` } diff --git a/index/server/vendor/modules.txt b/index/server/vendor/modules.txt index 6ecd71786..c770ab8a3 100644 --- a/index/server/vendor/modules.txt +++ b/index/server/vendor/modules.txt @@ -607,6 +607,8 @@ go.opentelemetry.io/otel/metric/embedded ## explicit; go 1.20 go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace/embedded +# go.uber.org/atomic v1.9.0 +## explicit; go 1.13 # golang.org/x/arch v0.0.0-20210923205945-b76863e36670 ## explicit; go 1.17 golang.org/x/arch/x86/x86asm diff --git a/registry-library/go.mod b/registry-library/go.mod index 8c45e6091..3587e1ffa 100644 --- a/registry-library/go.mod +++ b/registry-library/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/containerd/containerd v1.7.13 - github.com/devfile/registry-support/index/generator v0.0.0-20240311135803-6215550f93d4 + github.com/devfile/registry-support/index/generator v0.0.0-20240419194226-cca4c9a81f8d github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-version v1.4.0 github.com/mitchellh/go-homedir v1.1.0 @@ -74,7 +74,6 @@ require ( golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.19.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect google.golang.org/grpc v1.62.1 // indirect google.golang.org/protobuf v1.33.0 // indirect @@ -92,4 +91,4 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) -replace github.com/devfile/registry-support/index/generator v0.0.0-20240311135803-6215550f93d4 => ../index/generator +replace github.com/devfile/registry-support/index/generator v0.0.0-20240419194226-cca4c9a81f8d => ../index/generator diff --git a/registry-library/go.sum b/registry-library/go.sum index c42ba6b60..aaf090ddf 100644 --- a/registry-library/go.sum +++ b/registry-library/go.sum @@ -540,7 +540,6 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/registry-library/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go b/registry-library/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go index 5abfaab11..126c90705 100644 --- a/registry-library/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go +++ b/registry-library/vendor/github.com/devfile/registry-support/index/generator/schema/schema.go @@ -130,6 +130,7 @@ projectType: string - The project framework that is used in the devfile language: string - The project language that is used in the devfile links: map[string]string - Links related to the devfile commandGroups: map[CommandGroupKind]bool - The command groups that are used in the devfile +deploymentScopes: map[DeploymentScopeKind]bool - The deployment scope that are detected in the devfile resources: []string - The file resources that compose a devfile stack. starterProjects: string[] - The project templates that can be used in the devfile git: *git - The information of remote repositories @@ -139,26 +140,27 @@ versions: []Version - The list of stack versions information // Schema is the index file schema type Schema struct { - Name string `yaml:"name,omitempty" json:"name,omitempty"` - Version string `yaml:"version,omitempty" json:"version,omitempty"` - Attributes map[string]apiext.JSON `yaml:"attributes,omitempty" json:"attributes,omitempty"` - DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"` - Description string `yaml:"description,omitempty" json:"description,omitempty"` - Type DevfileType `yaml:"type,omitempty" json:"type,omitempty"` - Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` - Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` - Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` - GlobalMemoryLimit string `yaml:"globalMemoryLimit,omitempty" json:"globalMemoryLimit,omitempty"` - ProjectType string `yaml:"projectType,omitempty" json:"projectType,omitempty"` - Language string `yaml:"language,omitempty" json:"language,omitempty"` - Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` - CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` - Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` - StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` - Git *Git `yaml:"git,omitempty" json:"git,omitempty"` - Provider string `yaml:"provider,omitempty" json:"provider,omitempty"` - SupportUrl string `yaml:"supportUrl,omitempty" json:"supportUrl,omitempty"` - Versions []Version `yaml:"versions,omitempty" json:"versions,omitempty"` + Name string `yaml:"name,omitempty" json:"name,omitempty"` + Version string `yaml:"version,omitempty" json:"version,omitempty"` + Attributes map[string]apiext.JSON `yaml:"attributes,omitempty" json:"attributes,omitempty"` + DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + Type DevfileType `yaml:"type,omitempty" json:"type,omitempty"` + Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` + Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` + Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` + GlobalMemoryLimit string `yaml:"globalMemoryLimit,omitempty" json:"globalMemoryLimit,omitempty"` + ProjectType string `yaml:"projectType,omitempty" json:"projectType,omitempty"` + Language string `yaml:"language,omitempty" json:"language,omitempty"` + Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` + CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` + DeploymentScopes map[DeploymentScopeKind]bool `yaml:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` + StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` + Git *Git `yaml:"git,omitempty" json:"git,omitempty"` + Provider string `yaml:"provider,omitempty" json:"provider,omitempty"` + SupportUrl string `yaml:"supportUrl,omitempty" json:"supportUrl,omitempty"` + Versions []Version `yaml:"versions,omitempty" json:"versions,omitempty"` } // DevfileType describes the type of devfile @@ -183,6 +185,14 @@ const ( DeployCommandGroupKind CommandGroupKind = "deploy" ) +// DeploymentScopeKind describes the kind of deployment scope +type DeploymentScopeKind string + +const ( + InnerloopKind DeploymentScopeKind = "innerloop" + OuterloopKind DeploymentScopeKind = "outerloop" +) + // StarterProject is the devfile starter project type StarterProject struct { Name string `yaml:"name,omitempty" json:"name,omitempty"` @@ -241,16 +251,17 @@ type StackInfo struct { // Version stores the information for each stack version type Version struct { - Version string `yaml:"version,omitempty" json:"version,omitempty"` - SchemaVersion string `yaml:"schemaVersion,omitempty" json:"schemaVersion,omitempty"` - Default bool `yaml:"default,omitempty" json:"default,omitempty"` - Git *Git `yaml:"git,omitempty" json:"git,omitempty"` - Description string `yaml:"description,omitempty" json:"description,omitempty"` - Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` - Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` - Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` - Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` - CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` - Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` - StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` + Version string `yaml:"version,omitempty" json:"version,omitempty"` + SchemaVersion string `yaml:"schemaVersion,omitempty" json:"schemaVersion,omitempty"` + Default bool `yaml:"default,omitempty" json:"default,omitempty"` + Git *Git `yaml:"git,omitempty" json:"git,omitempty"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` + Architectures []string `yaml:"architectures,omitempty" json:"architectures,omitempty"` + Icon string `yaml:"icon,omitempty" json:"icon,omitempty"` + Links map[string]string `yaml:"links,omitempty" json:"links,omitempty"` + CommandGroups map[CommandGroupKind]bool `yaml:"commandGroups,omitempty" json:"commandGroups,omitempty"` + DeploymentScopes map[DeploymentScopeKind]bool `yaml:"deploymentScopes,omitempty" json:"deploymentScopes,omitempty"` + Resources []string `yaml:"resources,omitempty" json:"resources,omitempty"` + StarterProjects []string `yaml:"starterProjects,omitempty" json:"starterProjects,omitempty"` } diff --git a/registry-library/vendor/modules.txt b/registry-library/vendor/modules.txt index 36f179067..26e087e48 100644 --- a/registry-library/vendor/modules.txt +++ b/registry-library/vendor/modules.txt @@ -36,7 +36,7 @@ github.com/containerd/containerd/version # github.com/containerd/log v0.1.0 ## explicit; go 1.20 github.com/containerd/log -# github.com/devfile/registry-support/index/generator v0.0.0-20240311135803-6215550f93d4 => ../index/generator +# github.com/devfile/registry-support/index/generator v0.0.0-20240419194226-cca4c9a81f8d => ../index/generator ## explicit; go 1.19 github.com/devfile/registry-support/index/generator/schema # github.com/distribution/reference v0.5.0 @@ -309,8 +309,6 @@ golang.org/x/text/secure/bidirule golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm -# golang.org/x/tools v0.19.0 -## explicit; go 1.19 # google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 ## explicit; go 1.19 google.golang.org/genproto/googleapis/rpc/status diff --git a/tests/integration/go.mod b/tests/integration/go.mod index 980c59b66..dc471e1f2 100644 --- a/tests/integration/go.mod +++ b/tests/integration/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/devfile/library/v2 v2.2.2 - github.com/devfile/registry-support/index/generator v0.0.0-20240311135803-6215550f93d4 + github.com/devfile/registry-support/index/generator v0.0.0-20240419194226-cca4c9a81f8d github.com/onsi/ginkgo v1.16.4 github.com/onsi/gomega v1.27.10 ) @@ -99,6 +99,7 @@ require ( go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.uber.org/atomic v1.9.0 // indirect golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.16.0 // indirect golang.org/x/net v0.22.0 // indirect diff --git a/tests/integration/go.sum b/tests/integration/go.sum index 2743a20b8..6a0de0a89 100644 --- a/tests/integration/go.sum +++ b/tests/integration/go.sum @@ -96,8 +96,8 @@ github.com/devfile/api/v2 v2.2.2 h1:DXRCPWFlZhTIE38Of2jzTRjQHadfbxBC8GS+m+EjoCU= github.com/devfile/api/v2 v2.2.2/go.mod h1:qp8jcw12y1JdCsxjK/7LJ7uWaJOxcY1s2LUk5PhbkbM= github.com/devfile/library/v2 v2.2.2 h1:iLtFQ16aYMcB+vUx7NKtKPiTEursxwueu6/qOailubA= github.com/devfile/library/v2 v2.2.2/go.mod h1:LHgAu9VApI++hE+cr6CWrkj1OlzHOJeKbraqC5PxSec= -github.com/devfile/registry-support/index/generator v0.0.0-20240311135803-6215550f93d4 h1:t09mGdy31tC2YBp6kVD7x8m0jq1CyBUSYMUvrF0iaWw= -github.com/devfile/registry-support/index/generator v0.0.0-20240311135803-6215550f93d4/go.mod h1:3Ngbmm12LW03tAEHpDNymM7zryd5H1Xo3ZAGlBpecf8= +github.com/devfile/registry-support/index/generator v0.0.0-20240419194226-cca4c9a81f8d h1:XE1N4HVssY72KLp2omW3xoZ89vnIJ2w5/abp+3oWTaA= +github.com/devfile/registry-support/index/generator v0.0.0-20240419194226-cca4c9a81f8d/go.mod h1:X/YcXBDg6PF+k/2yVRwnEVfQtNFGeVZOIGCyCkaBWO8= github.com/devfile/registry-support/registry-library v0.0.0-20240328155806-7c89891a72ce h1:IgUCI7eCq6m0JzRx3+FZuIeJy5e+rUSQYMr3NBzrqyg= github.com/devfile/registry-support/registry-library v0.0.0-20240328155806-7c89891a72ce/go.mod h1:2RRLQaOYuzh8n59euz6Bu60hFoX/LLVM9uzFOFDyOZM= github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc= @@ -481,6 +481,7 @@ go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8p go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=