providers

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const CONTRIBUTOR_ROLE_ID = "b24988ac-6180-42a0-ab88-20f7382dd24c"

Variables

This section is empty.

Functions

func InitiateAzureOIDCFlow

func InitiateAzureOIDCFlow(ctx context.Context, sc *SetUpCmd, s spinner.Spinner, gh GhClient, az AzClientInterface) error

func PromptTenantId added in v0.17.0

func PromptTenantId(azc AzClientInterface, ctx context.Context) (string, error)

Prompt the user to select a tenant ID if there are multiple tenants, or return the only tenant ID if there is only one

Types

type AzClient added in v0.0.34

type AzClient struct {
	Credential          *azidentity.DefaultAzureCredential
	TenantClient        *armsubscription.TenantsClient
	RoleAssignClient    *armauthorization.RoleAssignmentsClient
	ResourceGroupClient *armresources.ResourceGroupsClient
	CommandRunner       CommandRunner
}

AzClient is a struct that contains the Azure client and its dependencies It is used to interact with Azure resources Create a new AzClient with NewAzClient

func NewAzClient added in v0.17.0

func NewAzClient(cred *azidentity.DefaultAzureCredential) (*AzClient, error)

func (*AzClient) AssignSpRole added in v0.17.0

func (az *AzClient) AssignSpRole(ctx context.Context, subscriptionId, resourceGroup, servicePrincipalObjectID, roleId string) error

func (*AzClient) AzAcrExists added in v0.17.0

func (az *AzClient) AzAcrExists(acrName string) bool

func (*AzClient) AzAksExists added in v0.17.0

func (az *AzClient) AzAksExists(aksName string, resourceGroup string) bool

func (*AzClient) AzAppExists added in v0.17.0

func (az *AzClient) AzAppExists(appName string) bool

func (*AzClient) CreateAzApp added in v0.17.0

func (az *AzClient) CreateAzApp(appName string) (string, error)

CreateAzApp creates an Azure app with the given name Returns the appId of the created app

func (*AzClient) CreateServicePrincipal added in v0.17.0

func (az *AzClient) CreateServicePrincipal(appId string) (string, error)

CreateServicePrincipal creates a service principal with the given appId Returns the objectId of the created service principal

func (*AzClient) EnsureAzCli added in v0.17.0

func (az *AzClient) EnsureAzCli() error

EnsureAzCli ensures that the Azure CLI is installed and the user is logged in

func (*AzClient) EnsureAzCliLoggedIn added in v0.17.0

func (az *AzClient) EnsureAzCliLoggedIn() error

func (*AzClient) GetAzCliVersion added in v0.17.0

func (az *AzClient) GetAzCliVersion() (string, error)

func (*AzClient) GetAzSubscriptionLabels added in v0.17.0

func (az *AzClient) GetAzSubscriptionLabels() ([]SubLabel, error)

func (*AzClient) GetAzUpgrade added in v0.17.0

func (az *AzClient) GetAzUpgrade() string

func (*AzClient) GetCurrentAzSubscriptionLabel added in v0.17.0

func (az *AzClient) GetCurrentAzSubscriptionLabel() (SubLabel, error)

func (*AzClient) GetServicePrincipal added in v0.17.0

func (az *AzClient) GetServicePrincipal(appId string) (string, error)

func (*AzClient) IsLoggedInToAz added in v0.17.0

func (az *AzClient) IsLoggedInToAz() bool

func (*AzClient) IsSubscriptionIdValid added in v0.17.0

func (az *AzClient) IsSubscriptionIdValid(subscriptionId string) error

func (*AzClient) IsValidResourceGroup added in v0.17.0

func (az *AzClient) IsValidResourceGroup(
	subscriptionId string,
	resourceGroup string,
) error

func (*AzClient) ListResourceGroups added in v0.17.0

func (az *AzClient) ListResourceGroups(ctx context.Context, subscriptionID string) ([]armresources.ResourceGroup, error)

func (*AzClient) ListTenants added in v0.17.0

func (*AzClient) LogInToAz added in v0.17.0

func (az *AzClient) LogInToAz() error

func (*AzClient) UpgradeAzCli added in v0.17.0

func (az *AzClient) UpgradeAzCli()

