azure

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package azure is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProfilePath

func ProfilePath() (string, error)

ProfilePath() checks for the presence of a config directory and returns the path to the azureProfileJSON file in that directory, or if the config directory is not present, it returns the path to the azureProfileJSON file in the user's home directory. If an error occurs, an error is returned.

Types

type AzureCredentialKind added in v0.35.0

type AzureCredentialKind string

AzureCredentialKind - Azure credential kinds supported.

const (
	// ProviderDisplayName is the text used in display for Azure.
	ProviderDisplayName                                     = "Azure"
	AzureCredentialKindWorkloadIdentity AzureCredentialKind = "WorkloadIdentity"
	AzureCredentialKindServicePrincipal AzureCredentialKind = "ServicePrincipal"
)

type Client

type Client interface {
	// Locations lists the locations available for a subscription.
	Locations(ctx context.Context, subscriptionID string) ([]armsubscriptions.Location, error)
	// Subscriptions lists the subscriptions available to the user.
	Subscriptions(ctx context.Context) (*SubscriptionResult, error)
	// ResourceGroups lists the existing resource groups in a subscription.
	ResourceGroups(ctx context.Context, subscriptionID string) ([]armresources.ResourceGroup, error)
	// CheckResourceGroupExistence checks if a resource group exists.
	CheckResourceGroupExistence(ctx context.Context, subscriptionID string, resourceGroupName string) (bool, error)
	// CreateOrUpdateResourceGroup creates or updates a resource group.
	CreateOrUpdateResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, location string) error
}

Client is an interface that abstracts `rad init`'s interactions with Azure. This is for testing purposes.

func NewClient

func NewClient() Client

NewClient returns a new Client.

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) CheckResourceGroupExistence

func (m *MockClient) CheckResourceGroupExistence(arg0 context.Context, arg1, arg2 string) (bool, error)

CheckResourceGroupExistence mocks base method.

func (*MockClient) CreateOrUpdateResourceGroup

func (m *MockClient) CreateOrUpdateResourceGroup(arg0 context.Context, arg1, arg2, arg3 string) error

CreateOrUpdateResourceGroup mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) Locations

func (m *MockClient) Locations(arg0 context.Context, arg1 string) ([]armsubscriptions.Location, error)

Locations mocks base method.

func (*MockClient) ResourceGroups

func (m *MockClient) ResourceGroups(arg0 context.Context, arg1 string) ([]armresources.ResourceGroup, error)

ResourceGroups mocks base method.

func (*MockClient) Subscriptions

func (m *MockClient) Subscriptions(arg0 context.Context) (*SubscriptionResult, error)

Subscriptions mocks base method.

type MockClientCheckResourceGroupExistenceCall added in v0.35.0

type MockClientCheckResourceGroupExistenceCall struct {
	*gomock.Call
}

MockClientCheckResourceGroupExistenceCall wrap *gomock.Call

func (*MockClientCheckResourceGroupExistenceCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientCheckResourceGroupExistenceCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientCheckResourceGroupExistenceCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientCreateOrUpdateResourceGroupCall added in v0.35.0

type MockClientCreateOrUpdateResourceGroupCall struct {
	*gomock.Call
}

MockClientCreateOrUpdateResourceGroupCall wrap *gomock.Call

func (*MockClientCreateOrUpdateResourceGroupCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientCreateOrUpdateResourceGroupCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientCreateOrUpdateResourceGroupCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientLocationsCall added in v0.35.0

type MockClientLocationsCall struct {
	*gomock.Call
}

MockClientLocationsCall wrap *gomock.Call

func (*MockClientLocationsCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientLocationsCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientLocationsCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) CheckResourceGroupExistence

func (mr *MockClientMockRecorder) CheckResourceGroupExistence(arg0, arg1, arg2 any) *MockClientCheckResourceGroupExistenceCall

CheckResourceGroupExistence indicates an expected call of CheckResourceGroupExistence.

func (*MockClientMockRecorder) CreateOrUpdateResourceGroup

func (mr *MockClientMockRecorder) CreateOrUpdateResourceGroup(arg0, arg1, arg2, arg3 any) *MockClientCreateOrUpdateResourceGroupCall

CreateOrUpdateResourceGroup indicates an expected call of CreateOrUpdateResourceGroup.

func (*MockClientMockRecorder) Locations

func (mr *MockClientMockRecorder) Locations(arg0, arg1 any) *MockClientLocationsCall

Locations indicates an expected call of Locations.

func (*MockClientMockRecorder) ResourceGroups

func (mr *MockClientMockRecorder) ResourceGroups(arg0, arg1 any) *MockClientResourceGroupsCall

ResourceGroups indicates an expected call of ResourceGroups.

func (*MockClientMockRecorder) Subscriptions

func (mr *MockClientMockRecorder) Subscriptions(arg0 any) *MockClientSubscriptionsCall

Subscriptions indicates an expected call of Subscriptions.

type MockClientResourceGroupsCall added in v0.35.0

type MockClientResourceGroupsCall struct {
	*gomock.Call
}

MockClientResourceGroupsCall wrap *gomock.Call

func (*MockClientResourceGroupsCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientResourceGroupsCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientResourceGroupsCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientSubscriptionsCall added in v0.35.0

type MockClientSubscriptionsCall struct {
	*gomock.Call
}

MockClientSubscriptionsCall wrap *gomock.Call

func (*MockClientSubscriptionsCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientSubscriptionsCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientSubscriptionsCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type Profile

type Profile struct {
	InstallationID string         `json:"installationId"`
	Subscriptions  []Subscription `json:"subscriptions"`
}

Profile represents a Profile from the Azure CLI

func LoadProfile

func LoadProfile(path string) (result Profile, err error)

LoadProfile reads a file from the given path, decodes it into a Profile representation and returns the result, or an error if the file could not be read or decoded.

type Provider

type Provider struct {
	SubscriptionID   string
	ResourceGroup    string
	CredentialKind   AzureCredentialKind
	WorkloadIdentity *WorkloadIdentityCredential
	ServicePrincipal *ServicePrincipalCredential
}

Provider specifies the properties required to configure Azure provider for cloud resources

type ServicePrincipalCredential added in v0.35.0

type ServicePrincipalCredential struct {
	ClientID     string
	ClientSecret string
	TenantID     string
}

ServicePrincipal specifies the properties of an Azure service principal

type Subscription

type Subscription struct {
	EnvironmentName string `json:"environmentName"`
	ID              string `json:"id"`
	IsDefault       bool   `json:"isDefault"`
	Name            string `json:"name"`
	State           string `json:"state"`
	TenantID        string `json:"tenantId"`
	User            *User  `json:"user"`
}

Subscription represents a Subscription from the Azure CLI

type SubscriptionResult

type SubscriptionResult struct {
	Default       *Subscription
	Subscriptions []Subscription
}

SubscriptionResult is the result of loading Azure subscriptions for the user.

func LoadSubscriptionsFromAzure

func LoadSubscriptionsFromAzure(ctx context.Context, options clientv2.Options) (*SubscriptionResult, error)

LoadSubscriptionsFromAzure retrieves a list of subscriptions from Azure and returns them in a SubscriptionResult struct.

It returns an error if there is an issue retrieving the list.

func LoadSubscriptionsFromProfile

func LoadSubscriptionsFromProfile() (*SubscriptionResult, error)

LoadSubscriptionsFromProfile() reads the profile from a file, filters out the enabled subscriptions and returns a SubscriptionResult object containing the enabled subscriptions and the default subscription. If an error occurs, an error is returned.

type User

type User struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

User represents a User from the Azure CLI

type WorkloadIdentityCredential added in v0.35.0

type WorkloadIdentityCredential struct {
	ClientID string
	TenantID string
}

WorkloadIdentityCredential specifies the properties of an Azure service principal

Jump to

Keyboard shortcuts

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