This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 560
/
interfaces.go
126 lines (96 loc) · 6.02 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package armhelpers
import (
"time"
"github.com/Azure/azure-sdk-for-go/arm/authorization"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/disk"
"github.com/Azure/azure-sdk-for-go/arm/graphrbac"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/Azure/go-autorest/autorest"
log "github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
)
// ACSEngineClient is the interface used to talk to an Azure environment.
// This interface exposes just the subset of Azure APIs and clients needed for
// ACS-Engine.
type ACSEngineClient interface {
//AddAcceptLanguages sets the list of languages to accept on this request
AddAcceptLanguages(languages []string)
//
// RESOURCES
// DeployTemplate can deploy a template into Azure ARM
DeployTemplate(resourceGroup, name string, template, parameters map[string]interface{}, cancel <-chan struct{}) (*resources.DeploymentExtended, error)
// EnsureResourceGroup ensures the specified resource group exists in the specified location
EnsureResourceGroup(resourceGroup, location string, managedBy *string) (*resources.Group, error)
//
// COMPUTE
// List lists VM resources
ListVirtualMachines(resourceGroup string) (compute.VirtualMachineListResult, error)
// GetVirtualMachine retrieves the specified virtual machine.
GetVirtualMachine(resourceGroup, name string) (compute.VirtualMachine, error)
// DeleteVirtualMachine deletes the specified virtual machine.
DeleteVirtualMachine(resourceGroup, name string, cancel <-chan struct{}) (<-chan compute.OperationStatusResponse, <-chan error)
// ListVirtualMachineScaleSets lists the vmss resources in the resource group
ListVirtualMachineScaleSets(resourceGroup string) (compute.VirtualMachineScaleSetListResult, error)
// ListVirtualMachineScaleSetVMs lists the virtual machines contained in a vmss
ListVirtualMachineScaleSetVMs(resourceGroup, virtualMachineScaleSet string) (compute.VirtualMachineScaleSetVMListResult, error)
// DeleteVirtualMachineScaleSetVM deletes a VM in a VMSS
DeleteVirtualMachineScaleSetVM(resourceGroup, virtualMachineScaleSet, instanceID string, cancel <-chan struct{}) (<-chan compute.OperationStatusResponse, <-chan error)
// SetVirtualMachineScaleSetCapacity sets the VMSS capacity
SetVirtualMachineScaleSetCapacity(resourceGroup, virtualMachineScaleSet string, sku compute.Sku, location string, cancel <-chan struct{}) (<-chan compute.VirtualMachineScaleSet, <-chan error)
//
// STORAGE
// GetStorageClient uses SRP to retrieve keys, and then an authenticated client for talking to the specified storage
// account.
GetStorageClient(resourceGroup, accountName string) (ACSStorageClient, error)
//
// NETWORK
// DeleteNetworkInterface deletes the specified network interface.
DeleteNetworkInterface(resourceGroup, nicName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error)
//
// GRAPH
// CreateGraphAppliction creates an application via the graphrbac client
CreateGraphApplication(applicationCreateParameters graphrbac.ApplicationCreateParameters) (graphrbac.Application, error)
// CreateGraphPrincipal creates a service principal via the graphrbac client
CreateGraphPrincipal(servicePrincipalCreateParameters graphrbac.ServicePrincipalCreateParameters) (graphrbac.ServicePrincipal, error)
CreateApp(applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationID, servicePrincipalObjectID, secret string, err error)
// RBAC
CreateRoleAssignment(scope string, roleAssignmentName string, parameters authorization.RoleAssignmentCreateParameters) (authorization.RoleAssignment, error)
CreateRoleAssignmentSimple(applicationID, roleID string) error
DeleteRoleAssignmentByID(roleAssignmentNameID string) (authorization.RoleAssignment, error)
ListRoleAssignmentsForPrincipal(scope string, principalID string) (authorization.RoleAssignmentListResult, error)
// MANAGED DISKS
DeleteManagedDisk(resourceGroupName string, diskName string, cancel <-chan struct{}) (<-chan disk.OperationStatusResponse, <-chan error)
ListManagedDisksByResourceGroup(resourceGroupName string) (result disk.ListType, err error)
GetKubernetesClient(masterURL, kubeConfig string, interval, timeout time.Duration) (KubernetesClient, error)
ListProviders() (resources.ProviderListResult, error)
// DEPLOYMENTS
// ListDeploymentOperations gets all deployments operations for a deployment.
ListDeploymentOperations(resourceGroupName string, deploymentName string, top *int32) (result resources.DeploymentOperationsListResult, err error)
// ListDeploymentOperationsNextResults retrieves the next set of results, if any.
ListDeploymentOperationsNextResults(lastResults resources.DeploymentOperationsListResult) (result resources.DeploymentOperationsListResult, err error)
}
// ACSStorageClient interface models the azure storage client
type ACSStorageClient interface {
// DeleteBlob deletes the specified blob in the specified container.
DeleteBlob(container, blob string) error
}
// KubernetesClient interface models client for interacting with kubernetes api server
type KubernetesClient interface {
//ListPods returns all Pods running on the passed in node
ListPods(node *v1.Node) (*v1.PodList, error)
//GetNode returns details about node with passed in name
GetNode(name string) (*v1.Node, error)
//UpdateNode updates the node in the api server with the passed in info
UpdateNode(node *v1.Node) (*v1.Node, error)
//DeleteNode deregisters node in the api server
DeleteNode(name string) error
//SupportEviction queries the api server to discover if it supports eviction, and returns supported type if it is supported
SupportEviction() (string, error)
//DeletePod deletes the passed in pod
DeletePod(pod *v1.Pod) error
//EvictPod evicts the passed in pod using the passed in api version
EvictPod(pod *v1.Pod, policyGroupVersion string) error
//WaitForDelete waits until all pods are deleted. Returns all pods not deleted and an error on failure
WaitForDelete(logger *log.Entry, pods []v1.Pod, usingEviction bool) ([]v1.Pod, error)
}