metadataservice

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package metadataservice provides the v1 api for the metadata service

Index

Constants

View Source
const (
	// V20090404URI is the path prefix for the ec2-style (v2009-04-04) format
	V20090404URI = "/2009-04-04"

	// Ec2MetadataURI is the path to the ec2-style metadata endpoint for listing
	// available metadata items for the instance.
	Ec2MetadataURI = "/meta-data"

	// Ec2MetadataItemURI is the path to the ec2-style metadata endpoint for
	// retrieving a specified metadata item value.
	Ec2MetadataItemURI = "/meta-data/*subpath"

	// Ec2UserdataURI is the path to the ec2-style userdata endpoint
	Ec2UserdataURI = "/user-data"
)
View Source
const (
	// V1URI is the path prefix for all v1 endpoints
	V1URI = "/api/v1"

	// MetadataURI is the path to the regular metadata endpoint, called by the
	// instances themselves to retrieve their metadata.
	MetadataURI = "/metadata"

	// UserdataURI is the path to the regular userdata endpoint, called by the
	// instances themselves to retrieve their userdata.
	UserdataURI = "/userdata"

	// InternalMetadataURI is the path to the internal (authenticated) endpoint
	// used for updating & retrieving metadata for any instance
	InternalMetadataURI = "/device-metadata"

	// InternalUserdataURI is the path to the internal (authenticated) endpoint
	// used for updating & retrieving metadata for any instance
	InternalUserdataURI = "/device-userdata"

	// InternalMetadataWithIDURI is the path to the internal (authenticated)
	// endpoint used for retrieving the stored metadata for an instance
	InternalMetadataWithIDURI = "/device-metadata/:instance-id"

	// InternalUserdataWithIDURI is the path to the internal (authenticated)
	// endpoint used for retrieving the stored metadata for an instance
	InternalUserdataWithIDURI = "/device-userdata/:instance-id"
)

Variables

View Source
var (

	// ErrUUIDNotFound is returned when an expected uuid is not provided.
	ErrUUIDNotFound = errors.New("uuid not found")

	// ErrInvalidUUID is returned when an invalid uuid is provided.
	ErrInvalidUUID = errors.New("invalid uuid")
)

Functions

func GetEc2MetadataItemPath

func GetEc2MetadataItemPath(itemPath string) string

GetEc2MetadataItemPath returns the path used to fetch a specific metadata item. Ex: GetEx2MetadataItemPath("foo/bar/baz") returns: "/2009-04-04/meta-data/foo/bar/baz"

func GetEc2MetadataPath

func GetEc2MetadataPath() string

GetEc2MetadataPath returns the path used to fetch a list of the ec2-style metadata item fields for the instance

func GetEc2UserdataPath

func GetEc2UserdataPath() string

GetEc2UserdataPath returns the path used to fetch ec2-style userdata

func GetInternalMetadataByIDPath

func GetInternalMetadataByIDPath(id string) string

GetInternalMetadataByIDPath returns the path used by an internal, authenticated system or user to retrieve the metadata for a specific instance.

func GetInternalMetadataPath

func GetInternalMetadataPath() string

GetInternalMetadataPath returns the path used by an internal, authenticated system or used to update or retrieve metadata.

func GetInternalUserdataByIDPath

func GetInternalUserdataByIDPath(id string) string

GetInternalUserdataByIDPath returns the path used by an internal, authenticated system or user to retrieve the metadata for a specific instance.

func GetInternalUserdataPath

func GetInternalUserdataPath() string

GetInternalUserdataPath returns the patch used by an internal, authenticated system or used to update or retrieve userdata.

func GetMetadataPath

func GetMetadataPath() string

GetMetadataPath returns the path used by an instance to fetch Metadata

func GetUserdataPath

func GetUserdataPath() string

GetUserdataPath returns the path used by an instance to fetch Userdata

Types

type ErrorResponse

type ErrorResponse struct {
	Message string   `json:"message,omitempty"`
	Errors  []string `json:"errors,omitempty"`
}

ErrorResponse represents an error response record

type Router

type Router struct {
	AuthMW         *ginjwt.Middleware
	DB             *sqlx.DB
	Logger         *zap.Logger
	LookupEnabled  bool
	LookupClient   lookup.Client
	TemplateFields map[string]template.Template
}

Router provides a router for the v1 API

func (*Router) Ec2Routes

func (r *Router) Ec2Routes(rg *gin.RouterGroup)

Ec2Routes will add the routes for the EC2-style API to a router group

func (*Router) Routes

func (r *Router) Routes(rg *gin.RouterGroup)

Routes will add the routes for this API version to a router group

type UpsertMetadataRequest

type UpsertMetadataRequest struct {
	ID          string   `json:"id" validate:"required,uuid"`
	Metadata    string   `json:"metadata" validate:"required,json"`
	IPAddresses []string `json:"ipAddresses" validate:"dive,ip_addr|cidr"`
}

UpsertMetadataRequest contains the fields for inserting or updating an instances metadata.

type UpsertUserdataRequest

type UpsertUserdataRequest struct {
	ID          string   `json:"id" validate:"required,uuid"`
	Userdata    []byte   `json:"userdata"`
	IPAddresses []string `json:"ipAddresses" validate:"dive,ip_addr|cidr"`
}

UpsertUserdataRequest contains the fields for inserting or updating an instances userdata.

Directories

Path Synopsis
Package ec2 provides for converting metadata json to a more ec2-like format
Package ec2 provides for converting metadata json to a more ec2-like format

Jump to

Keyboard shortcuts

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