azure

package
v0.29.0 Latest Latest
Warning

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

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

Documentation

Overview

Package azure is a generated GoMock package.

Index

Constants

View Source
const (
	// ProviderDisplayName is the text used in display for Azure.
	ProviderDisplayName = "Azure"
)

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 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 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 interface{}) *gomock.Call

CheckResourceGroupExistence indicates an expected call of CheckResourceGroupExistence.

func (*MockClientMockRecorder) CreateOrUpdateResourceGroup

func (mr *MockClientMockRecorder) CreateOrUpdateResourceGroup(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

CreateOrUpdateResourceGroup indicates an expected call of CreateOrUpdateResourceGroup.

func (*MockClientMockRecorder) Locations

func (mr *MockClientMockRecorder) Locations(arg0, arg1 interface{}) *gomock.Call

Locations indicates an expected call of Locations.

func (*MockClientMockRecorder) ResourceGroups

func (mr *MockClientMockRecorder) ResourceGroups(arg0, arg1 interface{}) *gomock.Call

ResourceGroups indicates an expected call of ResourceGroups.

func (*MockClientMockRecorder) Subscriptions

func (mr *MockClientMockRecorder) Subscriptions(arg0 interface{}) *gomock.Call

Subscriptions indicates an expected call of Subscriptions.

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
	ServicePrincipal *ServicePrincipal
}

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

type ServicePrincipal

type ServicePrincipal 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

Jump to

Keyboard shortcuts

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