Skip to content

Adopt FoundationEssentials when available#14

Merged
iabudiab merged 12 commits into
swiftkube:mainfrom
t089:foundation-essentials
May 4, 2026
Merged

Adopt FoundationEssentials when available#14
iabudiab merged 12 commits into
swiftkube:mainfrom
t089:foundation-essentials

Conversation

@t089
Copy link
Copy Markdown
Contributor

@t089 t089 commented Apr 15, 2026

This integrates the generated model classes using FoundationEssentials and ensures that all non-generated code only uses FoundationEssentials. This requires moving some API from Fondation-API to stdlib.

Related: swiftkube/modelgen#3

Tobias Haeberle and others added 7 commits March 29, 2026 16:08
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use explicit String(unit) conversion from Substring since
FoundationEssentials doesn't implicitly convert Substring to String.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerated model files from K8s v1.34.6 OpenAPI spec.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@iabudiab
Copy link
Copy Markdown
Member

@t089 The code generated by modelgen can't be dropped-in directly, there are 2-3 steps that I usually do manually. (I couldn't be bothered to fully automate it 😅)

And one other thing, model is already at v1.34.6.

If you want, I can take it from here. Just let me know 😉

Thanks!

@iabudiab
Copy link
Copy Markdown
Member

Generated model for v1.35.3 is ready. I could push on a branch if you want to incorporate it, or directly on main.
Just let me know how you want to go about it. Either is fine 😉

@t089
Copy link
Copy Markdown
Contributor Author

t089 commented Apr 28, 2026

Feel free to take it from here. I've already suspected that there are a couple of hidden steps ;) thanks for the help!

@t089
Copy link
Copy Markdown
Contributor Author

t089 commented Apr 28, 2026

actually, I've reverted the generated files on this branch now. So this branch now only contains changes to non-generated files.

@t089 t089 marked this pull request as ready for review April 28, 2026 10:03
Comment thread Sources/Model/Quantity.swift Outdated
let regex = try! NSRegularExpression(pattern: "^\\d*\\.?\\d*e?\\d*", options: [])
let results = regex.matches(in: str, options: [], range: range)
if results.count != 1 {
let regex = /^\d*\.?\d*e?\d*/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This won't compile w/o increasing min SDKs to: .macOS(.v13), .iOS(.v16), .tvOS(.v16), .watchOS(.v9) and swift-tools-version to 5.7

@t089 t089 requested a review from iabudiab April 29, 2026 18:12
Comment on lines 30 to 44
func pow(_ base: Int, _ exponent: Int) -> Decimal {
let baseDecimal = Decimal(base)
if exponent < 0 {
return 1 / pow(Decimal(base), -1 * exponent)
var result = Decimal(1)
for _ in 0 ..< -exponent {
result /= baseDecimal
}
return result
} else {
return pow(Decimal(base), exponent)
var result = Decimal(1)
for _ in 0 ..< exponent {
result *= baseDecimal
}
return result
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is what claude came up with ... apparently Swift 6.0 is missing the pow(Decimal, Int) method

@t089
Copy link
Copy Markdown
Contributor Author

t089 commented Apr 30, 2026

@iabudiab Sorry, fixed the formatting and also validated locally that it builds in all the swift versions the CI is using. We could consider moving the minimum to 6.0 or even 6.1. Not sure what the ecosystem recommendation was, maybe last two previous minor versions?

@iabudiab
Copy link
Copy Markdown
Member

iabudiab commented May 4, 2026

@t089 no worries at all. As I've mentioned in the PR for the client, I wanted to increase the baseline to Swift 6.0 anyway. I'll merge your changes and take it from here ;)

Thank you very much for the PRs. (and the trigger to do some updates)

@iabudiab iabudiab merged commit b662053 into swiftkube:main May 4, 2026
6 of 7 checks passed
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