 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
A development kit for the cloud based of modular components.
A Lacework component package to help facilitate the loading and execution of components
Index ¶
- Constants
- Variables
- func Dir() (string, error)
- func IsNotFound(err error) bool
- type Artifact
- type Breadcrumbs
- type Component
- func (c Component) ArtifactForRunningHost(version string) (*Artifact, bool)
- func (c Component) CurrentVersion() (*semver.Version, error)
- func (c Component) EnterDevelopmentMode() error
- func (c Component) IsCommandType() bool
- func (c Component) IsExecutable() bool
- func (c Component) IsInstalled() bool
- func (c Component) ListVersions(installed *semver.Version) string
- func (c Component) MakeUpdateMessage(from, to semver.Version) string
- func (c Component) MarshalJSON() ([]byte, error)
- func (c Component) Path() (string, error)
- func (c Component) RootPath() (string, error)
- func (c Component) RunAndOutput(args []string, envs ...string) error
- func (c Component) RunAndReturn(args []string, stdin io.Reader, envs ...string) (stdout string, stderr string, err error)
- func (c Component) SignatureFromDisk() ([]byte, error)
- func (c Component) Status() Status
- func (c Component) UnderDevelopment() bool
- func (c *Component) UnmarshalJSON(data []byte) error
- func (c Component) UpdateAvailable() (bool, error)
- func (c Component) WriteSignature(signature []byte) error
- func (c Component) WriteVersion(installed string) error
 
- type Library
- type RunError
- type State
- type Status
- type Type
Constants ¶
const ( EmptyType Type = "" // the component is a binary BinaryType = "BINARY" // will this component be accessible via the CLI CommandType = "CLI_COMMAND" // the component is a library, only provides content for the CLI or other components LibraryType = "LIBRARY" // the component is standalone, should be available in $PATH StandaloneType = "STANDALONE" )
Variables ¶
var (
	ErrComponentNotFound = errors.New("component not found on disk")
)
    Functions ¶
func IsNotFound ¶
IsNotFound returns a boolean indicating whether the error is known to have determined the component is not found. It is satisfied by ErrNotApplyComment
Types ¶
type Breadcrumbs ¶ added in v0.40.0
type Breadcrumbs struct {
	InstallationMessage string `json:"installationMessage,omitempty"`
	UpdateMessage       string `json:"updateMessage,omitempty"`
}
    Components should leave a trail/crumb after installation or update, these messages will be shown by the Lacework CLI
type Component ¶
type Component struct {
	Name          string         `json:"name"`
	Description   string         `json:"description"`
	Type          Type           `json:"type"`
	LatestVersion semver.Version `json:"-"`
	Artifacts     []Artifact     `json:"artifacts"`
	Breadcrumbs   Breadcrumbs    `json:"breadcrumbs,omitempty"`
	// @dhazekamp command_name required when CLICommand is true?
	CommandName string `json:"command_name,omitempty"`
}
    Component can be a command-line tool, a new command that extends the Lacework CLI, or a library that contains files used by another Lacework component.
func (Component) ArtifactForRunningHost ¶
ArtifactForRunningHost returns the right component artifact for the running host,
func (Component) CurrentVersion ¶
CurrentVersion returns the current installed version of the component
func (Component) EnterDevelopmentMode ¶ added in v0.43.0
func (Component) IsCommandType ¶
func (Component) IsExecutable ¶
func (Component) IsInstalled ¶
IsInstalled returns true if the component is installed on disk
func (Component) ListVersions ¶ added in v1.4.0
func (Component) MakeUpdateMessage ¶ added in v1.4.0
func (Component) MarshalJSON ¶ added in v0.43.0
func (Component) RunAndOutput ¶
RunAndOutput runs the command and outputs to os.Stdout and os.Stderr, the provided environment variables will be accessible by the component
func (Component) RunAndReturn ¶
func (c Component) RunAndReturn(args []string, stdin io.Reader, envs ...string) ( stdout string, stderr string, err error, )
RunAndReturn runs the command and returns its standard output and standard error, the provided environment variables will be accessible by the component
func (Component) SignatureFromDisk ¶
SignatureFromDisk returns the component signature stored on disk ("RootPath()/.signature")
func (Component) UnderDevelopment ¶ added in v0.43.0
UnderDevelopment returns true if the component is under development that is, if the component root path has the '.dev' specs file or, if the environment variable 'LW_CDK_DEV_COMPONENT' matches the component name
func (*Component) UnmarshalJSON ¶ added in v0.43.0
func (Component) UpdateAvailable ¶
UpdateAvailable returns true if there is a newer version of the component
func (Component) WriteSignature ¶
WriteSignature stores the component signature on disk
func (Component) WriteVersion ¶
WriteVersion stores the component version on disk
type Library ¶
type Library interface {
	// Install downloads the library and deploys the files and index
	Install() error
	// Index returns the index of files that the library contains
	Index() []string
	// GetFile returns the content of one file from the library
	GetFile(string) ([]byte, error)
}
    A library component provides one or more files that other components use
type RunError ¶ added in v0.45.0
RunError is a struct used to pass an error when a component tries to run and it fails, a few functions will return this error so that callers (upstream packages) can unwrap and identify that the error comes from this package
type State ¶
State holds the components specification
You can load the state from the Lacework API server by passing an `api.Client`.
client, err := api.NewClient(account, opts...) cState, err := lwcomponent.LoadState(client)
Or, you can load the state from the local storage.
cState, err := lwcomponent.LocalState()
func LocalState ¶
LocalState loads the state from the local storage ("Dir()/state")
func (State) GetComponent ¶
GetComponent returns the pointer of a component, if the component is not found, this function will return a `nil` pointer and `false`
Usage:
component, found := state.GetComponent(name)
if !found {
	fmt.Println("Component %s not found", name)
}
  
  func (State) WriteState ¶
WriteState stores the components state to disk