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

Allow using image names as selectors #172

Conversation

rm3l
Copy link
Member

@rm3l rm3l commented Apr 24, 2023

What does this PR do?:

This PR introduces a new ImageNamesAsSelector field in the Devfile parser args. If this field is not nil, the parser will try to use image names from Image components as selectors in any matching Container or Kubernetes/OpenShift components.
In this case, the parser will return a Devfile object where all matching image names have been replaced with the arguments provided in the parser args.
Replacement is done only on relative image names and the logic to check whether there is a match is based on the discussion in devfile/api#985 (comment).

This is needed by odo (redhat-developer/odo#6565).

Which issue(s) this PR fixes:

Fixes devfile/api#985
Fixes redhat-developer/odo#6676

PR acceptance criteria:

Testing and documentation do not need to be complete in order for this PR to be approved. We just need to ensure tracking issues are opened.

  • Open new test/doc issues under the devfile/api repo
  • Check each criteria if:
  • There is a separate tracking issue. Add the issue link under the criteria
    or
  • test/doc updates are made as part of this PR
  • If unchecked, explain why it's not needed
  • Unit/Functional tests

  • QE Integration test

  • Documentation

  • Client Impact
    This is backward compatible, but the behavior of considering imageName as an image selector will need to be documented.

  • Gosec scans

How to test changes / Special notes to the reviewer:

@rm3l rm3l force-pushed the 985_imageName_as_selector_in_container_and_kubernetes_definitions branch 2 times, most recently from cc735ab to 8c044e3 Compare April 25, 2023 07:36
@rm3l rm3l marked this pull request as ready for review April 25, 2023 11:29
@openshift-ci openshift-ci bot requested review from elsony and maysunfaisal April 25, 2023 11:29
@rm3l rm3l changed the title [WIP] Allow using image names as selectors Allow using image names as selectors Apr 25, 2023
@rm3l rm3l force-pushed the 985_imageName_as_selector_in_container_and_kubernetes_definitions branch 2 times, most recently from a643206 to 84a90db Compare April 25, 2023 19:41
@codecov
Copy link

codecov bot commented May 2, 2023

Codecov Report

Patch coverage: 68.91% and project coverage change: +0.36 🎉

Comparison is base (8185c3a) 59.25% compared to head (d32bcd6) 59.62%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #172      +/-   ##
==========================================
+ Coverage   59.25%   59.62%   +0.36%     
==========================================
  Files          40       41       +1     
  Lines        4926     5119     +193     
==========================================
+ Hits         2919     3052     +133     
- Misses       1832     1873      +41     
- Partials      175      194      +19     
Impacted Files Coverage Δ
pkg/devfile/parse.go 24.59% <0.00%> (-2.20%) ⬇️
pkg/devfile/imageNameSelector.go 70.27% <70.27%> (ø)
pkg/devfile/parser/parse.go 60.80% <100.00%> (+0.18%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@rm3l rm3l force-pushed the 985_imageName_as_selector_in_container_and_kubernetes_definitions branch from 164ec3d to bc4cd5d Compare May 10, 2023 13:08
rm3l added 4 commits May 10, 2023 15:12
The goal of this field is to allow tools to provide
information (currently registry and tag) allowing to replace matching image names.

See [1] for more details.

[1] devfile/api#985

Signed-off-by: Armel Soro <[email protected]>
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)

Signed-off-by: Armel Soro <[email protected]>
…file

Users might actually be using variables for image names.

Signed-off-by: Armel Soro <[email protected]>
It does not make sense to set a non-nil ParserArgs.ImageNamesAsSelector with no Registry in it

Signed-off-by: Armel Soro <[email protected]>
@rm3l rm3l force-pushed the 985_imageName_as_selector_in_container_and_kubernetes_definitions branch from bc4cd5d to d32bcd6 Compare May 10, 2023 13:13
@rm3l rm3l requested a review from yangcao77 May 10, 2023 13:18
Copy link
Collaborator

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good to me

@openshift-ci
Copy link

openshift-ci bot commented May 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rm3l, yangcao77

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yangcao77 yangcao77 merged commit f041d79 into devfile:main May 15, 2023
@rm3l rm3l deleted the 985_imageName_as_selector_in_container_and_kubernetes_definitions branch May 15, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants