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.
func PartitionsEnabled ¶ added in v0.4.0
PartitionsEnabled indicates if support for partitions and namespaces is enabled.
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 // 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 { ConsulClient *api.Client // 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 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.
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 // ConsulClient is the Consul client to be used by the ServiceStateLister. ConsulClient *api.Client // 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 whcih 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.