azcli

package
v0.0.0-...-1fd3d55 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAzCliNotLoggedIn         = errors.New("cli is not logged in. Try running \"az login\" to fix")
	ErrAzCliRefreshTokenExpired = errors.New("refresh token has expired. Try running \"az login\" to fix")
	ErrClientAssertionExpired   = errors.New("client assertion expired")
	ErrNoConfigurationValue     = errors.New("no value configured")
)

Functions

This section is empty.

Types

type AdService

type AdService interface {
	GetServicePrincipal(
		ctx context.Context,
		subscriptionId string,
		appIdOrName string,
	) (*graphsdk.ServicePrincipal, error)
	CreateOrUpdateServicePrincipal(
		ctx context.Context,
		subscriptionId string,
		appIdOrName string,
		rolesToAssign []string,
	) (*graphsdk.ServicePrincipal, error)
	ResetPasswordCredentials(
		ctx context.Context,
		subscriptionId string,
		appId string,
	) (*AzureCredentials, error)
	ApplyFederatedCredentials(
		ctx context.Context,
		subscriptionId string,
		clientId string,
		federatedCredentials []*graphsdk.FederatedIdentityCredential,
	) ([]*graphsdk.FederatedIdentityCredential, error)
}

AdService provides actions on top of Azure Active Directory (AD)

func NewAdService

func NewAdService(
	credentialProvider account.SubscriptionCredentialProvider,
	armClientOptions *arm.ClientOptions,
	coreClientOptions *azcore.ClientOptions,
) AdService

Creates a new instance of the AdService

type AzCli

type AzCli interface {
	GetResource(
		ctx context.Context,
		subscriptionId string,
		resourceId string,
		apiVersion string,
	) (AzCliResourceExtended, error)
	GetManagedHSM(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		hsmName string,
	) (*AzCliManagedHSM, error)
	GetCognitiveAccount(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		accountName string,
	) (armcognitiveservices.Account, error)
	GetAppConfig(
		ctx context.Context, subscriptionId string, resourceGroupName string, configName string) (*AzCliAppConfig, error)
	PurgeApim(ctx context.Context, subscriptionId string, apimName string, location string) error
	PurgeAppConfig(ctx context.Context, subscriptionId string, configName string, location string) error
	PurgeManagedHSM(ctx context.Context, subscriptionId string, hsmName string, location string) error
	PurgeCognitiveAccount(ctx context.Context, subscriptionId, location, resourceGroup, accountName string) error
	GetApim(
		ctx context.Context, subscriptionId string, resourceGroupName string, apimName string) (*AzCliApim, error)
	DeployAppServiceZip(
		ctx context.Context,
		subscriptionId string,
		resourceGroup string,
		appName string,
		deployZipFile io.ReadSeeker,
	) (*string, error)
	DeployFunctionAppUsingZipFile(
		ctx context.Context,
		subscriptionID string,
		resourceGroup string,
		funcName string,
		deployZipFile io.ReadSeeker,
	) (*string, error)
	GetFunctionAppProperties(
		ctx context.Context,
		subscriptionID string,
		resourceGroup string,
		funcName string,
	) (*AzCliFunctionAppProperties, error)

	DeleteResourceGroup(ctx context.Context, subscriptionId string, resourceGroupName string) error
	CreateOrUpdateResourceGroup(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		location string,
		tags map[string]*string,
	) error
	ListResourceGroup(
		ctx context.Context,
		subscriptionId string,
		listOptions *ListResourceGroupOptions,
	) ([]AzCliResource, error)
	ListResourceGroupResources(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		listOptions *ListResourceGroupResourcesOptions,
	) ([]AzCliResource, error)
	// CreateOrUpdateServicePrincipal creates a service principal using a given name and returns a JSON object which
	// may be used by tools which understand the `AZURE_CREDENTIALS` format (i.e. the `sdk-auth` format). The service
	// principal is assigned a given role. If an existing principal exists with the given name,
	// it is updated in place and its credentials are reset.
	GetAppServiceProperties(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		applicationName string,
	) (*AzCliAppServiceProperties, error)
	GetStaticWebAppProperties(
		ctx context.Context,
		subscriptionID string,
		resourceGroup string,
		appName string,
	) (*AzCliStaticWebAppProperties, error)
	GetStaticWebAppApiKey(ctx context.Context, subscriptionID string, resourceGroup string, appName string) (*string, error)
	GetStaticWebAppEnvironmentProperties(
		ctx context.Context,
		subscriptionID string,
		resourceGroup string,
		appName string,
		environmentName string,
	) (*AzCliStaticWebAppEnvironmentProperties, error)
}

