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

Update container #98

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Update container #98

wants to merge 2 commits into from

Conversation

mdellweg
Copy link
Member

@mdellweg mdellweg commented Jun 4, 2024

No description provided.

@mdellweg mdellweg force-pushed the update_container branch 5 times, most recently from 09f7286 to a032ed7 Compare June 6, 2024 14:36
This also allows to consume the *api.json from anywhere, as it's
processed into patched-api.json prior to be used in the container.

[noissue]
@mdellweg mdellweg force-pushed the update_container branch 2 times, most recently from 10309ba to 04312c5 Compare June 29, 2024 11:13
Copy link
Contributor

@gerrod3 gerrod3 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 correct to me, left some questions.

Comment on lines +67 to +68
FIX_TASK_CREATED_RESOURCES_FILTER='(.components.schemas.TaskResponse|select(.)|.properties.created_resources.items) |= {"$oneOf":[{type:"null"},.]}'
FIX_TASK_ERROR_FILTER='(.components.schemas.TaskResponse|select(.)|.properties.error) |= (del(.readOnly) | .additionalProperties.type = "string")'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain what these filters are doing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both of them are necessary, because the newer templates do more sophisticated validation on the http responses than before.
The first one is to allow the created_resources list to contain null entries, which happens when we delete a resource formerly locked by the task. (It is not even evident to me whether it's better to not report them on the server side anymore, but as a matter of fact, current pulp violates the schema here.)
The second one, I'm not even sure this is the right thing to do. But what is does: It removes the readOnly property from the error attribute and changes its additionalProperties to be strings. I encountered this in some tests, where the bindings were unable to instantiate a TaskResponse object for the readOnly thing and it's unclear to me why this should be an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote these filters as Variables (Constants) because they may be useful to the other generators too. Who knows...

@@ -433,12 +464,15 @@ conf = {{{packageName}}}.Configuration(
auth = {}
{{#authMethods}}
{{#isApiKey}}
if '{{keyParamName}}' in self.api_key:
if '{{name}}' in self.api_key{{#vendorExtensions.x-auth-id-alias}} or '{{.}}' in self.api_key{{/vendorExtensions.x-auth-id-alias}}:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this what we are modifying from the original template?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's been too long...
I kind of did a manual 3-way merge pulling the new and old versions of the templates from git to see what we changed originally.
This honestly looks like an improvement of the auth code on the o-a-generator side.

_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le={{#servers.size}}{{servers.size}}{{/servers.size}}{{^servers.size}}1{{/servers.size}})] = 0,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this indentation on the last line suppose to be there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohhhh, yes!
This is a mustache partial template. It will be templated inside another template, and mustache does not seem to have good whitespace control for that. And you can surely imagine how this plays nicely with python. XD

@mdellweg mdellweg marked this pull request as draft July 15, 2024 09:58
@mdellweg
Copy link
Member Author

This new version of the container uses pydantic to validate http responses. I believe this will lead to a whole lot of new test failures. I'm not sure we are ready for this.
Specifically not since we cannot opt out of it for older plugin branches.

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.

2 participants