sdkspec

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: 7 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 sdkspec is the Go SDK as data: its spec, which osapi sdk spec get prints and the SDK skill is made from, and its checks, which osapi sdk validate runs. It reads the SDK's own description of itself, types.All and client.Services, as osapi agent collector reads gohai.Collectors.

Index

Constants

View Source
const (
	// KindPackage is a package of pkg/sdk.
	KindPackage = "package"
	// KindCall is how a call is made and how it fails.
	KindCall = "call"
	// KindService is a service of the client.
	KindService = "service"
)

The kinds of the SDK's spec.

View Source
const (
	RuleDoc     = "doc"
	RuleValues  = "values"
	RuleExample = "example"
	RuleClient  = "client"
)

The rules of Checks.

Variables

View Source
var Checks = guide.Checks{
	{
		Rule:     RuleDoc,
		Requires: "Each type, each service and each method of the SDK says what it is.",
		Fix:      "Give the type a doc comment, or the schema or the operation of the spec a description, and run just generate.",
	},
	{
		Rule:     RuleValues,
		Requires: "Each type for values has at least one value.",
		Fix:      "Give the type constants and list them in its Values.",
	},
	{
		Rule:     RuleExample,
		Requires: "Each method of the client has an example, which examples/sdk/client runs, but a method that a program calls, which the spec marks x-osapi-program.",
		Fix:      "Add an Example to the method's definition, and run just generate.",
	},
	{
		Rule:     RuleClient,
		Requires: "Each service that client.Services lists is a field of client.Client, and each of its methods is a method of that field.",
		Fix:      "Run just generate: client.Services and the client come from one run.",
	},
}

Checks are the rules that osapi sdk validate applies.

Functions

func Spec

func Spec(
	ts []types.TypeSpec,
	ss []client.ServiceSpec,
) guide.Spec

Spec is the SDK: its packages, how a call is made, its types for values and the services of its client.

Types

type Problem

type Problem struct {
	// Name is the type, the service or the method, such as Hostname.Update.
	Name string `json:"name"`
	// Rule is the rule, from Checks.
	Rule string `json:"rule"`
	// Message says what is wrong.
	Message string `json:"message"`
	// Fix is how to fix it, from the check of Rule.
	Fix string `json:"fix" table:"-"`
}

Problem is one thing of the SDK that breaks a rule of Checks.

func Validate

func Validate(
	ts []types.TypeSpec,
	ss []client.ServiceSpec,
) []Problem

Validate is each problem of ts and ss against Checks.

Jump to

Keyboard shortcuts

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