func NewAzCli

func NewAzCli(
	credentialProvider account.SubscriptionCredentialProvider,
	httpClient httputil.HttpClient,
	args NewAzCliArgs,
	armClientOptions *arm.ClientOptions,
) AzCli

type AzCliAccessToken

type AzCliAccessToken struct {
	AccessToken string
	ExpiresOn   *time.Time
}

AzCliAccessToken represents the value returned by `az account get-access-token`

type AzCliApim

type AzCliApim struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	Location string `json:"location"`
}

type AzCliAppConfig

type AzCliAppConfig struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	Location   string `json:"location"`
	Properties struct {
		EnablePurgeProtection bool `json:"enablePurgeProtection"`
	} `json:"properties"`
}

type AzCliAppServiceProperties

type AzCliAppServiceProperties struct {
	HostNames []string
}

type AzCliConfigValue

type AzCliConfigValue struct {
	Name   string `json:"name"`
	Source string `json:"source"`
	Value  string `json:"value"`
}

AzCliConfigValue represents the value returned by `az config get`.

type AzCliExtensionInfo

type AzCliExtensionInfo struct {
	Name string
}

AzCliConfigValue represents the value in the array returned by `az extension list`.

type AzCliFunctionAppProperties

type AzCliFunctionAppProperties struct {
	HostNames []string
}

type AzCliManagedHSM

type AzCliManagedHSM struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	Location   string `json:"location"`
	Properties struct {
		EnableSoftDelete      bool `json:"enableSoftDelete"`
		EnablePurgeProtection bool `json:"enablePurgeProtection"`
	} `json:"properties"`
}

type AzCliResource

type AzCliResource struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	Location string `json:"location"`
}

type AzCliResourceExtended

type AzCliResourceExtended struct {
	AzCliResource
	Kind string `json:"kind"`
}

type AzCliStaticWebAppEnvironmentProperties

type AzCliStaticWebAppEnvironmentProperties struct {
	Hostname string
	Status   string
}

type AzCliStaticWebAppProperties

type AzCliStaticWebAppProperties struct {
	DefaultHostname string
}

type AzureCredentials

type AzureCredentials struct {
	ClientId       string `json:"clientId"`
	ClientSecret   string `json:"clientSecret"`
	SubscriptionId string `json:"subscriptionId"`
	TenantId       string `json:"tenantId"`
}

Required model structure for Azure Credentials tools

type ContainerRegistryService

type ContainerRegistryService interface {
	// Logs into the specified container registry
	Login(ctx context.Context, subscriptionId string, loginServer string) error
	// Gets the credentials that could be used to login to the specified container registry.
	Credentials(ctx context.Context, subscriptionId string, loginServer string) (*DockerCredentials, error)
	// Gets a list of container registries for the specified subscription
	GetContainerRegistries(ctx context.Context, subscriptionId string) ([]*armcontainerregistry.Registry, error)
}

ContainerRegistryService provides access to query and login to Azure Container Registries (ACR)

func NewContainerRegistryService

func NewContainerRegistryService(
	credentialProvider account.SubscriptionCredentialProvider,
	docker docker.Docker,
	armClientOptions *arm.ClientOptions,
	coreClientOptions *azcore.ClientOptions,
) ContainerRegistryService

