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" 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: diff --git a/registry-library/README.md b/registry-library/README.md index 2d87717fe..b9dc60526 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: registryLibrary.DeprecatedFilterTrue, + }, + } + ``` +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: registryLibrary.DeprecatedFilterFalse, + }, + } + ``` #### Download the starter project diff --git a/registry-library/library/library.go b/registry-library/library/library.go index 152b755d4..8d7f374c2 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 @@ -103,6 +108,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 DeprecatedFilter } // GetRegistryIndex returns the list of index schema structured stacks and/or samples from a specified devfile registry. @@ -152,13 +161,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 == DeprecatedFilterTrue || options.Filter.Deprecated == DeprecatedFilterFalse { + q.Add("deprecated", string(options.Filter.Deprecated)) } } urlObj.RawQuery = q.Encode() diff --git a/registry-library/library/library_test.go b/registry-library/library/library_test.go index d5a2cdffc..cf9db7136 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: DeprecatedFilterTrue, + }, + }, + devfileTypes: []indexSchema.DevfileType{indexSchema.StackDevfileType}, + wantSchemas: deprecatedFilteredIndex, + }, + { + name: "Get Non Deprecated Filtered Index", + url: "http://" + serverIP, + options: RegistryOptions{ + NewIndexSchema: true, + Filter: RegistryFilter{ + Deprecated: DeprecatedFilterFalse, + }, + }, + devfileTypes: []indexSchema.DevfileType{indexSchema.StackDevfileType}, + wantSchemas: nonDeprecatedFilteredIndex, + }, { name: "Get Arch Filtered Index", url: "http://" + serverIP,