[go: up one dir, main page]

Skip to content

Use default devfile with golden image to create workspace if no devfile is present

Issue - Backend: Use default devfile with golden image ... (#474986 - closed)

What does this MR do and why?

As per the plan in Provide default devfile for projects if not pre... (&14644 - closed) , use default devfile with golden image to create workspace if no .devfile.yaml is present in the root of the repository.

References

Epic here Provide default devfile for projects if not pre... (&14644 - closed)

MR acceptance checklist

  • DB migration to make devfile_path nullable
  • Update devfile_fetcher.rb to take in default devfile is needed
  • Rename devfile_ref to project_ref in the DB and the GraphQL and the codebase.
  • Add a new settings in the settings module for default_devfile.

Screenshots or screen recordings

Below test scenarios are all with code changes

Scenario Screenshot DB record
All existing params Screenshot_2024-11-01_at_8.21.14_PM Screenshot_2024-11-01_at_8.36.51_PM
project_ref is used and ignore devfie_ref Screenshot_2024-11-01_at_8.23.06_PM Screenshot_2024-11-01_at_8.37.25_PM
project_ref is used with no devfile_ref Screenshot_2024-11-01_at_8.24.21_PM Screenshot_2024-11-01_at_8.38.02_PM
no project_ref or devfile_ref Screenshot_2024-11-01_at_8.25.28_PM
devfile_path is null (highlighted image is different from other screenshot image, and is using default_devfile from settings) Screenshot_2024-11-01_at_8.30.11_PM Screenshot_2024-11-01_at_8.38.32_PM
devfile_path is empty string and return error as expected Screenshot_2024-11-01_at_8.31.19_PM

How to set up and validate locally

  1. Setup workspaces locally following this guide
  2. Navigate to http://gdk.test:3000/-/graphql-explorer
  3. Also find your local correct project id and agent id for the use in the graphql query
  4. Execute queries in above screenshot, one example is provided below.
  5. Verify results as expected, and also try other different params.
mutation workspaceCreate {
  workspaceCreate(
    input: {
      projectId: "gid://gitlab/Project/3",
      clusterAgentId: "gid://gitlab/Clusters::Agent/10",
      desiredState: "Running",
      devfileRef: "main-invalid",
      projectRef: "main",
      devfilePath: null,
      maxHoursBeforeTermination: 24,
      variables: []}
  ) {
    workspace {
      id
      projectRef
      devfileRef
      devfilePath
      devfile
    }
    errors
  }
}
Edited by Chad Woolley

Merge request reports

Loading