generate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ui cli.Ui) *cmd

func NewWithDependencies

func NewWithDependencies(ui cli.Ui, ssoClientFactory func(aws.Config) SSOClient, tokenGenerator TokenGenerator, configLoader func() aws.Config) *cmd

NewWithDependencies creates a new command with injected dependencies for testing

Types

type ConfigGenerator

type ConfigGenerator struct {
	SSOStartURL   string
	SSORegion     string
	DefaultRegion string
}

ConfigGenerator holds the config generator implementation

func NewConfigGenerator

func NewConfigGenerator(ssoStartURL, ssoRegion, defaultRegion string) *ConfigGenerator

Returns a new config generator with the given parameters

func (*ConfigGenerator) GetAccountRolesWithClient

func (g *ConfigGenerator) GetAccountRolesWithClient(ssoClient SSOClient, token *string, accountID string) ([]types.RoleInfo, error)

GetAccountRolesWithClient gets AWS account roles using the provided SSO client

func (*ConfigGenerator) ListAccountsWithClient

func (g *ConfigGenerator) ListAccountsWithClient(ssoClient SSOClient, token *string) ([]types.AccountInfo, error)

ListAccountsWithClient lists AWS accounts with the provided SSO client

func (*ConfigGenerator) WriteSectionToConfig

func (g *ConfigGenerator) WriteSectionToConfig(configParser *configparser.ConfigParser, sectionName string, values map[string]string) error

WriteSectionToConfig writes a section to the config parser

type ConfigGeneratorIface

type ConfigGeneratorIface interface {
	GenerateConfigFile(ssoClient SSOClient, token *string, configFile string, showDiff bool, appCfg *appconfig.Config) error
	ListAccountsWithClient(ssoClient SSOClient, token *string) ([]types.AccountInfo, error)
	GetAccountRolesWithClient(ssoClient SSOClient, token *string, accountID string) ([]types.RoleInfo, error)
	WriteSectionToConfig(configParser *configparser.ConfigParser, sectionName string, values map[string]string) error
}

ConfigGeneratorIface defines the interface for config generator operations

type DefaultTokenGenerator

type DefaultTokenGenerator struct{}

DefaultTokenGenerator implements TokenGenerator using the real AWS functions

func (*DefaultTokenGenerator) GenerateTokenWithConfig

func (g *DefaultTokenGenerator) GenerateTokenWithConfig(cfg aws.Config, appCfg *appconfig.Config) *string

type SSOClient

type SSOClient interface {
	GetRoleCredentials(ctx context.Context, params *sso.GetRoleCredentialsInput, optFns ...func(*sso.Options)) (*sso.GetRoleCredentialsOutput, error)
	ListAccounts(ctx context.Context, params *sso.ListAccountsInput, optFns ...func(*sso.Options)) (*sso.ListAccountsOutput, error)
	ListAccountRoles(ctx context.Context, params *sso.ListAccountRolesInput, optFns ...func(*sso.Options)) (*sso.ListAccountRolesOutput, error)
}

Interface for AWS SSO operations to allow mocking in tests

type TokenGenerator

type TokenGenerator interface {
	GenerateTokenWithConfig(cfg aws.Config, appCfg *appconfig.Config) *string
}

TokenGenerator interface for mocking

Jump to

Keyboard shortcuts

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