sigs.k8s.io/cluster-api-provider-aws@v1.5.5/pkg/cloud/services/interfaces.go (about)

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package services
    18  
    19  import (
    20  	infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"
    21  	expinfrav1 "sigs.k8s.io/cluster-api-provider-aws/exp/api/v1beta1"
    22  	"sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/scope"
    23  )
    24  
    25  const (
    26  	// TemporaryResourceID is the name used temporarily when creating AWS resources.
    27  	TemporaryResourceID = "temporary-resource-id"
    28  	// AnyIPv4CidrBlock is the CIDR block to match all IPv4 addresses.
    29  	AnyIPv4CidrBlock = "0.0.0.0/0"
    30  )
    31  
    32  // ASGInterface encapsulates the methods exposed to the machinepool
    33  // actuator.
    34  type ASGInterface interface {
    35  	ASGIfExists(id *string) (*expinfrav1.AutoScalingGroup, error)
    36  	GetASGByName(scope *scope.MachinePoolScope) (*expinfrav1.AutoScalingGroup, error)
    37  	CreateASG(scope *scope.MachinePoolScope) (*expinfrav1.AutoScalingGroup, error)
    38  	UpdateASG(scope *scope.MachinePoolScope) error
    39  	StartASGInstanceRefresh(scope *scope.MachinePoolScope) error
    40  	CanStartASGInstanceRefresh(scope *scope.MachinePoolScope) (bool, error)
    41  	UpdateResourceTags(resourceID *string, create, remove map[string]string) error
    42  	DeleteASGAndWait(id string) error
    43  }
    44  
    45  // EC2Interface encapsulates the methods exposed to the machine
    46  // actuator.
    47  type EC2Interface interface {
    48  	InstanceIfExists(id *string) (*infrav1.Instance, error)
    49  	TerminateInstance(id string) error
    50  	CreateInstance(scope *scope.MachineScope, userData []byte, userDataFormat string) (*infrav1.Instance, error)
    51  	GetRunningInstanceByTags(scope *scope.MachineScope) (*infrav1.Instance, error)
    52  
    53  	GetAdditionalSecurityGroupsIDs(securityGroup []infrav1.AWSResourceReference) ([]string, error)
    54  	GetCoreSecurityGroups(machine *scope.MachineScope) ([]string, error)
    55  	GetInstanceSecurityGroups(instanceID string) (map[string][]string, error)
    56  	UpdateInstanceSecurityGroups(id string, securityGroups []string) error
    57  	UpdateResourceTags(resourceID *string, create, remove map[string]string) error
    58  
    59  	TerminateInstanceAndWait(instanceID string) error
    60  	DetachSecurityGroupsFromNetworkInterface(groups []string, interfaceID string) error
    61  
    62  	DiscoverLaunchTemplateAMI(scope *scope.MachinePoolScope) (*string, error)
    63  	GetLaunchTemplate(id string) (lt *expinfrav1.AWSLaunchTemplate, userDataHash string, err error)
    64  	GetLaunchTemplateID(id string) (string, error)
    65  	CreateLaunchTemplate(scope *scope.MachinePoolScope, imageID *string, userData []byte) (string, error)
    66  	CreateLaunchTemplateVersion(scope *scope.MachinePoolScope, imageID *string, userData []byte) error
    67  	PruneLaunchTemplateVersions(id string) error
    68  	DeleteLaunchTemplate(id string) error
    69  	LaunchTemplateNeedsUpdate(scope *scope.MachinePoolScope, incoming *expinfrav1.AWSLaunchTemplate, existing *expinfrav1.AWSLaunchTemplate) (bool, error)
    70  	DeleteBastion() error
    71  	ReconcileBastion() error
    72  }
    73  
    74  // SecretInterface encapsulated the methods exposed to the
    75  // machine actuator.
    76  type SecretInterface interface {
    77  	Delete(m *scope.MachineScope) error
    78  	Create(m *scope.MachineScope, data []byte) (string, int32, error)
    79  	UserData(secretPrefix string, chunks int32, region string, endpoints []scope.ServiceEndpoint) ([]byte, error)
    80  }
    81  
    82  // ELBInterface encapsulates the methods exposed to the cluster and machine
    83  // controller.
    84  type ELBInterface interface {
    85  	DeleteLoadbalancers() error
    86  	ReconcileLoadbalancers() error
    87  	IsInstanceRegisteredWithAPIServerELB(i *infrav1.Instance) (bool, error)
    88  	DeregisterInstanceFromAPIServerELB(i *infrav1.Instance) error
    89  	RegisterInstanceWithAPIServerELB(i *infrav1.Instance) error
    90  }
    91  
    92  // NetworkInterface encapsulates the methods exposed to the cluster
    93  // controller.
    94  type NetworkInterface interface {
    95  	DeleteNetwork() error
    96  	ReconcileNetwork() error
    97  }
    98  
    99  // SecurityGroupInterface encapsulates the methods exposed to the cluster
   100  // controller.
   101  type SecurityGroupInterface interface {
   102  	DeleteSecurityGroups() error
   103  	ReconcileSecurityGroups() error
   104  }
   105  
   106  // ObjectStoreInterface encapsulates the methods exposed to the machine actuator.
   107  type ObjectStoreInterface interface {
   108  	DeleteBucket() error
   109  	ReconcileBucket() error
   110  	Delete(m *scope.MachineScope) error
   111  	Create(m *scope.MachineScope, data []byte) (objectURL string, err error)
   112  }