From a4c3244b853aac8761b9b4b9214486601d4ed679 Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 10 Apr 2024 12:17:57 +0100 Subject: [PATCH 1/9] Add filtering for deprecated stacks Signed-off-by: thepetk --- registry-library/library/library.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/registry-library/library/library.go b/registry-library/library/library.go index 152b755d4..f5adad8b3 100644 --- a/registry-library/library/library.go +++ b/registry-library/library/library.go @@ -103,6 +103,10 @@ type RegistryFilter struct { // only major version and minor version are required. e.g. 2.1, 2.2 ect. service version should not be provided. // will only be applied if `NewIndexSchema=true` MaxSchemaVersion string + // Deprecated is set to filter devfile index for stacks having the "Deprecated" tag inside their default set of tags + // or not. the only acceptable values are "true"/"false". in case the value is "true" it will only include only + // deprecated stacks, if is "false" only non deprecated. will only be applied if `NewIndexSchema=true` + Deprecated string } // GetRegistryIndex returns the list of index schema structured stacks and/or samples from a specified devfile registry. @@ -152,13 +156,17 @@ func GetRegistryIndex(registryURL string, options RegistryOptions, devfileTypes q.Add("arch", arch) } } - - if options.NewIndexSchema && (options.Filter.MaxSchemaVersion != "" || options.Filter.MinSchemaVersion != "") { - if options.Filter.MinSchemaVersion != "" { - q.Add("minSchemaVersion", options.Filter.MinSchemaVersion) + if options.NewIndexSchema { + if options.Filter.MaxSchemaVersion != "" || options.Filter.MinSchemaVersion != "" { + if options.Filter.MinSchemaVersion != "" { + q.Add("minSchemaVersion", options.Filter.MinSchemaVersion) + } + if options.Filter.MaxSchemaVersion != "" { + q.Add("maxSchemaVersion", options.Filter.MaxSchemaVersion) + } } - if options.Filter.MaxSchemaVersion != "" { - q.Add("maxSchemaVersion", options.Filter.MaxSchemaVersion) + if options.Filter.Deprecated == "true" || options.Filter.Deprecated == "false" { + q.Add("deprecated", options.Filter.Deprecated) } } urlObj.RawQuery = q.Encode() From 7176cd01d4add194667b585541751b7e1f1125b1 Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 10 Apr 2024 12:18:26 +0100 Subject: [PATCH 2/9] Add test cases for deprecated stacks filtering Signed-off-by: thepetk --- registry-library/library/library_test.go | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/registry-library/library/library_test.go b/registry-library/library/library_test.go index d5a2cdffc..86d2434b9 100644 --- a/registry-library/library/library_test.go +++ b/registry-library/library/library_test.go @@ -50,6 +50,19 @@ var ( }, } + deprecatedFilteredIndex = []indexSchema.Schema{ + { + Name: "deprecatedindex1", + Tags: []string{"Deprecated, arm64"}, + }, + } + + nonDeprecatedFilteredIndex = []indexSchema.Schema{ + { + Name: "deprecatedindex2", + }, + } + schemaVersionFilteredIndex = []indexSchema.Schema{ { Name: "indexSchema2.1", @@ -206,6 +219,10 @@ func setUpIndexHandle(indexUrl *url.URL) []indexSchema.Schema { if strings.Contains(indexUrl.String(), "arch=amd64&arch=arm64") { data = archFilteredIndex + } else if strings.Contains(indexUrl.String(), "deprecated=true") { + data = deprecatedFilteredIndex + } else if strings.Contains(indexUrl.String(), "deprecated=false") { + data = nonDeprecatedFilteredIndex } else if strings.Contains(indexUrl.String(), "maxSchemaVersion=2.2") && strings.Contains(indexUrl.String(), "minSchemaVersion=2.1") { data = schemaVersionFilteredIndex } else if indexUrl.Path == "/index/sample" { @@ -315,6 +332,30 @@ func TestGetRegistryIndex(t *testing.T) { devfileTypes: []indexSchema.DevfileType{indexSchema.StackDevfileType}, wantSchemas: schemaVersionFilteredIndex, }, + { + name: "Get Deprecated Filtered Index", + url: "http://" + serverIP, + options: RegistryOptions{ + NewIndexSchema: true, + Filter: RegistryFilter{ + Deprecated: "true", + }, + }, + devfileTypes: []indexSchema.DevfileType{indexSchema.StackDevfileType}, + wantSchemas: deprecatedFilteredIndex, + }, + { + name: "Get Non Deprecated Filtered Index", + url: "http://" + serverIP, + options: RegistryOptions{ + NewIndexSchema: true, + Filter: RegistryFilter{ + Deprecated: "false", + }, + }, + devfileTypes: []indexSchema.DevfileType{indexSchema.StackDevfileType}, + wantSchemas: nonDeprecatedFilteredIndex, + }, { name: "Get Arch Filtered Index", url: "http://" + serverIP, From cc6081ca5e00cfde904c9fbbe7de4df62b4c6716 Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 10 Apr 2024 12:18:39 +0100 Subject: [PATCH 3/9] Update documentation Signed-off-by: thepetk --- registry-library/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/registry-library/README.md b/registry-library/README.md index 2d87717fe..cfced7db3 100644 --- a/registry-library/README.md +++ b/registry-library/README.md @@ -128,6 +128,22 @@ Supported devfile media types can be found in the latest version of [library.go] HTTPTimeout: &customTimeout } ``` +7. Filter *only deprecated* Devfiles based on the [lifecycle process for the devfiles project](https://github.com/devfile/registry/blob/main/LIFECYCLE.md) + ```go + options := registryLibrary.RegistryOptions{ + Filter: registryLibrary.RegistryFilter{ + Deprecated: "true", + }, + } + ``` +8. Filter *only non deprecated* Devfiles based on the [lifecycle process for the devfiles project](https://github.com/devfile/registry/blob/main/LIFECYCLE.md) + ```go + options := registryLibrary.RegistryOptions{ + Filter: registryLibrary.RegistryFilter{ + Deprecated: "false", + }, + } + ``` #### Download the starter project From c623b42b8c0cce8743f6c2e0803fd1c02ee2afdd Mon Sep 17 00:00:00 2001 From: thepetk Date: Sat, 13 Apr 2024 17:09:37 +0100 Subject: [PATCH 4/9] Update library with const values Signed-off-by: thepetk --- registry-library/library/library.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/registry-library/library/library.go b/registry-library/library/library.go index f5adad8b3..4d78884f2 100644 --- a/registry-library/library/library.go +++ b/registry-library/library/library.go @@ -48,9 +48,11 @@ const ( DevfilePNGLogoMediaType = "image/png" DevfileArchiveMediaType = "application/x-tar" - OwnersFile = "OWNERS" - registryLibrary = "registry-library" //constant to indicate that function is called by the library - httpRequestResponseTimeout = 30 * time.Second // httpRequestTimeout configures timeout of all HTTP requests + OwnersFile = "OWNERS" + registryLibrary = "registry-library" //constant to indicate that function is called by the library + httpRequestResponseTimeout = 30 * time.Second // httpRequestTimeout configures timeout of all HTTP requests + DeprecatedFilterTrue DeprecatedFilter = "true" + DeprecatedFilterFalse DeprecatedFilter = "false" ) var ( @@ -65,6 +67,9 @@ type Registry struct { err error } +// DeprecatedFilter to manage the deprecated filter values +type DeprecatedFilter string + // TelemetryData structure to pass in client telemetry information // The User and Locale fields should be passed in by clients if telemetry opt-in is enabled // the generic Client name will be passed in regardless of opt-in/out choice. The value @@ -106,7 +111,7 @@ type RegistryFilter struct { // Deprecated is set to filter devfile index for stacks having the "Deprecated" tag inside their default set of tags // or not. the only acceptable values are "true"/"false". in case the value is "true" it will only include only // deprecated stacks, if is "false" only non deprecated. will only be applied if `NewIndexSchema=true` - Deprecated string + Deprecated DeprecatedFilter } // GetRegistryIndex returns the list of index schema structured stacks and/or samples from a specified devfile registry. @@ -165,7 +170,7 @@ func GetRegistryIndex(registryURL string, options RegistryOptions, devfileTypes q.Add("maxSchemaVersion", options.Filter.MaxSchemaVersion) } } - if options.Filter.Deprecated == "true" || options.Filter.Deprecated == "false" { + if options.Filter.Deprecated == DeprecatedFilterTrue || options.Filter.Deprecated == DeprecatedFilterFalse { q.Add("deprecated", options.Filter.Deprecated) } } From a402114190985aa67fe5db54f380c8c2ed9ac75a Mon Sep 17 00:00:00 2001 From: thepetk Date: Sat, 13 Apr 2024 17:11:43 +0100 Subject: [PATCH 5/9] Fix type for DeprecatedFilter Signed-off-by: thepetk --- registry-library/library/library.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry-library/library/library.go b/registry-library/library/library.go index 4d78884f2..8d7f374c2 100644 --- a/registry-library/library/library.go +++ b/registry-library/library/library.go @@ -171,7 +171,7 @@ func GetRegistryIndex(registryURL string, options RegistryOptions, devfileTypes } } if options.Filter.Deprecated == DeprecatedFilterTrue || options.Filter.Deprecated == DeprecatedFilterFalse { - q.Add("deprecated", options.Filter.Deprecated) + q.Add("deprecated", string(options.Filter.Deprecated)) } } urlObj.RawQuery = q.Encode() From ba1a8464c23d0654eb6d4399561df91aed2f59a7 Mon Sep 17 00:00:00 2001 From: Theofanis Petkos Date: Mon, 15 Apr 2024 14:49:08 +0100 Subject: [PATCH 6/9] Update registry-library/README.md Co-authored-by: Michael Valdron Signed-off-by: thepetk --- registry-library/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry-library/README.md b/registry-library/README.md index cfced7db3..b9dc60526 100644 --- a/registry-library/README.md +++ b/registry-library/README.md @@ -132,7 +132,7 @@ Supported devfile media types can be found in the latest version of [library.go] ```go options := registryLibrary.RegistryOptions{ Filter: registryLibrary.RegistryFilter{ - Deprecated: "true", + Deprecated: registryLibrary.DeprecatedFilterTrue, }, } ``` @@ -140,7 +140,7 @@ Supported devfile media types can be found in the latest version of [library.go] ```go options := registryLibrary.RegistryOptions{ Filter: registryLibrary.RegistryFilter{ - Deprecated: "false", + Deprecated: registryLibrary.DeprecatedFilterFalse, }, } ``` From 162cd7369b44f4f3a2374da20133578783463e60 Mon Sep 17 00:00:00 2001 From: Theofanis Petkos Date: Mon, 15 Apr 2024 14:49:15 +0100 Subject: [PATCH 7/9] Update registry-library/library/library_test.go Co-authored-by: Michael Valdron Signed-off-by: thepetk --- registry-library/library/library_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry-library/library/library_test.go b/registry-library/library/library_test.go index 86d2434b9..cf9db7136 100644 --- a/registry-library/library/library_test.go +++ b/registry-library/library/library_test.go @@ -338,7 +338,7 @@ func TestGetRegistryIndex(t *testing.T) { options: RegistryOptions{ NewIndexSchema: true, Filter: RegistryFilter{ - Deprecated: "true", + Deprecated: DeprecatedFilterTrue, }, }, devfileTypes: []indexSchema.DevfileType{indexSchema.StackDevfileType}, @@ -350,7 +350,7 @@ func TestGetRegistryIndex(t *testing.T) { options: RegistryOptions{ NewIndexSchema: true, Filter: RegistryFilter{ - Deprecated: "false", + Deprecated: DeprecatedFilterFalse, }, }, devfileTypes: []indexSchema.DevfileType{indexSchema.StackDevfileType}, From d8750921c100a288932afbc61173b57464bcf3b3 Mon Sep 17 00:00:00 2001 From: thepetk Date: Mon, 15 Apr 2024 15:28:28 +0100 Subject: [PATCH 8/9] Fix icon for test resource Signed-off-by: thepetk --- index/server/tests/registry/stacks/java-springboot/devfile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index/server/tests/registry/stacks/java-springboot/devfile.yaml b/index/server/tests/registry/stacks/java-springboot/devfile.yaml index abe0d0744..1bbe64a50 100644 --- a/index/server/tests/registry/stacks/java-springboot/devfile.yaml +++ b/index/server/tests/registry/stacks/java-springboot/devfile.yaml @@ -6,7 +6,7 @@ metadata: description: Spring Boot® using Java tags: ["Java", "Spring"] globalMemoryLimit: 2674Mi - icon: https://www.eclipse.org/che/images/logo-eclipseche.svg + icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg projectType: "spring" language: "java" starterProjects: From 994bf0013b03276ee815cb73b235604bb6869edb Mon Sep 17 00:00:00 2001 From: thepetk Date: Mon, 15 Apr 2024 15:33:58 +0100 Subject: [PATCH 9/9] Replace broken icon Signed-off-by: thepetk --- index/generator/tests/registry/index_main.json | 4 ++-- index/generator/tests/registry/index_registry.json | 4 ++-- .../tests/registry/stacks/java-springboot/devfile.yaml | 2 +- index/server/pkg/util/index.json | 2 +- index/server/registry-REST-API.adoc | 4 ++-- index/server/tests/registry/index_main.json | 4 ++-- index/server/tests/registry/index_registry.json | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/index/generator/tests/registry/index_main.json b/index/generator/tests/registry/index_main.json index 3f5e307bc..bee022b3e 100644 --- a/index/generator/tests/registry/index_main.json +++ b/index/generator/tests/registry/index_main.json @@ -154,7 +154,7 @@ "description": "Spring Boot® using Java", "type": "stack", "tags": ["Java", "Spring"], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "projectType": "spring", "language": "java", "versions": [ @@ -163,7 +163,7 @@ "schemaVersion": "2.2.0", "default": true, "description": "Spring Boot® using Java", - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "tags": ["Java", "Spring"], "links": { "self": "devfile-catalog/java-springboot:1.1.0" diff --git a/index/generator/tests/registry/index_registry.json b/index/generator/tests/registry/index_registry.json index b29dcc706..61eccf665 100644 --- a/index/generator/tests/registry/index_registry.json +++ b/index/generator/tests/registry/index_registry.json @@ -154,7 +154,7 @@ "description": "Spring Boot® using Java", "type": "stack", "tags": ["Java", "Spring"], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "projectType": "spring", "language": "java", "versions": [ @@ -164,7 +164,7 @@ "default": true, "description": "Spring Boot® using Java", "tags": ["Java", "Spring"], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "links": { "self": "devfile-catalog/java-springboot:1.1.0" }, diff --git a/index/generator/tests/registry/stacks/java-springboot/devfile.yaml b/index/generator/tests/registry/stacks/java-springboot/devfile.yaml index abe0d0744..1bbe64a50 100644 --- a/index/generator/tests/registry/stacks/java-springboot/devfile.yaml +++ b/index/generator/tests/registry/stacks/java-springboot/devfile.yaml @@ -6,7 +6,7 @@ metadata: description: Spring Boot® using Java tags: ["Java", "Spring"] globalMemoryLimit: 2674Mi - icon: https://www.eclipse.org/che/images/logo-eclipseche.svg + icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg projectType: "spring" language: "java" starterProjects: diff --git a/index/server/pkg/util/index.json b/index/server/pkg/util/index.json index e3e25a4d4..abad8ded2 100644 --- a/index/server/pkg/util/index.json +++ b/index/server/pkg/util/index.json @@ -101,7 +101,7 @@ "Java", "Spring" ], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "projectType": "spring", "language": "java", "links": { diff --git a/index/server/registry-REST-API.adoc b/index/server/registry-REST-API.adoc index 722bbccff..67044c4df 100644 --- a/index/server/registry-REST-API.adoc +++ b/index/server/registry-REST-API.adoc @@ -135,7 +135,7 @@ curl http://devfile-registry.192.168.1.1.nip.io/index "Java", "Spring" ], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "globalMemoryLimit": "2674Mi", "projectType": "spring", "language": "java", @@ -801,7 +801,7 @@ curl http://devfile-registry.192.168.1.1.nip.io/index/all "Java", "Spring" ], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "globalMemoryLimit": "2674Mi", "projectType": "spring", "language": "java", diff --git a/index/server/tests/registry/index_main.json b/index/server/tests/registry/index_main.json index c3020ad58..6e0b9fa3a 100644 --- a/index/server/tests/registry/index_main.json +++ b/index/server/tests/registry/index_main.json @@ -162,7 +162,7 @@ "Java", "Spring" ], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "projectType": "spring", "language": "java", "versions": [ @@ -171,7 +171,7 @@ "schemaVersion": "2.2.0", "default": true, "description": "Spring Boot® using Java", - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "tags": [ "Java", "Spring" diff --git a/index/server/tests/registry/index_registry.json b/index/server/tests/registry/index_registry.json index fa731b6d7..1cecabffd 100644 --- a/index/server/tests/registry/index_registry.json +++ b/index/server/tests/registry/index_registry.json @@ -162,7 +162,7 @@ "Java", "Spring" ], - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "projectType": "spring", "language": "java", "versions": [ @@ -171,7 +171,7 @@ "schemaVersion": "2.2.0", "default": true, "description": "Spring Boot® using Java", - "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg", "tags": [ "Java", "Spring"