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

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Update container #98

merged 1 commit into from
Dec 10, 2024

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
@mdellweg mdellweg force-pushed the update_container branch 3 times, most recently from 04312c5 to b9099c8 Compare July 4, 2024 20:01
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.

gen-client.sh Outdated
Comment on lines 67 to 102
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

Copy link
Member

Choose a reason for hiding this comment

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

@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.

@mdellweg mdellweg force-pushed the update_container branch 2 times, most recently from fb5c54d to 23b017f Compare December 3, 2024 16:08
gen-client.sh Outdated Show resolved Hide resolved
@mdellweg mdellweg marked this pull request as ready for review December 10, 2024 15:03
@mdellweg
Copy link
Member Author

If we merge this now, i think it will be picked up once pulpcore main bumped it's version to 3.70.0.dev. And we have time til mid January to fix stuff, right?

@pedro-psb
Copy link
Member

And we have time til mid January to fix stuff, right?

I hope so

Copy link
Member

@pedro-psb pedro-psb left a comment

Choose a reason for hiding this comment

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

From what I remember (in the context I worked), most of, if not all, the mustache stuff was just a copy over from the generator. Is that the case here? Back then I though this was a bit confusing that we were shadowing files without any changes. Also it was not so straightfoward to spot what we are actually overriding or not.

@mdellweg
Copy link
Member Author

From what I remember (in the context I worked), most of, if not all, the mustache stuff was just a copy over from the generator. Is that the case here? Back then I though this was a bit confusing that we were shadowing files without any changes. Also it was not so straightfoward to spot what we are actually overriding or not.

If you copy the files into the original openapi-generator repository, you can diff that. I even committed them there to reabase onto the newer tag and copied the result back. All three of those files carry pulp specific changes.

@mdellweg mdellweg enabled auto-merge December 10, 2024 18:26
Copy link
Member

@pedro-psb pedro-psb left a comment

Choose a reason for hiding this comment

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

Let's go for it.

@mdellweg mdellweg merged commit f1a4448 into pulp:main Dec 10, 2024
3 checks passed
@mdellweg mdellweg deleted the update_container branch December 10, 2024 19:01
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