Documentation ¶
Index ¶
Constants ¶
const ( // DefaultPartition is the name of the default Consul partition. DefaultPartition = "default" // DefaultNamespace is the name of the default Consul namespace. DefaultNamespace = "default" )
const DefaultPollingInterval = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
func IsACLNotFoundError ¶ added in v0.4.0
IsACLNotFoundError returns true if the ACL is not found.
Types ¶
type Controller ¶
type Controller struct { // Resources lists resources for Controller to reconcile. Resources ResourceLister // PollingInterval is an interval that Controller will use to reconcile all Resources. PollingInterval time.Duration // Log is the logger used by the Controller. Log hclog.Logger }
Controller is a generic controller implementation. It periodically polls for Resources and reconciles them by calling Resource's Upsert or Delete function accordingly.
func (*Controller) Run ¶
func (c *Controller) Run(ctx context.Context)
Run starts the Controller loop. The loop will exit when ctx is canceled.
type Resource ¶
type Resource interface { // Namespace indicates the namespace that this resource belongs to [Consul Enterprise]. // It returns the empty string if namespaces are not enabled. Namespace() string // IsPresent checks if the given resource is found in the response // returned by ECS IsPresent() bool // ID returns the taskID of the resource ID() TaskID // Reconcile offers functions to reconcile itself with an external state. Reconcile() error }
Resource is a generic type that needs to be reconciled by the Controller.
type ResourceLister ¶
type ResourceLister interface { // List all Resources. List() ([]Resource, error) // ReconcileNamespaces ensures that all requisite namespaces exist. ReconcileNamespaces([]Resource) error }
ResourceLister is an interface for listing Resources.
type TaskState ¶ added in v0.5.0
type TaskState struct { // SetupConsulClientFn sets up a consul client on demand. SetupConsulClientFn func() (*api.Client, error) // TaskID is the id of the ECS task. TaskID TaskID // ClusterARN is the ECS cluster. ClusterARN string // Partition that the task belongs to [Consul Enterprise]. Partition string // Namespace that the task belongs to [Consul Enterprise]. NS string // ECSTaskFound indicates whether an ECS task was found for this task id. ECSTaskFound bool // ACLTokens are the Consul ACL tokens found for this task id. ACLTokens []*api.ACLTokenListEntry // Service and the sidecar proxy registrations associated with this ECS task Services []*api.AgentService Log hclog.Logger }
TaskState contains the information needed to reconcile a task.
func (*TaskState) Delete ¶ added in v0.5.0
Delete removes the service token for the given ServiceInfo.
func (*TaskState) DeregisterServices ¶ added in v0.7.0
DeregisterServices removes the service and proxy registrations from the Consul catalog
type TaskStateLister ¶ added in v0.5.0
type TaskStateLister struct { // ECSClient is the AWS ECS client to be used by the ServiceStateLister. ECSClient ecsiface.ECSAPI // SetupConsulClientFn sets up a consul client on demand. SetupConsulClientFn func() (*api.Client, error) // ClusterARN is the name or the ARN of the ECS cluster. ClusterARN string // Partition is the partition that is used by the ServiceStateLister [Consul Enterprise]. // If partition and namespace support are not enabled then this is set to the empty string. Partition string // Log is the logger for the ServiceStateLister. Log hclog.Logger }
TaskStateLister is an implementation of ResourceLister.
func (TaskStateLister) List ¶ added in v0.5.0
func (s TaskStateLister) List() ([]Resource, error)
List returns resources to be reconciled. - Namespaces which may need to be created - Tokens which may need to be cleaned up
func (TaskStateLister) ReconcileNamespaces ¶ added in v0.5.0
func (s TaskStateLister) ReconcileNamespaces(resources []Resource) error
ReconcileNamespaces ensures that for every service in the cluster the namespace exists and the cross-partition/cross-namespace read policy exists.