cloud

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTenantID

func GetTenantID(resourceManagerEndpoint string, subscriptionID string) (string, error)

GetTenantID figures out the AAD tenant ID of the subscription by making an unauthenticated request to the Get Subscription Details endpoint and parses the value from WWW-Authenticate header. TODO this should probably to to the armhelpers library

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists parses the error message to check if it's resource already exists error.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the given error is a NotFound error.

func IsResourceNotFound

func IsResourceNotFound(err error) bool

IsResourceNotFound parses the error message to check if it's resource not found error.

func IsRoleAssignmentAlreadyDeleted

func IsRoleAssignmentAlreadyDeleted(err error) bool

IsRoleAssignmentAlreadyDeleted returns true if the given error is a role assignment already deleted error. Ref: https://docs.microsoft.com/en-us/rest/api/authorization/role-assignments/delete#response

Types

type AzureClient

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

func NewAzureClientWithCLI

func NewAzureClientWithCLI(env azure.Environment, subscriptionID, tenantID string) (*AzureClient, error)

NewAzureClientWithCLI creates an AzureClient configured from Azure CLI 2.0 for local development scenarios.

func NewAzureClientWithClientCertificate

func NewAzureClientWithClientCertificate(env azure.Environment, subscriptionID, clientID, tenantID string, certificate *x509.Certificate, privateKey *rsa.PrivateKey) (*AzureClient, error)

NewAzureClientWithClientCertificate returns an AzureClient via client_id and jwt certificate assertion

func NewAzureClientWithClientCertificateExternalTenant

func NewAzureClientWithClientCertificateExternalTenant(env azure.Environment, subscriptionID, tenantID, clientID string, certificate *x509.Certificate, privateKey *rsa.PrivateKey) (*AzureClient, error)

NewAzureClientWithClientCertificateExternalTenant returns an AzureClient via client_id and jwt certificate assertion against a 3rd party tenant

func NewAzureClientWithClientCertificateFile

func NewAzureClientWithClientCertificateFile(env azure.Environment, subscriptionID, clientID, tenantID, certificatePath, privateKeyPath string) (*AzureClient, error)

NewAzureClientWithClientCertificateFile returns an AzureClient via client_id and jwt certificate assertion

func NewAzureClientWithClientSecret

func NewAzureClientWithClientSecret(env azure.Environment, subscriptionID, clientID, clientSecret, tenantID string) (*AzureClient, error)

NewAzureClientWithClientSecret returns an AzureClient via client_id and client_secret

func (*AzureClient) AddFederatedCredential

func (c *AzureClient) AddFederatedCredential(ctx context.Context, objectID string, fc FederatedCredential) error

AddFederatedCredential adds a federated credential to the cloud provider.

func (*AzureClient) CreateApplication

func (c *AzureClient) CreateApplication(ctx context.Context, displayName string) (graphrbac.Application, error)

CreateApplication creates an application.

func (*AzureClient) CreateRoleAssignment

func (c *AzureClient) CreateRoleAssignment(ctx context.Context, scope, roleName, principalID string) (authorization.RoleAssignment, error)

CreateRoleAssignment creates a role assignment.

func (*AzureClient) CreateServicePrincipal

func (c *AzureClient) CreateServicePrincipal(ctx context.Context, appID string, tags []string) (graphrbac.ServicePrincipal, error)

CreateServicePrincipal creates a service principal for the given application. No secret or certificate is generated.

func (*AzureClient) DeleteApplication

func (c *AzureClient) DeleteApplication(ctx context.Context, objectID string) (autorest.Response, error)

DeleteApplication deletes an application.

func (*AzureClient) DeleteFederatedCredential

func (c *AzureClient) DeleteFederatedCredential(ctx context.Context, objectID, federatedCredentialID string) error

DeleteFederatedCredential deletes a federated credential from the cloud provider.

func (*AzureClient) DeleteRoleAssignment

func (c *AzureClient) DeleteRoleAssignment(ctx context.Context, roleAssignmentID string) (authorization.RoleAssignment, error)

DeleteRoleAssignment deletes a role assignment.

func (*AzureClient) DeleteServicePrincipal

func (c *AzureClient) DeleteServicePrincipal(ctx context.Context, objectID string) (autorest.Response, error)

DeleteServicePrincipal deletes a service principal.

func (*AzureClient) GetApplication

func (c *AzureClient) GetApplication(ctx context.Context, displayName string) (graphrbac.Application, error)

GetApplication gets an application by its display name.

func (*AzureClient) GetFederatedCredential

func (c *AzureClient) GetFederatedCredential(ctx context.Context, objectID, issuer, subject string) (FederatedCredential, error)

GetFederatedCredential gets a federated credential from the cloud provider.

func (*AzureClient) GetServicePrincipal

func (c *AzureClient) GetServicePrincipal(ctx context.Context, displayName string) (graphrbac.ServicePrincipal, error)

GetServicePrincipal gets a service principal by its display name.

type FederatedCredential

type FederatedCredential struct {
	Name        string   `json:"name"`
	Issuer      string   `json:"issuer"`
	Subject     string   `json:"subject"`
	Description string   `json:"description"`
	Audiences   []string `json:"audiences"`
	ID          string   `json:"id"`
}

FederatedCredential is the definition of the federated credential.

func NewFederatedCredential

func NewFederatedCredential(objectID, issuer, subject, description string, audiences []string) FederatedCredential

NewFederatedCredential returns a new federated credential.

type FederatedCredentials

type FederatedCredentials struct {
	Value []FederatedCredential `json:"value"`
}

FederatedCredentials returns a list of federated credentials for the specified application.

type FederatedCredentialsClient

type FederatedCredentialsClient struct {
	autorest.Client
	// contains filtered or unexported fields
}

func NewFederatedCredentialsClient

func NewFederatedCredentialsClient(baseURI string) FederatedCredentialsClient

type Interface

type Interface interface {
	CreateServicePrincipal(ctx context.Context, appID string, tags []string) (graphrbac.ServicePrincipal, error)
	CreateApplication(ctx context.Context, displayName string) (graphrbac.Application, error)
	DeleteServicePrincipal(ctx context.Context, objectID string) (autorest.Response, error)
	DeleteApplication(ctx context.Context, objectID string) (autorest.Response, error)
	GetServicePrincipal(ctx context.Context, displayName string) (graphrbac.ServicePrincipal, error)
	GetApplication(ctx context.Context, displayName string) (graphrbac.Application, error)

	// Role assignment methods
	CreateRoleAssignment(ctx context.Context, scope, roleName, principalID string) (authorization.RoleAssignment, error)
	DeleteRoleAssignment(ctx context.Context, roleAssignmentID string) (authorization.RoleAssignment, error)

	// Federation methods
	AddFederatedCredential(ctx context.Context, objectID string, fc FederatedCredential) error
	GetFederatedCredential(ctx context.Context, objectID, issuer, subject string) (FederatedCredential, error)
	DeleteFederatedCredential(ctx context.Context, objectID, federatedCredentialID string) error
}

Directories

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

Jump to

Keyboard shortcuts

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