object

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 object is the object behavior: the objects of the Object Store of the fleet, which other behaviors read, such as the content of a file.

Index

Constants

This section is empty.

Variables

View Source
var Behavior = behavior.Register(behavior.Define(
	"object",
	"The objects of the object store of the fleet, such as a file uploaded with osapi client file upload",
	behavior.Node,
	behavior.Internal,
	behavior.Platform(behavior.PlatformDebian, newStore),
	behavior.Platform(behavior.PlatformLinux, newStore),
	behavior.Platform(behavior.PlatformDarwin, newStore),
	behavior.Read("get", Get).Key("name").
		Describe("Get an object of the object store").
		Explain("Reads the object from the object store of the fleet, with the content type that "+
			"its upload gave it, raw or template, and the SHA-256 of its content. A template is "+
			"not rendered: the behavior that deploys it renders it. An agent with no object store "+
			"reports skipped.").
		Example("A unit file", GetInput{Name: "example.service"},
			Object{
				Name: "example.service", Content: unit, ContentType: types.ContentRaw,
				SHA256: "4d38310b40344ae465b2f1f88758809f31ef1aa8287c756a1d65c76ca27dc243",
			},
			behavior.Stored("example.service", unit, types.ContentRaw),
		).
		Example("A template", GetInput{Name: "motd.tmpl"},
			Object{
				Name:        "motd.tmpl",
				Content:     "Welcome to {{ .Hostname }}\n",
				ContentType: types.ContentTemplate,
				SHA256:      "08c60853fd0933d9903a112a64bb4c742c03961a4e56af1940173403a09746e2",
			},
			behavior.Stored("motd.tmpl", "Welcome to {{ .Hostname }}\n", types.ContentTemplate),
		).
		Fails("An object the store does not have", GetInput{Name: "nosuch"}, "not found").
		Fails("No name", GetInput{}, "Name").
		Fails("A name over 255 characters", GetInput{Name: strings.Repeat("a", 256)}, "Name"),
))

Behavior reads the objects of the object store of the fleet: the files that a person uploads once with osapi client file upload, and that behaviors deploy by name. It is a building block: a behavior that deploys a file requires it, gets the content with it, and writes the content with managedfile.

Functions

This section is empty.

Types

type GetInput

type GetInput struct {
	Name string `` /* 150-byte string literal not displayed */
}

GetInput names the object to read.

type Object

type Object struct {
	Name        string            `json:"name"         doc:"The name of the object"`
	Content     string            `json:"content"      doc:"The content of the object"`
	ContentType types.ContentType `json:"content_type" doc:"raw, or template for an object whose content is a Go template"`
	SHA256      string            `json:"sha256"       doc:"The SHA-256 of the content, in hex"`
}

Object is an object of the object store.

func Get

func Get(
	ctx context.Context,
	p Provider,
	in GetInput,
) (Object, error)

Get is an object of the object store.

type Provider

type Provider interface {
	// Object is the object name.
	Object(ctx context.Context, name string) (Object, error)
}

Provider reads the objects of the object store of the fleet.

Directories

Path Synopsis
Package mocks holds the generated double of the object provider, for the methods' tests.
Package mocks holds the generated double of the object provider, for the methods' tests.

Jump to

Keyboard shortcuts

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