region

package
v1.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

Region

Purpose

pkg/handler/region is the read-side handler for region capabilities and visibility.

Unlike most other handlers in this tree, it is not primarily about creating or mutating user-owned lifecycle resources. Its job is to expose:

  • visible regions
  • region detail
  • provider-derived flavor inventory
  • provider-derived external network inventory

So this package is where the service turns stored region configuration and provider capability discovery into user-visible region catalogue data.

Distinctive Behaviour

  • region visibility is filtered against region security constraints and the caller's organization scope
  • flavor and external-network reads cross the provider boundary rather than reading from CRD-backed child resources
  • flavor conversion passes through the shared conversion package because flavor is a provider concept rather than a first-class CRD

Invariants And Guard Rails

  • Regions are looked up directly from shared storage and then filtered for visibility.
  • Provider-derived capability reads must resolve the correct provider for the selected region rather than trusting client-supplied assumptions.
  • Flavor ordering is intentionally stable and user-facing.
  • Region ACL checking is enforced in two places:
    • List responses (FilterRegions) — removes regions the caller cannot see before building the response.
    • User-supplied region IDs (CheckAccess) — called at the top of any handler or client method that accepts a region ID as input (path parameter, query parameter, or request body field). This prevents a caller who knows a restricted region's ID from using it without authorization.
  • CheckAccess returns HTTPNotFound rather than HTTPForbidden to avoid confirming the existence of regions the caller cannot see.

Caveats

  • This package is mostly read-side and therefore much simpler than the resource lifecycle handlers. Do not use it as the model for the rest of the handler layer.
  • Region visibility is a service policy concern, not a storage property of the Region CRD by itself. Both the list filter and the per-ID access check must use the same ACL logic — they share the unexported checkAccess helper to enforce this.

Cross-Package Context

  • ../README.md explains why provider-backed capability reads sit alongside CRD-backed handler logic in this layer
  • ../conversion covers the shared flavor conversion boundary
  • ../../providers documents the provider capability contracts consumed here

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResource is raised when a resource is in a bad state.
	ErrResource = goerrors.New("resource error")

	// ErrRegionNotFound is raised when a region doesn't exist.
	ErrRegionNotFound = goerrors.New("region doesn't exist")
)

Functions

func FilterRegions added in v1.13.0

func FilterRegions(ctx context.Context, regions *unikornv1.RegionList)

Types

type Client

type Client struct {
	common.ClientArgs
}

func NewClient

func NewClient(clientArgs common.ClientArgs) *Client

func (*Client) CheckAccess added in v1.16.6

func (c *Client) CheckAccess(ctx context.Context, regionID string) error

CheckAccess fetches the region by ID and verifies the caller's organization is allowed to use it. Returns HTTPNotFound for both missing and inaccessible regions to avoid confirming region existence to unauthorized callers.

func (*Client) GetDetail added in v0.1.53

func (c *Client) GetDetail(ctx context.Context, regionID string) (*openapi.RegionDetailRead, error)

func (*Client) List

func (c *Client) List(ctx context.Context) (openapi.Regions, error)

func (*Client) ListExternalNetworks added in v1.3.0

func (c *Client) ListExternalNetworks(ctx context.Context, regionID string) (openapi.ExternalNetworks, error)

func (*Client) ListFlavors added in v1.3.0

func (c *Client) ListFlavors(ctx context.Context, organizationID, regionID string) (openapi.Flavors, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL