sdk

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 9 Imported by: 0 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 sdk is the sdk group: osapi sdk list, get, spec get and validate, which describe and check the Go SDK in this binary, as each DSL's group does and as osapi agent collector does for gohai's collectors.

Index

Constants

This section is empty.

Variables

View Source
var Group = command.Register(command.Define(
	"sdk", "List, describe and check the Go SDK in this binary: its types and its services",
	command.Uses[Deps](),
	command.SubDoc("spec", "Print the parts of the Go SDK"),
	command.Method[ListInput, ListOutput]("list").
		Short("List the types for values and the services of the client").
		Example("").
		Prints(sampleList).
		Example("--json").
		Handle(List),
	command.Method[GetInput, GetOutput]("get").
		Short("Show a type with its values, or a service with its methods").
		Long("A name of a type, such as ContentType, shows its doc and its values. A\n"+
			"name of a service, such as Hostname, shows each method with the permission\n"+
			"that it needs, its route, its input and its result.").
		Example("--name Hostname").
		Prints(sampleGet).
		Example("--name ContentType --json").
		Fails("no name", GetInput{}).
		Handle(Get),
	command.Method[SpecInput, SpecOutput]("get").
		Sub("spec").
		Short("Print the Go SDK: its packages, how a call works, its types and its services").
		Long("The list comes from this binary, from types.All and client.Services. Thus it\n"+
			"agrees with the build that you run. The SDK skill is made from it.").
		Example("").
		Prints(sampleSpec).
		Example("--json").
		Handle(Spec),
	command.Method[ValidateInput, ValidateOutput]("validate").
		Short("Check the SDK against its rules").
		Long("It prints each problem with its name, rule and message, then the fix of each\n"+
			"rule, and exits 1 when a rule fails.\n\n"+
			"The rules:\n\n"+sdkspec.Checks.Help()).
		Example("").
		Prints(sampleValidate).
		Example("--json").
		Handle(Validate),
))

Group is the sdk group's definition.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	// Types are the types for values, types.All in the binary.
	Types func() []types.TypeSpec
	// Services are the services of the client, client.Services in the binary.
	Services func() []client.ServiceSpec
}

Deps is what the sdk commands read: the SDK's description of itself.

type GetInput

type GetInput struct {
	Name string `json:"name" validate:"required" doc:"A type, such as ContentType, or a service, such as Hostname"`
}

GetInput names a type or a service.

type GetOutput

type GetOutput struct {
	Type    *types.TypeSpec     `            json:"type,omitempty"`
	Service *client.ServiceSpec `            json:"service,omitempty"`
	// contains filtered or unexported fields
}

GetOutput is the type or the service of the name.

func Get

func Get(
	_ context.Context,
	d Deps,
	in GetInput,
) (GetOutput, error)

Get is the type or the service of in.Name. A type may be named with its package, such as types.ContentType.

type Item

type Item struct {
	Kind  Kind   `json:"kind"`
	Name  string `json:"name"`
	Count int    `json:"count" doc:"The values of a type, or the methods of a service"`
	Doc   string `json:"doc"                                                           render:"short=60"`
}

Item is one row of list.

type Kind

type Kind string

Kind is what a row of list is: a type or a service.

const (
	// KindType is a type for values of pkg/sdk/types.
	KindType Kind = "type"
	// KindService is a service of the client.
	KindService Kind = "service"
)

The kinds of a row of list.

func (Kind) Valid

func (k Kind) Valid() bool

Valid reports whether k is a kind of a row.

func (Kind) Values

func (Kind) Values() []Kind

Values are the kinds of a row.

type ListInput

type ListInput struct{}

ListInput is the input of list, which has none.

type ListOutput

type ListOutput struct {
	Items []Item `            json:"items"`
	// contains filtered or unexported fields
}

ListOutput is each type for values, then each service.

func List

func List(
	_ context.Context,
	d Deps,
	_ ListInput,
) (ListOutput, error)

List is each type for values, then each service of the client.

type SpecInput

type SpecInput struct{}

SpecInput is the input of spec get, which has none.

type SpecOutput

type SpecOutput struct {
	Kinds []guide.Section `json:"kinds" table:"sections"`
}

SpecOutput is each kind of term of the SDK, with its terms.

func Spec

func Spec(
	_ context.Context,
	d Deps,
	_ SpecInput,
) (SpecOutput, error)

Spec is each part of the SDK.

type ValidateInput

type ValidateInput struct{}

ValidateInput is the input of validate, which has none.

type ValidateOutput

type ValidateOutput struct {
	Types    int               `                   json:"types"`
	Services int               `                   json:"services"`
	Valid    bool              `                   json:"valid"`
	Problems []sdkspec.Problem `                   json:"problems,omitempty"`
	Fixes    map[string]any    `                   json:"fixes,omitempty"`
	// contains filtered or unexported fields
}

ValidateOutput is each problem of the SDK, and the fix of each rule that one breaks.

func Validate

func Validate(
	_ context.Context,
	d Deps,
	_ ValidateInput,
) (ValidateOutput, error)

Validate is each problem of the SDK against sdkspec.Checks.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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