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

utils: Drop MaxInt #65

Merged
merged 1 commit into from
Sep 24, 2024
Merged

utils: Drop MaxInt #65

merged 1 commit into from
Sep 24, 2024

Conversation

oxzi
Copy link
Member

@oxzi oxzi commented Aug 15, 2024

A generic max function was added to Go in version 1.21, making the utils.MaxInt obsolete. Outside, it was not used in neither icingadb, icinga-notifications nor icinga-kubernetes.

$ for project in icingadb icinga-notifications icinga-kubernetes; do pushd "$project"; git checkout main; git pull; grep -r "MaxInt"; popd; done
~/git/github.com/Icinga/icingadb ~/git/github.com/Icinga
Already on 'main'
Your branch is up to date with 'origin/main'.
Already up to date.
cmd/icingadb-migrate/cache.go:                          checkpoint = math.MaxInt64 // start from the largest (possible) ID
cmd/icingadb-migrate/main.go:           ht.fromId = math.MaxInt64
grep: icingadb-migrate: binary file matches
grep: icingadb: binary file matches
~/git/github.com/Icinga
~/git/github.com/Icinga/icinga-notifications ~/git/github.com/Icinga
Already on 'main'
Your branch is up to date with 'origin/main'.
Already up to date.
internal/rule/condition.go:const RetryNever = time.Duration(math.MaxInt64)
~/git/github.com/Icinga
~/git/github.com/Icinga/icinga-kubernetes ~/git/github.com/Icinga
Already on 'main'
Your branch is up to date with 'origin/main'.
Already up to date.
pkg/schema/v1/pod.go:           p.CpuLimits = MaxInt(p.CpuLimits, container.Resources.Limits.Cpu().MilliValue())
pkg/schema/v1/pod.go:           p.CpuRequests = MaxInt(p.CpuRequests, container.Resources.Requests.Cpu().MilliValue())
pkg/schema/v1/pod.go:           p.MemoryLimits = MaxInt(p.MemoryLimits, container.Resources.Limits.Memory().MilliValue())
pkg/schema/v1/pod.go:           p.MemoryRequests = MaxInt(p.MemoryRequests, container.Resources.Requests.Memory().MilliValue())
pkg/schema/v1/utils.go:func MaxInt[T constraints.Integer](x, y T) T {
~/git/github.com/Icinga

A generic max function was added to Go in version 1.21[0], making the
utils.MaxInt obsolete. Outside, it was not used in neither icingadb,
icinga-notifications nor icinga-kubernetes.

> $ for project in icingadb icinga-notifications icinga-kubernetes; do pushd "$project"; git checkout main; git pull; grep -r "MaxInt"; popd; done
> ~/git/github.com/Icinga/icingadb ~/git/github.com/Icinga
> Already on 'main'
> Your branch is up to date with 'origin/main'.
> Already up to date.
> cmd/icingadb-migrate/cache.go:                          checkpoint = math.MaxInt64 // start from the largest (possible) ID
> cmd/icingadb-migrate/main.go:           ht.fromId = math.MaxInt64
> grep: icingadb-migrate: binary file matches
> grep: icingadb: binary file matches
> ~/git/github.com/Icinga
> ~/git/github.com/Icinga/icinga-notifications ~/git/github.com/Icinga
> Already on 'main'
> Your branch is up to date with 'origin/main'.
> Already up to date.
> internal/rule/condition.go:const RetryNever = time.Duration(math.MaxInt64)
> ~/git/github.com/Icinga
> ~/git/github.com/Icinga/icinga-kubernetes ~/git/github.com/Icinga
> Already on 'main'
> Your branch is up to date with 'origin/main'.
> Already up to date.
> pkg/schema/v1/pod.go:           p.CpuLimits = MaxInt(p.CpuLimits, container.Resources.Limits.Cpu().MilliValue())
> pkg/schema/v1/pod.go:           p.CpuRequests = MaxInt(p.CpuRequests, container.Resources.Requests.Cpu().MilliValue())
> pkg/schema/v1/pod.go:           p.MemoryLimits = MaxInt(p.MemoryLimits, container.Resources.Limits.Memory().MilliValue())
> pkg/schema/v1/pod.go:           p.MemoryRequests = MaxInt(p.MemoryRequests, container.Resources.Requests.Memory().MilliValue())
> pkg/schema/v1/utils.go:func MaxInt[T constraints.Integer](x, y T) T {
> ~/git/github.com/Icinga

[0]: https://pkg.go.dev/builtin#max
@oxzi oxzi added the enhancement New feature or request label Aug 15, 2024
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Aug 15, 2024
@oxzi oxzi mentioned this pull request Aug 15, 2024
@lippserd lippserd added this to the 0.4.0 milestone Sep 19, 2024
@lippserd lippserd merged commit afba056 into main Sep 24, 2024
2 checks passed
@lippserd lippserd deleted the drop-utils-maxint branch September 24, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants