azurecli

package
v0.0.0-...-5a15cda Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AZ_COMMAND     = "az"
	CONFIG_DIR_ENV = "AZURE_CONFIG_DIR"
	PROFILES_JSON  = "azureProfile.json"
	TENANTS_JSON   = "azctxTenants.json"
)
View Source
const TENANT_LEVEL_ACCOUNT_NAME = "N/A(tenant level account)"

Variables

View Source
var FilterTenantLevelAccount bool = true // Filter tenant level accounts with no available subscriptions, will be manipulated by the flag --filter-tenant-level in cmd/root.go#L47

Functions

This section is empty.

Types

type CLI

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

CLI represents the azure cli

func New

func New(fs afero.Fs) (CLI, error)

New creates a new CLI instance

func (CLI) ActiveSubscription

func (cli CLI) ActiveSubscription() (Subscription, error)

ActiveSubscription returns the active subscription

func (CLI) GetSubscriptionByName

func (cli CLI) GetSubscriptionByName(subscriptionName string) (Subscription, bool)

GetSubscriptionByName returns the azure subscription with the given name

func (CLI) InteractiveLogin

func (cli CLI) InteractiveLogin(extraArgs []string) error

InteractiveLogin executes the az login command

func (CLI) IterativeTenantLogin

func (cli CLI) IterativeTenantLogin(extraArgs []string) error

IterativeTenantLogin explicitly executes the az login command for each tenant

func (*CLI) MapTenantIdsToNames

func (cli *CLI) MapTenantIdsToNames()

MapTenanIdsToNames maps the tenant ids to the tenant names

func (*CLI) Reload

func (cli *CLI) Reload() error

Reload refreshes the CLI instance by fetching the latest data from the azure cli config files

func (CLI) SetSubscription

func (CLI) SetSubscription(subscription Subscription) error

SetSubscription sets the default subscription in the azure config file

func (CLI) SubscriptionNames

func (cli CLI) SubscriptionNames() []string

SubscriptionNames returns the names of the given subscriptions

func (CLI) Subscriptions

func (cli CLI) Subscriptions() utils.ComparableNamedSlice[Subscription]

Subscriptions returns all subscriptions

func (CLI) Tenants

func (cli CLI) Tenants() []Tenant

Tenants returns all tenants

func (CLI) TryFindSubscription

func (cli CLI) TryFindSubscription(subscriptionName string) (utils.ComparableNamedSlice[Subscription], error)

TryFindSubscription fuzzy searches for the azure subscription in the given AzureProfilesConfig

func (*CLI) UpdateTenants

func (cli *CLI) UpdateTenants() error

UpdateTenants fetches all available tenants from the azure management api and persists them to the azctxTenants.json file

type Profile

type Profile struct {
	Subscriptions  utils.ComparableNamedSlice[Subscription] `json:"subscriptions"`
	InstallationId string                                   `json:"installationId"`
}

Profile represents the AzureProfiles.json file

type Subscription

type Subscription struct {
	Id    string `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"`
	Tenant       string `json:"tenantId"`
	TenantName   string `` // This is a duplicate of Tenant, used only for display purposes
	Environment  string `json:"environmentName"`
	HomeTenantId string `json:"homeTenantId"`
	ManagedBy    []struct {
		Id string `json:"tenantId"`
	} `json:"managedByTenants"`
}

Subscription represents a subscription in the AzureProfiles.json file

func (Subscription) Compare

func (s Subscription) Compare(other utils.Comparable) int

Implement utils.Compartable interface

func (Subscription) Named

func (s Subscription) Named() string

Implement utils.Named interface

type Tenant

type Tenant struct {
	Id   string `json:"tenantId"`
	Name string `json:"displayName"`
}

Tenant represents the response of the azure management api

Jump to

Keyboard shortcuts

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