userdata

package
v1.18.7 Latest Latest
Warning

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

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

README

User Data

Purpose

pkg/userdata owns the API-boundary contract for cloud-init user-data validation: which payloads a create request may carry, and the exact HTTP 422 (status and message) returned when one is rejected.

It exists as a standalone package — rather than living in a handler — because the contract is shared across services: this repository's v2 server handler and the compute service's instances handler both call Validate, so the behaviour is identical everywhere by construction rather than by convention.

Behaviour

  • Absent user-data is valid.
  • Unmanaged payloads (no SSH certificate authority) must be recognizable cloud-init; gzip is additionally permitted because it is passed to the platform unmodified.
  • Managed payloads (an SSH certificate authority is referenced) must support managed cloud-init augmentation, which excludes gzip.
  • Rejections carry the parser's specific reason, recovered structurally from the parser's typed error — never by parsing message strings.

Cross-Package Context

Documentation

Overview

Package userdata owns the API-boundary contract for cloud-init user-data validation. It is deliberately importable by other services (the compute instances API consumes it alongside this repository's own server handler) so the HTTP status and message for rejected user-data are identical everywhere by construction rather than by convention.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(userData *[]byte, managed bool) error

Validate is the canonical boundary check for user-data carried on create requests. Absent user-data is valid. managed selects the stricter check for payloads that will receive managed cloud-init augmentation (an SSH certificate authority is referenced), which excludes gzip. Malformed payloads yield the ready HTTP 422 carrying the parser's specific reason.

Types

This section is empty.

Jump to

Keyboard shortcuts

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