Skip to content

Commit

Permalink
Add AgentConfigAccessor interface to ecs-agent/
Browse files Browse the repository at this point in the history
  • Loading branch information
danehlim committed Sep 26, 2023
1 parent 003edf0 commit 9a04051
Show file tree
Hide file tree
Showing 3 changed files with 306 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ecs-agent/config/generate_mocks.go
@@ -0,0 +1,16 @@
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.

package config

//go:generate mockgen -destination=mocks/config_mocks.go -copyright_file=../../scripts/copyright_file github.com/aws/amazon-ecs-agent/ecs-agent/config AgentConfigAccessor
62 changes: 62 additions & 0 deletions ecs-agent/config/interface.go
@@ -0,0 +1,62 @@
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.

package config

// AgentConfigAccessor provides access to an agent config via a set of designated methods (listed below).
type AgentConfigAccessor interface {
// APIEndpoint returns the endpoint to make calls against.
// (e.g., "ecs.us-east-1.amazonaws.com")
APIEndpoint() string
// AWSRegion returns the region to run in.
// (e.g., "us-east-1")
AWSRegion() string
// Cluster returns the name or full ARN of the cluster that the Agent
// should register the container instance into.
Cluster() string
// DefaultClusterName returns the name of the cluster that the container
// instance should be registered into by default (i.e., if no cluster is
// specified).
// (e.g., "default")
DefaultClusterName() string
// External returns whether the Agent is running on external compute
// capacity (i.e., outside of AWS).
External() bool
// InstanceAttributes returns a map of key/value pairs representing
// attributes to be associated with the instance within the ECS service.
// They are used to influence behavior such as launch placement.
InstanceAttributes() map[string]string
// NoInstanceIdentityDocument returns whether the Agent should register
// the instance with instance identity document.
NoInstanceIdentityDocument() bool
// OSFamily returns the operating system family of the instance.
// (e.g., "WINDOWS_SERVER_2019_CORE")
OSFamily() string
// OSType returns the operating system type of the instance.
// (e.g., "windows")
OSType() string
// ReservedMemory returns the reduction (in MiB) of the memory
// capacity of the instance that is reported to Amazon ECS.
// It is used by ECS service to influence task placement and does NOT reserve
// memory usage on the instance.
ReservedMemory() uint16
// ReservedPorts returns an array of ports which should be registered as
// unavailable.
ReservedPorts() []uint16
// ReservedPortsUDP returns an array of UDP ports which should be registered
// as unavailable.
ReservedPortsUDP() []uint16
// UpdateCluster updates the cluster that the Agent should register the
// container instance into.
UpdateCluster(cluster string)
}
228 changes: 228 additions & 0 deletions ecs-agent/config/mocks/config_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a04051

Please sign in to comment.