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 CatalogCacheDir() (string, error)
- func CatalogV1Enabled(client *api.Client) bool
- func Dir() (string, error)
- func DownloadFile(path string, url string) error
- func IsNotFound(err error) bool
- func LoadLocalComponents() (components map[string]CDKComponent, err error)
- type ApiInfo
- type Artifact
- type Breadcrumbs
- type CDKComponent
- type Catalog
- func (c *Catalog) ComponentCount() int
- func (c *Catalog) Delete(component *CDKComponent) error
- func (c *Catalog) GetComponent(name string) (*CDKComponent, error)
- func (c *Catalog) Install(component *CDKComponent) error
- func (c *Catalog) ListComponentVersions(component *CDKComponent) ([]*semver.Version, error)
- func (c *Catalog) PrintComponents() [][]string
- func (c *Catalog) Stage(component *CDKComponent, version string, ...) (stageClose func(), err error)
- func (c *Catalog) Verify(component *CDKComponent) error
- 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 DevInfo
- type Executer
- type HostInfo
- type Library
- type RunError
- type StageConstructor
- type Stager
- 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" )
const (
DefaultMaxRetry = 3
)
const (
DevelopmentEnv = "LW_CDK_DEV_COMPONENT"
)
Variables ¶
var ( ErrNonExecutable error = errors.New("component not executable") ErrRun string = "unable to run component" )
var ( VersionFile = ".version" SignatureFile = ".signature" InfoFile = ".info" DevelopmentFile = ".dev" )
var (
ErrComponentNotFound = errors.New("component not found on disk")
)
Functions ¶
func CatalogCacheDir ¶ added in v1.34.0
Returns the local directory that Components will be stored in.
func CatalogV1Enabled ¶ added in v1.34.0
func DownloadFile ¶ added in v1.33.2
Retry 3 times (4 requests total) Resty default RetryWaitTime is 100ms Exponential backoff to a maximum of RetryWaitTime of 2s
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
func LoadLocalComponents ¶ added in v1.45.0
func LoadLocalComponents() (components map[string]CDKComponent, err error)
Types ¶
type ApiInfo ¶ added in v1.34.0
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 CDKComponent ¶ added in v1.34.0
type CDKComponent struct { Name string `json:"name"` Description string `json:"description"` Type Type `json:"type"` Status Status `json:"-"` InstallMessage string `json:"-"` UpdateMessage string `json:"-"` Exec Executer `json:"-"` ApiInfo *ApiInfo `json:"apiInfo,omitempty"` HostInfo *HostInfo `json:"-"` // contains filtered or unexported fields }
func NewCDKComponent ¶ added in v1.34.0
func NewCDKComponent(apiInfo *ApiInfo, hostInfo *HostInfo) CDKComponent
func (*CDKComponent) Dir ¶ added in v1.45.0
func (c *CDKComponent) Dir() (string, error)
func (*CDKComponent) EnterDevMode ¶ added in v1.45.0
func (c *CDKComponent) EnterDevMode() error
func (*CDKComponent) InstalledVersion ¶ added in v1.34.0
func (c *CDKComponent) InstalledVersion() *semver.Version
func (*CDKComponent) LatestVersion ¶ added in v1.34.0
func (c *CDKComponent) LatestVersion() *semver.Version
func (*CDKComponent) PrintSummary ¶ added in v1.34.0
func (c *CDKComponent) PrintSummary() []string
type Catalog ¶ added in v1.34.0
type Catalog struct { Components map[string]CDKComponent // contains filtered or unexported fields }
func NewCachedCatalog ¶ added in v1.45.0
func NewCatalog ¶ added in v1.34.0
func NewCatalog( client *api.Client, stageConstructor StageConstructor, ) (*Catalog, error)
func (*Catalog) ComponentCount ¶ added in v1.34.0
func (*Catalog) Delete ¶ added in v1.34.0
func (c *Catalog) Delete(component *CDKComponent) error
Delete a CDKComponent
Remove the Component install directory and all sub-directory. This function will not return an error if the Component is not installed.
func (*Catalog) GetComponent ¶ added in v1.34.0
func (c *Catalog) GetComponent(name string) (*CDKComponent, error)
Return a CDKComponent that is present on the host.
func (*Catalog) Install ¶ added in v1.34.0
func (c *Catalog) Install(component *CDKComponent) error
func (*Catalog) ListComponentVersions ¶ added in v1.34.0
func (c *Catalog) ListComponentVersions(component *CDKComponent) ([]*semver.Version, error)
func (*Catalog) PrintComponents ¶ added in v1.34.0
func (*Catalog) Verify ¶ added in v1.34.0
func (c *Catalog) Verify(component *CDKComponent) error
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
TODO: @jon-stewart: remove - is in wrong place
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 Executer ¶ added in v1.34.0
type Executer interface { Executable() bool Execute(args []string, envs ...string) (stdout string, stderr string, err error) ExecuteInline(args []string, envs ...string) (err error) Path() string }
func NewExecuable ¶ added in v1.34.0
type HostInfo ¶ added in v1.34.0
type HostInfo struct { Name string `json:"name"` ComponentType Type `json:"type"` Desc string `json:"description"` Dir string `json:"-"` }
func LoadHostInfo ¶ added in v1.47.0
func NewHostInfo ¶ added in v1.34.0
func (*HostInfo) Development ¶ added in v1.34.0
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 StageConstructor ¶ added in v1.34.0
type Stager ¶ added in v1.34.0
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