defaults

package
v0.60.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package defaults exposes what Radius ships as defaults: the resource types that are registered out of the box, the icons drawn for them, and the upstream resource-types-contrib revisions those defaults were built from.

All of it is declared in deploy/manifest/defaults.yaml and its sibling SVG assets, which are embedded into every Radius binary by the assets-only package github.com/radius-project/radius/deploy/manifest (//go:embed cannot reach outside its own directory, and those files are deployment artifacts that the build tooling owns). This package parses those bytes once at init and serves them through the accessors below.

Icons

Four consumers read icons:

  1. The static (modeled) graph builder in `pkg/cli/graph` — the CLI binary has no control plane to consult, so it resolves per-node iconHash values from the embedded map.
  2. The runtime graph pipeline in `pkg/corerp/frontend/controller/applications` for substituting the default icon's bytes into the response's `icons` map for types whose stored `iconHash` matches the default. Default icons are the fallback for connected external cloud nodes that are not registered in the local Radius resource-type registry. They are also used when a user does not supply an icon for the resource type.
  3. The resource-type registration path — `pkg/ucp/initializer` and the `pkg/ucp/api` conversion layer — which stamps the default hash onto a type registered without an icon of its own.
  4. The icon endpoint in `pkg/ucp/frontend/controller/resourceproviders`, which serves the default bytes back for those types.

Icon absence is never an error. Icons are cosmetic, so a missing or malformed one must not fail a graph request, refuse a resource-type registration, or crash the process. Three states are modeled, in fallback order:

  1. Per-type SVG registered by the user (or shipped in `built-in-providers/self-hosted/<typeName>.svg`) — use it.
  2. Product default icon (embedded `default-icon.svg`) — use it when 1 is unavailable.
  3. Both unavailable — leave the node's `iconHash` unset (nil). Downstream consumers render the node without an icon.

The unavailable-default case is degenerate (only triggered if the build shipped a broken asset), so it is surfaced by logging to stderr at init time. Callers ask for a hash via DefaultIconHash (returns nil if none) and for bytes via DefaultIcon (empty Icon if none); both are safe to call unconditionally.

Pins

The same file records which upstream revision each default was taken from. ResourceTypePin exposes those entries so release builds can address the artifacts published from exactly that revision — see `pkg/cli/recipepack`, which uses the pinned commit SHA as the OCI tag of each core recipe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultIconHash

func DefaultIconHash() *string

DefaultIconHash returns a pointer to the product default icon's hash suitable for assigning directly to a resource-type record or graph node's IconHash field. Returns nil when the default is unavailable — callers should forward that nil to leave IconHash unset on their outputs (rather than storing a pointer to an empty string). This is the single spelling of the "graceful degradation" fallback used across the registration path, the runtime graph pipeline, and the static graph builder.

func IsDefaultIcon

func IsDefaultIcon(hash string) bool

IsDefaultIcon reports whether the given hex-encoded SHA-256 hash matches the product default icon's hash. Returns false when the given hash is empty or when the default is unavailable — safe to call unconditionally.

func SplitResourceType

func SplitResourceType(resourceType string) (namespace, typeName string, ok bool)

SplitResourceType splits a fully-qualified resource type of the form "<namespace>/<typeName>" (e.g. "Radius.Compute/containers") into its two parts. Returns ("", "", false) if the input does not match that shape (no separator, empty namespace, or empty type name). This is the format used by defaultRegistration in defaults.yaml and by every consumer of LookupIcon, and it is also how graph pipelines bucket resources by provider namespace before calling GetProviderSummary.

Types

type Icon

type Icon struct {
	// Hash is the SHA-256 of Bytes, hex-encoded. Matches the `iconHash` field
	// stored on the resource-type record and returned in graph responses.
	Hash string
	// Bytes is the verbatim SVG UTF-8 content of the icon.
	Bytes []byte
}

Icon is the SVG bytes and SHA-256 hex hash of a resource-type icon.

func DefaultIcon

func DefaultIcon() Icon

DefaultIcon returns the Radius product default icon. Every Radius binary carries the same bytes, so a hash produced anywhere in the codebase is comparable to one produced by the control plane during resource-type registration. Both fields are zero-valued (empty Hash, nil Bytes) when the embedded default asset failed to load at init time; see the package doc for the "icon absence is not an error" contract.

func LookupIcon

func LookupIcon(resourceType string) (Icon, bool)

LookupIcon returns the icon for the given fully-qualified resource type (e.g. "Radius.Compute/containers"). ok is false when the type is not in defaults.yaml or its SVG has not yet been shipped in resource-types-contrib. Callers that want a guaranteed icon should fall through to DefaultIcon.

type Pin

type Pin struct {
	// Name identifies the entry: a resource-type namespace (e.g.
	// "Radius.Compute") under `resourceTypes`, or a recipe pack folder (e.g.
	// "azure") under `recipePacks`.
	Name string
	// Repo is the upstream repository the entry is fetched from, without a
	// scheme (e.g. "github.com/radius-project/resource-types-contrib").
	Repo string
	// Ref is the immutable commit SHA the entry is pinned to.
	Ref string
	// Tag is the upstream release tag Ref was resolved from (e.g.
	// "Radius.Compute/v0.2.0"), or empty when the pin came from the edge
	// channel. Note that tags are not valid OCI tags — they may contain "/".
	Tag string
}

Pin records the upstream revision that defaults.yaml pins one entry to. The `resourceTypes` and `recipePacks` sections share this shape, so one type serves both.

func ResourceTypePin

func ResourceTypePin(namespace string) (Pin, bool)

ResourceTypePin returns the upstream revision that defaults.yaml pins the given resource-type namespace (e.g. "Radius.Compute") to. ok is false when the namespace has no `resourceTypes` entry — callers apply their own fallback rather than treating that as fatal, because a mis-configured build should still produce a working product (see pkg/cli/recipepack.resolveRecipeTag, which falls back to the "edge" OCI tag).

Pin.Ref is the immutable commit SHA recorded by `make update-resource-types` and is safe to use directly as an OCI tag: commit SHAs match the OCI tag character set, and the resource-types-contrib publishing pipeline stamps that SHA on each artifact it publishes for the namespace. Pin.Tag is not — upstream release tags are namespaced with "/" (e.g. "Radius.Compute/v0.2.0").

Jump to

Keyboard shortcuts

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