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

MGMT-16359: support configured extensions in resource server #47

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

danielerez
Copy link
Collaborator

Similarly to the support add in deployment manager server, this PR is adding a similar functionality to the resource server. The main difference between the implementations is the parsing logic of the objects retrieved from search API.

I.e. since each 'label' property is a single string consists of key=value pairs, the lables should be parsed before evaluating the expression with jq. Hence, added a custom jq function for parsing: parse_labels.

For example:

--extensions={
  "openshift_version": .label|parse_labels|.openshiftVersion,
  "cluster_set": .label|parse_labels|.\"cluster.open-cluster-management.io/clusterset\",
}

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Jan 15, 2024

@danielerez: This pull request references MGMT-16359 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.16.0" version, but no target version was set.

In response to this:

Similarly to the support add in deployment manager server, this PR is adding a similar functionality to the resource server. The main difference between the implementations is the parsing logic of the objects retrieved from search API.

I.e. since each 'label' property is a single string consists of key=value pairs, the lables should be parsed before evaluating the expression with jq. Hence, added a custom jq function for parsing: parse_labels.

For example:

--extensions={
 "openshift_version": .label|parse_labels|.openshiftVersion,
 "cluster_set": .label|parse_labels|.\"cluster.open-cluster-management.io/clusterset\",
}

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 openshift-eng/jira-lifecycle-plugin repository.

Copy link

openshift-ci bot commented Jan 15, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from danielerez. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@danielerez danielerez force-pushed the extensions_resource_jq branch 2 times, most recently from c05bb67 to 9f5dec8 Compare January 15, 2024 14:58
}
labelsMap := data.GetLabelsMap(labels)

r.logger.Error(fmt.Sprintf("r.extensions: %v", r.extensions))
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will probably want to remove this, or replace it with r.logger.Debug(...).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch:) Removed.

SetExtensions(
`{
"operation_system": .label|parse_labels|.os,
"architecture": .label|parse_labels|.arch
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is really nice @danielerez!

Copy link
Collaborator

@jhernand jhernand left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thanks @danielerez. The only reason I am not approving it is that you may want to change address the comment about logging before merging. Let me know and I will happily approve.

Similarly to the support add in deployment manager server,
this PR is adding a similar functionality to the resource server.
The main difference between the implementations is the parsing
logic of the objects retrieved from search API.

I.e. since each 'label' property is a single string consists
of key=value pairs, the lables should be parsed before
evaluating the expression with jq.
Hence, added a custom jq function for parsing: `parse_labels`.

For example:
```
--extensions={
  "openshift_version": .label|parse_labels|.openshiftVersion,
  "cluster_set": .label|parse_labels|.\"cluster.open-cluster-management.io/clusterset\",
}
```
@jhernand
Copy link
Collaborator

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2024
@danielerez danielerez merged commit 5daf9b9 into openshift-kni:main Jan 18, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants