Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to registry-support for sample checkoutFrom.revision #1209

Closed
2 tasks done
thepetk opened this issue Aug 2, 2023 · 10 comments · Fixed by devfile/registry-support#178 or devfile/registry#199
Closed
2 tasks done
Assignees
Labels
area/registry Devfile registry for stacks and infrastructure demo Issue or PR candidate for a demo at the end of the Sprint severity/blocker Issues that prevent developers from working

Comments

@thepetk
Copy link
Contributor

thepetk commented Aug 2, 2023

Which area this feature is related to?

/area registry

Which functionality do you think we should add?

As mentioned in issue #1112 it could be a good solution to check inside the extraDevfileEntries.yaml for any branches mentioned for the git repo that each sample has.

Why is this needed? Is your feature request related to a problem?

This feature will open the way to other registry features needed, like supporting multiple sample parent stacks versions while having a single repo to maintain.

Detailed description:
The idea of this feature was brought up inside the issue #1112 where we need to intoruce different versions of parent stacks per sample version. For example, a proposed update to a sample like go-basic would be:

- name: go-basic
  displayName: Basic Go
  description: Go 1.16 application
  icon: https://go.dev/blog/go-brand/Go-Logo/SVG/Go-Logo_Blue.svg
  tags:
    - Go
  projectType: Go
  language: Go
  provider: Red Hat
  versions:
    - version: 1.0.2
      schemaVersion: 2.1.0
      git:
        remotes:
          origin: https://github.com/devfile-samples/devfile-sample-go-basic.git
    - version: 2.1.0
      schemaVersion: 2.2.0
      default: true
      git:
        remotes:
          origin: https://github.com/thepetk/devfile-sample-go-basic.git

As you can see, we will have 2 different versions pointing to different parent stack version. Right now, with the current version of registry-support we are not able to use the same repo with different branches.

Describe the solution you'd like

Ideally we could add an additional check to the cache_samples file in order to use a specific branch when caching all samples.

So after this feature is created we can have:

 versions:
  - version: 2.1.0
    schemaVersion: 2.2.0
    default: true
    git:
      checkoutFrom:
        revision: 2.2.x
      remotes:
        origin: https://github.com/devfile-samples/devfile-sample-go-basic.git
  - version: 1.0.2
    schemaVersion: 2.1.0
    git:
      checkoutFrom:
        revision: main
      remotes:
        origin: https://github.com/devfile-samples/devfile-sample-go-basic.git

As you can see, we can use the same repo but different branches in order to support different versions of parent stacks.

Describe alternatives you've considered

Other alternatives can be found here

Acceptance Criteria

  • The index generator is able to detect checkoutFrom and use a different branch per version of sample.
  • All related documentation must be updated

Target date: 22 Aug 2023

@openshift-ci openshift-ci bot added the area/registry Devfile registry for stacks and infrastructure label Aug 2, 2023
@thepetk thepetk added the severity/blocker Issues that prevent developers from working label Aug 2, 2023
@thepetk thepetk changed the title Add support to registr-support for sample checkoutFrom.revision Add support to registry-support for sample checkoutFrom.revision Aug 2, 2023
@thepetk
Copy link
Contributor Author

thepetk commented Aug 2, 2023

Blocker for #1112

@thepetk
Copy link
Contributor Author

thepetk commented Aug 9, 2023

A PR is created and currently is under review

@thepetk
Copy link
Contributor Author

thepetk commented Aug 11, 2023

After the merge of the PR for the support of branches for multiple devfile versions an update to the documentation of the Registry contributing guide was added with this PR

@maysunfaisal
Copy link
Member

@thepetk is there an issue for registry-support library to support this?

@thepetk
Copy link
Contributor Author

thepetk commented Aug 23, 2023

I'm working on the library part of this issue in order to be able to provide a function which will be able to return all newer (2.2.x) samples.

@thepetk
Copy link
Contributor Author

thepetk commented Aug 23, 2023

@maysunfaisal I think the best way to use the new feature is to:

I was wondering if we need to create a func to wrap all this logic somewhere. If yes, where do you think it should be the best place to implement that?

@maysunfaisal
Copy link
Member

@thepetk

@thepetk
Copy link
Contributor Author

thepetk commented Aug 30, 2023

@maysunfaisal
I've tried to find any existing workaround for filtering the new versions of samples (sample versions using schemaVersion >= 2.2.x). We have already a filtering mechanism inside the GetRegistryIndex func. So if I run the code:

package main

import (
	"fmt"

	indexSchema "github.com/devfile/registry-support/index/generator/schema"
	registryLibrary "github.com/devfile/registry-support/registry-library/library"
)

const registryURL = "https://registry.devfile.io"

func main() {
	// devfiles matching debugging
	fmt.Printf("** Checking registryLibrary.GetRegistryIndex() ** \n")
	// indexSchema.StackDevfileType will return no results as there are no versions using schemaVersion 2.2.x
	// use indexSchema.StackDevfileType to get more results
	registryIndex, err := registryLibrary.GetRegistryIndex(registryURL, registryLibrary.RegistryOptions{
		Filter: registryLibrary.RegistryFilter{MinSchemaVersion: "2.2.0"}, Telemetry: registryLibrary.TelemetryData{}, NewIndexSchema: true,
	}, indexSchema.StackDevfileType)
	if err != nil {
		fmt.Printf("error:: %s", err)
	} else {
		for _, devfile := range registryIndex {
			fmt.Printf("Devfile %s found\n", devfile.Name)
			for _, version := range devfile.Versions {
				fmt.Printf("Version %s - using schemaVersion %s\n", version.Version, version.SchemaVersion)
			}
		}
	}
}

This way I take only the samples using schemaVersion >= 2.2.0 which can be the case for our issue. WDYT?

@thepetk
Copy link
Contributor Author

thepetk commented Sep 1, 2023

The issue remains under review (regarding PR which updates the contributing guide of registry). If the PR is approved, it can be merged and if the proposed solution for usage of registry support in order to filter samples is ok, we can close the issue.

@maysunfaisal
Copy link
Member

@thepetk thanks, let me try it out to see if it meets my needs! I shall get back to you shortly!

@elsony elsony added the demo Issue or PR candidate for a demo at the end of the Sprint label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/registry Devfile registry for stacks and infrastructure demo Issue or PR candidate for a demo at the end of the Sprint severity/blocker Issues that prevent developers from working
Projects
Status: Done ✅
3 participants