func (*AzClient) ValidateAzCliInstalled added in v0.17.0

func (az *AzClient) ValidateAzCliInstalled() error

type AzClientInterface added in v0.17.0

type AzClientInterface interface {
	AssignSpRole(ctx context.Context, subscriptionId, resourceGroup, servicePrincipalObjectID, roleId string) error
	AzAcrExists(acrName string) bool
	AzAksExists(aksName string, resourceGroup string) bool
	AzAppExists(appName string) bool
	CreateAzApp(appName string) (string, error)
	CreateServicePrincipal(appId string) (string, error)
	EnsureAzCli() error
	EnsureAzCliLoggedIn() error
	GetAzCliVersion() (string, error)
	GetAzSubscriptionLabels() ([]SubLabel, error)
	GetAzUpgrade() string
	GetCurrentAzSubscriptionLabel() (SubLabel, error)
	GetServicePrincipal(appId string) (string, error)
	IsLoggedInToAz() bool
	IsSubscriptionIdValid(subscriptionId string) error
	IsValidResourceGroup(subscriptionId string, resourceGroup string) error
	ListResourceGroups(ctx context.Context, subscriptionID string) ([]armresources.ResourceGroup, error)
	ListTenants(ctx context.Context) ([]armsubscription.TenantIDDescription, error)
	LogInToAz() error
	UpgradeAzCli()
	ValidateAzCliInstalled() error
}

type CommandRunner added in v0.17.0

type CommandRunner interface {
	RunCommand(...string) (string, error)
}

CommandRunner is an interface for executing commands and getting the output/error

type DefaultCommandRunner added in v0.17.0

type DefaultCommandRunner struct{}

func (*DefaultCommandRunner) RunCommand added in v0.17.0

func (d *DefaultCommandRunner) RunCommand(args ...string) (string, error)

type FakeCommandRunner added in v0.17.0

type FakeCommandRunner struct {
	Output string
	ErrStr string
}

func (*FakeCommandRunner) RunCommand added in v0.17.0

func (f *FakeCommandRunner) RunCommand(args ...string) (string, error)

type GhCliClient added in v0.17.0

type GhCliClient struct {
	CommandRunner CommandRunner
}

func NewGhClient added in v0.17.0

func NewGhClient() *GhCliClient

func (GhCliClient) EnsureGhCli added in v0.17.0

func (gh GhCliClient) EnsureGhCli()

EnsureGhCliInstalled ensures that the Github CLI is installed and the user is logged in

func (GhCliClient) EnsureGhCliInstalled added in v0.17.0

func (gh GhCliClient) EnsureGhCliInstalled()

func (GhCliClient) EnsureGhCliLoggedIn added in v0.17.0

func (gh GhCliClient) EnsureGhCliLoggedIn()

func (GhCliClient) GetRepoNameWithOwner added in v0.17.0

func (gh GhCliClient) GetRepoNameWithOwner() (string, error)

func (GhCliClient) IsLoggedInToGh added in v0.17.0

func (gh GhCliClient) IsLoggedInToGh() bool

func (GhCliClient) IsValidGhRepo added in v0.17.0

func (gh GhCliClient) IsValidGhRepo(repo string) error

func (GhCliClient) LogInToGh added in v0.17.0

func (gh GhCliClient) LogInToGh() error

type GhClient added in v0.17.0

type GhClient interface {
	EnsureGhCli()
	EnsureGhCliLoggedIn()
	IsLoggedInToGh() bool
	LogInToGh() error
	IsValidGhRepo(repo string) error
	GetRepoNameWithOwner() (string, error)
}

type SetUpCmd

type SetUpCmd struct {
	AppName           string
	SubscriptionID    string
	ResourceGroupName string
	Provider          string
	Repo              string

	TenantId string

	AzClient AzClientInterface
	// contains filtered or unexported fields
}

func (*SetUpCmd) ValidateSetUpConfig

func (sc *SetUpCmd) ValidateSetUpConfig(gh GhClient, az AzClientInterface) error

type SubLabel added in v0.0.36

type SubLabel struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Directories

Path Synopsis
Package mock_providers is a generated GoMock package.
Package mock_providers is a generated GoMock package.

Jump to

Keyboard shortcuts

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