spec

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MPL-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package spec contains types and functions used for parsing, and validating a Specification.

Index

Constants

View Source
const (
	Version0_1 = "0.1"
)

Variables

View Source
var (
	//go:embed v0.1/schema.json
	JSONSchemaVersion0_1 []byte
)

Functions

func Validate

func Validate(ctx context.Context, document []byte) error

Validate loads the schema version specified in the document, and validates the document.

Types

type Request

type Request struct {
	Create RequestType    `json:"create,omitempty"`
	Read   RequestType    `json:"read"`
	Update []*RequestType `json:"update"`
	Delete RequestType    `json:"delete"`
}

type RequestBody

type RequestBody struct {
	Name     string   `json:"name"`
	Required []string `json:"required"`
}

type RequestType

type RequestType struct {
	Parameters  []string     `json:"parameters,omitempty"`
	RequestBody *RequestBody `json:"request_body,omitempty"`
	Response    string       `json:"response,omitempty"`
}

type Requests

type Requests []Request

type Specification

type Specification struct {
	// DataSources defines a slice of datasource.DataSource type.
	DataSources datasource.DataSources `json:"datasources,omitempty"`

	// Provider defines an instance of the provider.Provider type.
	Provider *provider.Provider `json:"provider,omitempty"`

	// Resources defines a slice of resource.Resource type.
	Resources resource.Resources `json:"resources,omitempty"`

	// Request(Parameters, Body) struct for CRUD
	Requests Requests `json:"requests,omitempty"`

	// Version defines the Provider Code Specification JSON schema version
	Version string `json:"version,omitempty"`
}

Specification defines the data source(s), provider, and resource(s) for a Terraform provider.

func Parse

func Parse(ctx context.Context, document []byte) (Specification, error)

Parse returns a Specification from the JSON document contents, or any validation errors.

func (Specification) Validate

func (s Specification) Validate(ctx context.Context) error

Validate delegates validation to each of datasource.DataSources, *provider.Provider and resource.Resources.

Jump to

Keyboard shortcuts

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