profile

package
v0.0.0-...-b412c78 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InfoColor    = "\033[0;32m%s\033[0m"
	NoticeColor  = "\033[0;36m%s\033[0m"
	WarningColor = "\033[1;33m%s\033[0m"
	ErrorColor   = "\033[1;31m%s\033[0m"
	DebugColor   = "\033[0;36m%s\033[0m"
)

Variables

View Source
var (
	// ErrFileDoesNotExist is returned when the file does not exist.
	ErrFileDoesNotExist = func(err error) error {
		return fmt.Errorf("file does not exist: %w", err)
	}

	// ErrGettingHomeDirectory is returned when there is an error getting the home directory.
	ErrGettingHomeDirectory = func(err error) error {
		return fmt.Errorf("error getting home directory: %w", err)
	}

	// ErrMarshallingJSON is returned when there is an error marshalling JSON.
	ErrMarshallingJSON = func(err error) error {
		return fmt.Errorf("error marshalling JSON: %w", err)
	}

	// ErrUnmarshallingJSON is returned when there is an error unmarshalling JSON.
	ErrUnmarshallingJSON = func(err error) error {
		return fmt.Errorf("error unmarshalling JSON: %w", err)
	}

	// ErrWritingFile is returned when there is an error writing the file.
	ErrWritingFile = func(err error) error {
		return fmt.Errorf("error writing file: %w", err)
	}

	// ErrReadingFile is returned when there is an error reading the file.
	ErrReadingFile = func(err error) error {
		return fmt.Errorf("error reading file: %w", err)
	}

	// ErrPathIsEmpty is returned when the sampleConfigFilePath is empty.
	ErrPathIsEmpty = errors.New("sampleConfigFilePath is empty")

	// ErrReadingConfiguration is returned when there is an error reading the configuration.
	ErrReadingConfiguration = func(err error) error {
		return fmt.Errorf("error reading configuration: %w", err)
	}

	// ErrWritingConfiguration is returned when there is an error writing the configuration.
	ErrWritingConfiguration = func(err error) error {
		return fmt.Errorf("error writing configuration: %w", err)
	}

	// ErrSelectingSubscription is returned when there is an error selecting the subscription.
	ErrSelectingSubscription = func(err error) error {
		return fmt.Errorf("error selecting subscription: %w", err)
	}

	// ErrSettingPreviousContext is returned when there is an error setting the previous context.
	ErrSettingPreviousContext = func(err error) error {
		return fmt.Errorf("error setting previous context: %w", err)
	}

	// ErrNoPreviousContext is returned when there is no previous context.
	ErrNoPreviousContext = errors.New("no previous context, check ~/.aztx.yml is present and has content")

	// ErrSubscriptionNotFound is returned when there is no subscription found.
	ErrSubscriptionNotFound = errors.New("no subscription found")

	// ErrFetchingUserProfile is returned when there is an error fetching the user profile.
	ErrFetchingUserProfile = func(err error) error {
		return fmt.Errorf("error fetching user profile: %w", err)
	}
)

Functions

func PrintInfo

func PrintInfo(message string)

PrintInfo prints an info message to the terminal.

func PrintNotice

func PrintNotice(message string)

PrintNotice prints a notice message to the terminal.

Types

type Configuration

type Configuration struct {
	InstallationID uuid.UUID      `json:"installationId"`
	Subscriptions  []Subscription `json:"subscriptions"`
}

type ConfigurationAdapter

type ConfigurationAdapter struct {
	// contains filtered or unexported fields
}

func NewConfigurationAdapter

func NewConfigurationAdapter(userProfile userProfileReadWriter) *ConfigurationAdapter

func (*ConfigurationAdapter) SelectWithFinder

func (c *ConfigurationAdapter) SelectWithFinder() (*Subscription, error)

func (*ConfigurationAdapter) SetContext

func (c *ConfigurationAdapter) SetContext(lastContext *azurestate.LastContext, selectedContext *Subscription) error

func (*ConfigurationAdapter) SetPreviousContext

func (c *ConfigurationAdapter) SetPreviousContext(lastContext *azurestate.LastContext) error

type Subscription

type Subscription struct {
	ID    uuid.UUID `json:"id"`
	Name  string    `json:"name"`
	State string    `json:"state"`
	User  struct {
		Name string `json:"name"`
		Type string `json:"type"`
	} `json:"user"`
	IsDefault bool `json:"isDefault"`
}

type UserProfileFileAdapter

type UserProfileFileAdapter struct {
	// contains filtered or unexported fields
}

func (*UserProfileFileAdapter) Fetch

func (u *UserProfileFileAdapter) Fetch() error

func (*UserProfileFileAdapter) Find

func (u *UserProfileFileAdapter) Find(cfg *Configuration) (int, error)

func (*UserProfileFileAdapter) Read

func (*UserProfileFileAdapter) Write

Jump to

Keyboard shortcuts

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