utils

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_SSO_NAME = "Default" // DefaultSSO per cmd/aws-sso/main.go
	CONFIG_PREFIX    = "# BEGIN_AWS_SSO_CLI"
	CONFIG_SUFFIX    = "# END_AWS_SSO_CLI"
	FILE_TEMPLATE    = "%s\n%s\n%s\n"
)
View Source
const MAX_AWS_ACCOUNTID = 999999999999

Variables

This section is empty.

Functions

func AccountIdToInt64

func AccountIdToInt64(a string) (int64, error)

AccountIdToInt64 returns an int64 version of AWS AccountID in base10

func AccountIdToString

func AccountIdToString(a int64) (string, error)

AccountIdToString returns a string version of AWS AccountID

func DiffBytes

func DiffBytes(aBytes, bBytes []byte, aName, bName string) string

DiffBytes generates a diff between two byte arrays

func EnsureDirExists

func EnsureDirExists(filename string) error

ensures the given directory exists for the filename used by JsonStore and InsecureStore

func GenerateSource added in v1.15.0

func GenerateSource(fileTemplate string, vars interface{}) ([]byte, error)

GenerateSource returns the byte array of a template

func GetHomePath

func GetHomePath(path string) string

GetHomePath returns the absolute path of the provided path with the first ~ replaced with the location of the users home directory and the path rewritten for the host operating system

func GetLogger

func GetLogger() *logrus.Logger

func IsRemoteHost added in v1.17.0

func IsRemoteHost() bool

IsRemoteHost returns if we are running on a remote host or not

func MakeRoleARN

func MakeRoleARN(account int64, name string) string

MakeRoleARN create an IAM Role ARN using an int64 for the account

func MakeRoleARNs

func MakeRoleARNs(account, name string) string

MakeRoleARNs creates an IAM Role ARN using a string for the account and role

func MakeUserARN

func MakeUserARN(account int64, name string) string

MakeUserARN create an IAM User ARN using an int64 for the account

func ParseRoleARN

func ParseRoleARN(arn string) (int64, string, error)

ParseRoleARN parses an ARN representing a role in long or short format

func ParseTimeString

func ParseTimeString(t string) (int64, error)

ParseTimeString converts a standard time string to Unix Epoch

func ParseUserARN

func ParseUserARN(arn string) (int64, string, error)

ParseUserARN parses an ARN representing a user in long or short format

func SetLogger

func SetLogger(l *logrus.Logger)

func StrListContains

func StrListContains(str string, list []string) bool

StrListContains returns if `str` is in the `list`

func TimeRemain

func TimeRemain(expires int64, space bool) (string, error)

Returns the MMm or HHhMMm or 'Expired' if no time remains

Types

type BellSkipper

type BellSkipper struct{}

* BellSkipper implements an io.WriteCloser that skips the terminal bell * character (ASCII code 7), and writes the rest to os.Stderr. It is used to * replace readline.Stdout, that is the package used by promptui to display the * prompts. * * This is a workaround for the bell issue documented in * https://github.com/manifoldco/promptui/issues/49#issuecomment-573814976

func (*BellSkipper) Close

func (bs *BellSkipper) Close() error

Close implements an io.WriterCloser over os.Stderr.

func (*BellSkipper) Write

func (bs *BellSkipper) Write(b []byte) (int, error)

Write implements an io.WriterCloser over os.Stderr, but it skips the terminal bell character.

type FileEdit

type FileEdit struct {
	Prefix    string
	Suffix    string
	Template  *template.Template
	InputVars interface{}
}

func NewFileEdit

func NewFileEdit(fileTemplate, ssoName string, vars interface{}) (*FileEdit, error)

NewFileEdit creates a new FileEdit object

func (*FileEdit) GenerateNewFile

func (f *FileEdit) GenerateNewFile(configFile string) ([]byte, error)

GenerateNewFile generates the contents of a new config file

func (*FileEdit) UpdateConfig

func (f *FileEdit) UpdateConfig(printDiff, force bool, configFile string) (bool, string, error)

UpdateConfig does all the heavy lifting of updating (or creating) the file and optionally providing a diff for user to approve/view. Returns true if changes were made (and the diff), false if no changes were made, or an error if something happened

Jump to

Keyboard shortcuts

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