Skip to content

feat: Add coordinates to Location spec - #328

Merged
kevwilliams merged 1 commit into
mainfrom
feat/location-coordinates
Jul 30, 2026
Merged

feat: Add coordinates to Location spec#328
kevwilliams merged 1 commit into
mainfrom
feat/location-coordinates

Conversation

@kevwilliams

@kevwilliams kevwilliams commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

A Location only carries a topology.datum.net/city-code value — there's no latitude/longitude anywhere on the resource, so any UI that wants to plot a location on a map (e.g. the compute portal plugin's instance locations view) has to maintain its own hand-rolled city-code → coordinates lookup table.

This adds an optional spec.coordinates field with latitude/longitude. Both are strings rather than floats — controller-gen flags float fields as discouraged, matching the broader Kubernetes API convention against them — validated with a regex pattern plus a CEL rule enforcing the real range ([-90, 90] for latitude, [-180, 180] for longitude) at the apiserver.

The field is optional and additive, so existing Locations without coordinates are unaffected.

Test plan

  • make manifests generate api-docs — CRD schema, deepcopy, and API docs regenerated
  • make lint — clean
  • make test — full suite passes, including new envtest coverage:
    • a Location with valid coordinates is accepted and round-trips
    • a Location with coordinates omitted still creates fine (backward compatible)
    • an out-of-range latitude (95.0) is rejected by the CEL rule
    • a non-numeric coordinate is rejected by the pattern

Fixes #327

Location previously only carried a topology.datum.net/city-code value,
with no latitude/longitude anywhere on the resource. Consumers that
want to plot a location on a map (e.g. the compute portal plugin's
instance locations view) had no way to do that without a hand-maintained
city-code lookup table.

Add an optional spec.coordinates field with latitude/longitude. Both
are serialized as strings rather than floats, per Kubernetes API
convention, with a regex pattern plus a CEL range rule
(double(self) within [-90, 90] / [-180, 180]) enforced at the
apiserver.

Key changes:
- Add Coordinates type and LocationSpec.Coordinates field
- Regenerate CRD manifests, deepcopy, and API docs
- Add envtest coverage for the happy path, the optional-field case, and
  both CEL/pattern rejections

Fixes #327
@kevwilliams
kevwilliams merged commit 59443ae into main Jul 30, 2026
11 checks passed
@kevwilliams
kevwilliams deleted the feat/location-coordinates branch July 30, 2026 16:38
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.

Locations don't carry coordinates, so they can't be plotted on a map

3 participants