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

Add support for modifying field properties prior to model generation #874

Merged
merged 3 commits into from
Nov 23, 2023

Conversation

flaviuvadan
Copy link
Collaborator

Pull Request Checklist

#869 reports how the field IntOrString incorrectly renders the port specification into a string that's not accepted by K8s. This PR adds a spec modification strategy that takes the remote Argo OpenAPI JSON specification and modifies the field from IntOrString to integer. This way the correct model is generated, and users know an integer is supposed to be used. Ideally, we'd fix these upstream but this at least unblocks current Hera users.

@flaviuvadan flaviuvadan added semver:patch A change requiring a patch version bump type:bug A general bug labels Nov 23, 2023
Copy link

codecov bot commented Nov 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (862c45b) 79.6% compared to head (b6a06e1) 79.6%.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #874   +/-   ##
=====================================
  Coverage   79.6%   79.6%           
=====================================
  Files         45      45           
  Lines       3730    3730           
  Branches     758     758           
=====================================
  Hits        2972    2972           
  Misses       562     562           
  Partials     196     196           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Flaviu Vadan <flaviuvadan@gmail.com>
Signed-off-by: Flaviu Vadan <flaviuvadan@gmail.com>
Signed-off-by: Flaviu Vadan <flaviuvadan@gmail.com>
Copy link
Collaborator

@elliotgunton elliotgunton left a comment

Choose a reason for hiding this comment

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

I'm conscious of scripts/spec.py being a bit hacky at this point, but it's to address problems upstream so 🤷‍♂️ Also, the fix in the underlying generated code is probably a smart union to try to use an int if it looks like an int. But that's for separate investigation/PR

@@ -1526,7 +1526,7 @@ class HTTPGetAction(BaseModel):
description=("Custom headers to set in the request. HTTP allows repeated headers."),
)
path: Optional[str] = Field(default=None, description="Path to access on the HTTP server.")
port: intstr.IntOrString = Field(
port: int = Field(
...,
description=(
"Name or number of the port to access on the container. Number must be in"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting that the description is "name or number" 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea.. and all other ports I looked at, on other objects, are integers. Perhaps it's a backwards compatibility thing that upstream tried to address. I lack the context

@elliotgunton elliotgunton merged commit 6cba295 into main Nov 23, 2023
17 checks passed
@elliotgunton elliotgunton deleted the fv/869 branch November 23, 2023 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump type:bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTPGetAction "port: int" will output as string in yaml
2 participants