Creates a new instance of the ContainerRegistryService

type DockerCredentials

type DockerCredentials struct {
	// Username is the name of the user. Note that this may be set to a value like
	// '00000000-0000-0000-0000-000000000000' when using access tokens.
	Username string
	// Password is the password for the user, or the access token when using access tokens.
	Password    string
	LoginServer string
}

Credentials for authenticating with a docker registry, can be both username/password or access token based.

type Filter

type Filter struct {
	Key   string
	Value string
}

type ListResourceGroupOptions

type ListResourceGroupOptions struct {
	// An optional tag filter
	TagFilter *Filter
	// An optional filter expression to filter the resource group results
	// https://learn.microsoft.com/en-us/rest/api/resources/resource-groups/list
	Filter *string
}

Optional parameters for resource group listing.

type ListResourceGroupResourcesOptions

type ListResourceGroupResourcesOptions struct {
	// An optional filter expression to filter the resource list result
	// https://learn.microsoft.com/en-us/rest/api/resources/resources/list-by-resource-group#uri-parameters
	Filter *string
}

Optional parameters for resource group resources listing.

type ManagedClustersService

type ManagedClustersService interface {
	// Gets the managed cluster resource by name
	Get(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		resourceName string,
	) (*armcontainerservice.ManagedCluster, error)
	// Gets the user credentials for the specified resource
	GetUserCredentials(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		resourceName string,
	) (*armcontainerservice.CredentialResults, error)
}

ManagedClustersService provides actions on top of Azure Kubernetes Service (AKS) Managed Clusters

func NewManagedClustersService

func NewManagedClustersService(
	credentialProvider account.SubscriptionCredentialProvider,
	armClientOptions *arm.ClientOptions,
) ManagedClustersService

Creates a new instance of the ManagedClustersService

type NewAzCliArgs

type NewAzCliArgs struct {
	EnableDebug     bool
	EnableTelemetry bool
}

type SpringAppProperties

type SpringAppProperties struct {
	Url []string
}

type SpringService

type SpringService interface {
	// Get Spring app properties
	GetSpringAppProperties(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		instanceName string,
		appName string,
	) (*SpringAppProperties, error)
	// Deploy jar artifact to ASA app deployment
	DeploySpringAppArtifact(
		ctx context.Context,
		subscriptionId string,
		resourceGroup string,
		instanceName string,
		appName string,
		relativePath string,
		deploymentName string,
	) (*string, error)
	// Upload jar artifact to ASA app Storage File
	UploadSpringArtifact(
		ctx context.Context,
		subscriptionId string,
		resourceGroup string,
		instanceName string,
		appName string,
		artifactPath string,
	) (*string, error)
	// Get Spring app deployment
	GetSpringAppDeployment(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		instanceName string,
		appName string,
		deploymentName string,
	) (*string, error)
}

SpringService provides artifacts upload/deploy and query to Azure Spring Apps (ASA)

func NewSpringService

func NewSpringService(
	credentialProvider account.SubscriptionCredentialProvider,
	armClientOptions *arm.ClientOptions,
) SpringService

Creates a new instance of the NewSpringService

type UserProfileService

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

UserProfileService allows querying for user profile information.

func NewUserProfileService

func NewUserProfileService(
	credentialProvider auth.MultiTenantCredentialProvider,
	clientOptionsBuilderFactory *azsdk.ClientOptionsBuilderFactory,
	cloud *cloud.Cloud,
) *UserProfileService

func (*UserProfileService) GetAccessToken

func (u *UserProfileService) GetAccessToken(ctx context.Context, tenantId string) (*AzCliAccessToken, error)

func (*UserProfileService) GetSignedInUserId

func (user *UserProfileService) GetSignedInUserId(ctx context.Context, tenantId string) (string, error)

Jump to

Keyboard shortcuts

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