lwconfig

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Lacework Config

A Go library to manage the Lacework configuration file ($HOME/.lacework.toml)

Usage

Download the library into your $GOPATH:

$ go get github.com/lacework/go-sdk/v2/lwconfig

Import the library into your tool:

import "github.com/lacework/go-sdk/v2/lwconfig"

Examples

Load the default Lacework configuration file and detect if there is a profile named test:

package main

import (
	"fmt"
	"os"

	"github.com/lacework/go-sdk/v2/lwconfig"
)

func main() {
	profiles, err := lwconfig.LoadProfiles()
	if err != nil {
		fmt.Printf("Error trying to load profiles: %s\n", err)
		os.Exit(1)
	}

	config, ok := profiles["test"]
	if !ok {
		fmt.Println("You have a test profile configured!")
	} else {
		fmt.Println("'test' profile not found")
	}
}

Look at the examples/ folder for more examples.

Documentation

Overview

A package to manage the Lacework configuration file ($HOME/.lacework.toml)

Index

Constants

View Source
const (
	ApiKeyMinLength    = 55
	ApiSecretMinLength = 30
)

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the default path where the Lacework config file is located, which is at $HOME/.lacework.toml

func StoreAt

func StoreAt(configPath string, profiles Profiles) error

StoreAt stores the provided profiles into the selected configuration file

func StoreProfileAt

func StoreProfileAt(configPath, name string, profile Profile) error

StoreProfileAt updates a single profile from the provided configuration file

Types

type Profile

type Profile struct {
	Account    string `toml:"account"`
	Subaccount string `toml:"subaccount,omitempty"`
	ApiKey     string `toml:"api_key" survey:"api_key"`
	ApiSecret  string `toml:"api_secret" survey:"api_secret"`
	Version    int    `toml:"version,omitzero"`
}

Profile represents a single profile within a configuration file

func (*Profile) Verify

func (p *Profile) Verify() error

Verify will return an error is there is one required setting missing

type Profiles

type Profiles map[string]Profile

Profiles is the representation of the $HOME/.lacework.toml

Example:

[default]
account = "example"
api_key = "EXAMPLE_0123456789"
api_secret = "_0123456789"

[dev]
account = "dev"
api_key = "DEV_0123456789"
api_secret = "_0123456789"

[prod]
account = "coolcorp"
subaccount = "prod-business"
api_key = "PROD_0123456789"
api_secret = "_0123456789"
version = 2

func LoadProfiles

func LoadProfiles() (Profiles, error)

LoadProfiles loads all the profiles from the default location ($HOME/.lacework.toml)

func LoadProfilesFrom

func LoadProfilesFrom(configPath string) (Profiles, error)

LoadProfilesFrom loads all the profiles from the provided location

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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