Skip to content

Conversation

@dharmit
Copy link
Contributor

@dharmit dharmit commented Nov 16, 2022

Signed-off-by: Dharmit Shah shahdharmit@gmail.com

What does this PR do?:

Adds support for container-overrides attribute, as described in devfile/api#920 (comment).

Which issue(s) this PR fixes:

Fixes part of #936

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

How to test changes / Special notes to the reviewer:

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
@openshift-ci
Copy link

openshift-ci bot commented Nov 16, 2022

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dharmit
Once this PR has been reviewed and has the lgtm label, please assign elsony for approval by writing /assign @elsony in a comment. For more information see the Kubernetes Code Review Process.

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

Details 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


// containerOverridesHandler modifies the container component to include any container-overrides values in the devfile.
// It does so by merging the devfile JSON with the JSON string representation of container-overrides field
func containerOverridesHandler(comp v1.Component, container *corev1.Container) (*corev1.Container, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find it a bad idea to pass a pointer and return a pointer. But I'm struggling to do otherwise because of the way runtime.DefaultUnstructuredConverter.ToUnstructured works.

I'm open to ideas/suggestions.

go.mod Outdated

require (
github.com/devfile/api/v2 v2.2.0
github.com/devfile/library v1.2.1-0.20220308191614-f0f7e11b17de
Copy link
Member

Choose a reason for hiding this comment

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

I think you may need to go mod tidy

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Base: 58.95% // Head: 58.75% // Decreases project coverage by -0.19% ⚠️

Coverage data is based on head (a5609fa) compared to base (c8f6c26).
Patch coverage: 42.55% of modified lines in pull request are covered.

❗ Current head a5609fa differs from pull request most recent head aa6e68d. Consider uploading reports for the commit aa6e68d to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
- Coverage   58.95%   58.75%   -0.20%     
==========================================
  Files          36       36              
  Lines        4037     4083      +46     
==========================================
+ Hits         2380     2399      +19     
- Misses       1518     1535      +17     
- Partials      139      149      +10     
Impacted Files Coverage Δ
pkg/devfile/generator/utils.go 87.59% <42.55%> (-4.61%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
Comment on lines +648 to +654
if *errHandler != nil && !errors.Is(*errHandler, &attributes.KeyNotFoundError{Key: key}) {
return nil, *errHandler
}
// no need to continue any further if container-overrides wasn't used for the container component
if val == nil {
return nil, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if *errHandler != nil && !errors.Is(*errHandler, &attributes.KeyNotFoundError{Key: key}) {
return nil, *errHandler
}
// no need to continue any further if container-overrides wasn't used for the container component
if val == nil {
return nil, nil
}
if *errHandler != nil {
if errors.Is(*errHandler, &attributes.KeyNotFoundError{Key: key}){
// no need to continue any further if container-overrides wasn't used for the container component
return nil, nil
}
return nil, *errHandler
}

Comment on lines +691 to +693
func convertUnstructuredToResource(u unstructured.Unstructured, obj interface{}) error {
return runtime.DefaultUnstructuredConverter.FromUnstructured(u.UnstructuredContent(), obj)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:
To keep this function consistent with convertResourceToUnstructured, I think the receiving argument for this function should be the same as return value of the other one.

Suggested change
func convertUnstructuredToResource(u unstructured.Unstructured, obj interface{}) error {
return runtime.DefaultUnstructuredConverter.FromUnstructured(u.UnstructuredContent(), obj)
}
func convertUnstructuredToResource(content map[string]interface{}, obj interface{}) error {
return runtime.DefaultUnstructuredConverter.FromUnstructured(content, obj)
}

@openshift-ci
Copy link

openshift-ci bot commented Nov 24, 2022

@valaparthvi: changing LGTM is restricted to collaborators

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@valaparthvi
Copy link
Contributor

Can we close this in favor of #157?

@dharmit
Copy link
Contributor Author

dharmit commented Dec 8, 2022

@valaparthvi closing this as you requested so.

@dharmit dharmit closed this Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants