Documentation ¶
Overview ¶
Copyright 2022 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License 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 labels provides a way to get dynamic labels. Used by SSH, App, and Kubernetes servers.
Index ¶
Constants ¶
const ( // AWSLabelNamespace is used as the namespace prefix for any labels // imported from AWS. AWSLabelNamespace = "aws" // AzureLabelNamespace is used as the namespace prefix for any labels // imported from Azure. AzureLabelNamespace = "azure" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudConfig ¶
type CloudConfig struct { Client cloud.InstanceMetadata Clock clockwork.Clock Log logrus.FieldLogger // contains filtered or unexported fields }
CloudConfig is the configuration for a cloud label service.
type CloudImporter ¶
type CloudImporter struct { *CloudConfig // contains filtered or unexported fields }
CloudImporter is a service that periodically imports tags from a cloud service via instance metadata.
func NewCloudImporter ¶
func NewCloudImporter(ctx context.Context, c *CloudConfig) (*CloudImporter, error)
NewCloudImporter creates a new cloud label importer.
func (*CloudImporter) Apply ¶
func (l *CloudImporter) Apply(r types.ResourceWithLabels)
Apply adds cloud labels to the provided resource.
func (*CloudImporter) Get ¶
func (l *CloudImporter) Get() map[string]string
Get returns the list of updated cloud labels.
func (*CloudImporter) Start ¶
func (l *CloudImporter) Start(ctx context.Context)
Start will start a loop that continually keeps cloud labels updated.
type Dynamic ¶
type Dynamic struct {
// contains filtered or unexported fields
}
Dynamic allows defining a set of labels whose output is the result of some command execution. Dynamic labels can be configured to update periodically to provide updated information.
func NewDynamic ¶
func NewDynamic(ctx context.Context, config *DynamicConfig) (*Dynamic, error)
NewDynamic returns new Dynamic that can be configured to run asynchronously in a loop or synchronously.
func (*Dynamic) Close ¶
func (l *Dynamic) Close()
Close will free up all resources and stop the keeping dynamic labels updated.
func (*Dynamic) Get ¶
func (l *Dynamic) Get() map[string]types.CommandLabel
Get returns the list of updated dynamic labels.
type DynamicConfig ¶
type DynamicConfig struct { // Labels is the list of dynamic labels to update. Labels services.CommandLabels // Log is a component logger. Log *logrus.Entry }
DynamicConfig is the configuration for dynamic labels.
func (*DynamicConfig) CheckAndSetDefaults ¶
func (c *DynamicConfig) CheckAndSetDefaults() error
CheckAndSetDefaults makes sure valid values were passed in to create dynamic labels.
type Importer ¶
type Importer interface { // Get returns the current labels. Get() map[string]string // Apply adds the current labels to the provided resource's static labels. Apply(r types.ResourceWithLabels) // Sync blocks and synchronously updates the labels. Sync(context.Context) error // Start starts a loop that continually keeps the labels updated. Start(context.Context) }
Importer is an interface for labels imported from an external source, such as a cloud provider.