redhat-developer / odo

odo - Developer-focused CLI for fast & iterative container-based application development on Podman and Kubernetes. Implementation of the open Devfile standard.
https://odo.dev
Apache License 2.0
788 stars 243 forks source link

[Research][Spike] Backstage Golden Path Template (GPT) for `odo init` #7086

Closed feloy closed 12 months ago

feloy commented 1 year ago

/kind feature

Research to help estimate Q4 epics:

Which functionality do you think we should add?

Why is this needed?

Related Epic: https://github.com/redhat-developer/odo/issues/7091

rm3l commented 1 year ago

Proposal

@kadel @feloy Following some discussions with you, below is a proposal for a first version of the template. Let me know your thoughts.

The Backstage Golden Path Template for odo init could be made of the following:

Once we have the items above implemented, we could provide a very simple template with the following:


For more context, here is a more detailed summary of my investigations:

Approach 1: Cloning all Devfile starter projects along with their stacks

Given the structure of a typical Backstage Software Template (a template.yaml definition file and a skeleton directory containing all the necessary files and directories parameterized), I initially thought the UI could display a (manual) list of Devfiles to pick, and depending on what Devfile users pick, they would be shown dedicated sections to further customize the project.

Example ![image](https://github.com/redhat-developer/odo/assets/593208/241c173b-047c-4798-967a-9480098b9c9d)

Pros

Cons

Approach 2: Custom field extensions + custom actions + template

To alleviate the maintenance overhead, the idea here is to make the Template display fields that could be dynamically populated from the Devfile Registry Index. Such fields are the list of Devfiles, the Devfile versions, and the starter projects. This sounds feasible using Backstage custom field extensions. Once the UI is done, we need to perform actions like pulling the Devfile Stack version and starter project, publishing it to a repository service, and registering it in the Software Catalog.

Pulling the Devfile Stack can be done either with odo or by pulling it directly from the Devfile Registry.

Using the odo binary

We could provide a custom action, say odo:component:init, which would take care of executing odo init passing it the right arguments. From my investigations, it is possible to execute a shell command from a Backstage custom action. plugin-scaffolder-git-actions is a good example as it requires Git to be installed in the environment running the Backstage instance: https://github.com/arhill05/backstage-plugin-scaffolder-git-actions/blob/master/src/actions/git.ts#L37-L43

This has the benefit of opening up other usages relying on the odo binary in the future.

WARNINGS:

However, comes the question: how do we expect odo to be present?

Pulling directly from the Devfile Registry

The idea here is to mimic the behavior of odo init without relying on the odo binary. Currently, odo uses the Registry Library to pull Stacks via the ORAS library (because Stacks are stored as OCI artifacts). So instead, we would need to:

rm3l commented 12 months ago

Closing this issue as complete. https://github.com/redhat-developer/odo/issues/7114 has been created to track everything needed to implement the Golden Path Template for odo init.

/close