apply

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 22 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

Index

Constants

View Source
const (
	KindGateway        = "gateway"
	KindNode           = "node"
	KindSource         = "source"
	KindField          = "field"
	KindFirmware       = "firmware"
	KindDataRepository = "data-repository"
	KindUser           = "user"
	KindPolicy         = "policy"
	KindServiceAccount = "service-account"

	OperationAdd    = "add"
	OperationMerge  = "merge"
	OperationDelete = "delete"
)

Variables

View Source
var ErrApplyFailed = errors.New("apply failed")

ErrApplyFailed is returned after the result table is printed when any row failed.

Functions

func Apply

func Apply(client ResourceClient, resources []Resource, replace, dryRun bool, out, errOut io.Writer) error

Apply plans and optionally executes resource operations. When dryRun is true, the server is still queried so add-already-exists can be verified.

Types

type Resource

type Resource struct {
	Kind           string
	Operation      string
	Replace        bool
	Index          int
	Source         string
	Gateway        *gwTY.Config
	Node           *nodeTY.Node
	Src            *sourceTY.Source
	Field          *fieldTY.Field
	Firmware       *firmwareTY.Firmware
	DataRepository *dataRepoTY.Config
	User           *userTY.User
	Policy         *policyTY.Policy
	ServiceAccount *svcAccountTY.ServiceAccount
	Payload        map[string]interface{}
}

Resource is one node, source, or field from a YAML/JSON file.

func ParseResources

func ParseResources(data []byte, source string) ([]Resource, error)

ParseResources reads one or more resources from YAML or JSON. Supported shapes: a single object, a list, or YAML documents separated by ---.

func (Resource) ID

func (r Resource) ID() string

func (Resource) Identity

func (r Resource) Identity() string

func (Resource) NaturalKeys

func (r Resource) NaturalKeys() (gatewayID, nodeID, sourceID, fieldID string)

func (Resource) SetID

func (r Resource) SetID(id string)

func (Resource) TableResource

func (r Resource) TableResource() string

func (Resource) Validate

func (r Resource) Validate() error

type ResourceClient

type ResourceClient interface {
	FindGateway(id string) (idFound string, err error)
	FindNode(id, gatewayID, nodeID string) (idFound string, err error)
	FindSource(id, gatewayID, nodeID, sourceID string) (idFound string, err error)
	FindField(id, gatewayID, nodeID, sourceID, fieldID string) (idFound string, err error)
	FindFirmware(id string) (idFound string, err error)
	FindDataRepository(id string) (idFound string, err error)
	FindUser(id, username string) (idFound string, err error)
	FindPolicy(id string) (idFound string, err error)
	FindServiceAccount(id, name, userRef string) (idFound string, err error)
	SaveGateway(resource Resource) error
	SaveNode(resource Resource) error
	SaveSource(resource Resource) error
	SaveField(resource Resource) error
	SaveFirmware(resource Resource) error
	SaveDataRepository(resource Resource) error
	SaveUser(resource Resource) error
	SavePolicy(resource Resource) error
	SaveServiceAccount(resource Resource) (token string, err error)
	DeleteGateway(ids ...string) error
	DeleteNode(ids ...string) error
	DeleteSource(ids ...string) error
	DeleteField(ids ...string) error
	DeleteFirmware(ids ...string) error
	DeleteDataRepository(ids ...string) error
	DeleteUser(ids ...string) error
	DeletePolicy(ids ...string) error
	DeleteServiceAccount(ids ...string) error
	GetExisting(resource Resource) ([]byte, error)
}

ResourceClient looks up and mutates nodes, sources, and fields.

Jump to

Keyboard shortcuts

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