internal

package
v0.0.0-...-54d739a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AgentGVK = schema.GroupVersionKind{
		Group:   "agent-install.openshift.io",
		Version: "v1beta1",
		Kind:    "Agent",
	}
	AgentListGVK = listGVK(AgentGVK)

	AgentClusterInstallGVK = schema.GroupVersionKind{
		Group:   "extensions.hive.openshift.io",
		Version: "v1beta1",
		Kind:    "AgentClusterInstall",
	}
	AgentClusterInstallListGVK = listGVK(AgentClusterInstallGVK)

	BackingStoreGVK = schema.GroupVersionKind{
		Group:   "noobaa.io",
		Version: "v1alpha1",
		Kind:    "BackingStore",
	}
	BackingStoreListGVK = listGVK(BackingStoreGVK)

	BareMetalHostGVK = schema.GroupVersionKind{
		Group:   "metal3.io",
		Version: "v1alpha1",
		Kind:    "BareMetalHost",
	}
	BareMetalHostListGVK = listGVK(BareMetalHostGVK)

	CatalogSourceGVK = schema.GroupVersionKind{
		Group:   "operators.coreos.com",
		Version: "v1alpha1",
		Kind:    "CatalogSource",
	}
	CatalogSourceListGVK = listGVK(CatalogSourceGVK)

	ClusterDeploymentGVK = schema.GroupVersionKind{
		Group:   "hive.openshift.io",
		Version: "v1",
		Kind:    "ClusterDeployment",
	}
	ClusterDeploymentListGVK = listGVK(ClusterDeploymentGVK)

	CustomResourceDefinitionGVK = schema.GroupVersionKind{
		Group:   "apiextensions.k8s.io",
		Version: "v1",
		Kind:    "CustomResourceDefinition",
	}
	CustomResourceDefinitionListGVK = listGVK(CustomResourceDefinitionGVK)

	ImageConfigGVK = schema.GroupVersionKind{
		Group:   "config.openshift.io",
		Version: "v1",
		Kind:    "Image",
	}
	ImageConfigListGVK = listGVK(ImageConfigGVK)

	InfraEnvGKV = schema.GroupVersionKind{
		Group:   "agent-install.openshift.io",
		Version: "v1beta1",
		Kind:    "InfraEnv",
	}
	InfraEnvListGKV = listGVK(InfraEnvGKV)

	IngressControllerGVK = schema.GroupVersionKind{
		Group:   "operator.openshift.io",
		Version: "v1",
		Kind:    "IngressController",
	}
	IngressControllerListGVK = listGVK(IngressControllerGVK)

	LocalVolumeGVK = schema.GroupVersionKind{
		Group:   "local.storage.openshift.io",
		Version: "v1",
		Kind:    "LocalVolume",
	}
	LocalVolumeListGVK = listGVK(LocalVolumeGVK)

	LVMClusterGVK = schema.GroupVersionKind{
		Group:   "lvm.topolvm.io",
		Version: "v1alpha1",
		Kind:    "LVMCluster",
	}
	LVMClusterListGVK = listGVK(LVMClusterGVK)

	ManagedClusterGVK = schema.GroupVersionKind{
		Group:   "cluster.open-cluster-management.io",
		Version: "v1",
		Kind:    "ManagedCluster",
	}
	ManagedClusterListGVK = listGVK(ManagedClusterGVK)

	NamespaceGVK = schema.GroupVersionKind{
		Group:   "",
		Version: "v1",
		Kind:    "Namespace",
	}
	NamespaceListGVK = listGVK(NamespaceGVK)

	NMStateConfigGVK = schema.GroupVersionKind{
		Group:   "agent-install.openshift.io",
		Version: "v1beta1",
		Kind:    "NMStateConfig",
	}
	NMStateConfigListGVK = listGVK(NMStateConfigGVK)

	QuayRegistryGVK = schema.GroupVersionKind{
		Group:   "quay.redhat.com",
		Version: "v1",
		Kind:    "QuayRegistry",
	}
	QuayRegistryListGVK = listGVK(QuayRegistryGVK)

	RouteGVK = schema.GroupVersionKind{
		Group:   "route.openshift.io",
		Version: "v1",
		Kind:    "Route",
	}
	RouteListGVK = listGVK(RouteGVK)

	StorageClusterGVK = schema.GroupVersionKind{
		Group:   "ocs.openshift.io",
		Version: "v1",
		Kind:    "StorageCluster",
	}
	StorageClusterListGVK = listGVK(StorageClusterGVK)
)

Functions

func AddConsoleFlags

func AddConsoleFlags(set *pflag.FlagSet)

AddConsoleFlags adds the console flags to the given flag set.

func AddEnricherFlags

func AddEnricherFlags(set *pflag.FlagSet)

AddEnricherFlags adds the enricher flags to the given flag set.

func ConsoleIntoContext

func ConsoleIntoContext(ctx context.Context, console *Console) context.Context

ConsoleIntoContext creates a new context that contains the given console.

func LoggerFromContext

func LoggerFromContext(ctx context.Context) logr.Logger

LoggerFromContext returns the logger from the context. It panics if the given context doesn't contain a logger.

func LoggerIntoContext

func LoggerIntoContext(ctx context.Context, logger logr.Logger) context.Context

LoggerIntoContext creates a new context that contains the given logger.

func ToolIntoContext

func ToolIntoContext(ctx context.Context, tool *Tool) context.Context

ToolIntoContext creates a new context that contains the given tool.

Types

type Applier

type Applier struct {
	// contains filtered or unexported fields
}

Applier knows how to create Kubernetes API objects from templates. Don't create instances of this type directly, use the NewApplier function instead.

func (*Applier) Apply

func (a *Applier) Apply(ctx context.Context, data any) error

Apply generates the objects passing the given data to the templates and then creates them.

func (*Applier) ApplyObjects

func (a *Applier) ApplyObjects(ctx context.Context, objects []*unstructured.Unstructured) error

ApplyObjects creates the given objects.

func (*Applier) Delete

func (a *Applier) Delete(ctx context.Context, data any) error

Delete generates the objects passing the given data to the templates and then deletes them.

func (*Applier) DeleteObjects

func (a *Applier) DeleteObjects(ctx context.Context, objects []*unstructured.Unstructured) error

DeleteObjects deletes the given objects.

func (*Applier) Render

func (a *Applier) Render(ctx context.Context, data any) (results []*unstructured.Unstructured,
	err error)

Render generates the objects passing the given data to the templates, but doesn't actually create them.

type ApplierBuilder

type ApplierBuilder struct {
	// contains filtered or unexported fields
}

ApplierBuilder contains the data and logic needed to create an object that knows how create Kubernetes API objects from templates. Don't create instances of this type directly, use the NewApplier function instead.

func NewApplier

func NewApplier() *ApplierBuilder

NewApplier creates a builder that can then be used to create an object that knows how create Kubernetes API objects from templates.

func (*ApplierBuilder) AddDir

func (b *ApplierBuilder) AddDir(value string) *ApplierBuilder

AddDir adds a directory within the templates filesystem root that contains templates for the Kubernetes API objects. This is optional. If no directory is specified then all the templates in the filesystem will be used.

func (*ApplierBuilder) AddDirs

func (b *ApplierBuilder) AddDirs(values ...string) *ApplierBuilder

AddDirs adds a set of directories within the templates filesystem root that contain templates for the Kubernetes API objects. This is optional. If no directory is specified then all the templates in the filesystem will be used.

func (*ApplierBuilder) AddLabel

func (b *ApplierBuilder) AddLabel(name, value string) *ApplierBuilder

AddLabel adds a label that will be added to all the objects created. This is optional.

func (*ApplierBuilder) AddLabels

func (b *ApplierBuilder) AddLabels(values map[string]string) *ApplierBuilder

AddLabels adds a the collection of labels that will be added to all the objects created. This is ooptional.

func (*ApplierBuilder) AddListener

func (b *ApplierBuilder) AddListener(value func(*ApplierEvent)) *ApplierBuilder

AddListener adds a function that will be called when an event is generated. This is optional.

func (*ApplierBuilder) Build

func (b *ApplierBuilder) Build() (result *Applier, err error)

Build uses the data stored in the builder to create a new applier.

func (*ApplierBuilder) SetClient

func (b *ApplierBuilder) SetClient(value clnt.WithWatch) *ApplierBuilder

SetClient sets the Kubernetes API client that the applier will use to create the objects.

func (*ApplierBuilder) SetDir

func (b *ApplierBuilder) SetDir(value string) *ApplierBuilder

SetDir sets a directory within the templates filesystem root that contains templates for the Kubernetes API objects. This is optional. If no directory is specified then all the templates in the filesystem will be used. Note that this removes all previously configured directories, use AddDir if you want to preserve them.

func (*ApplierBuilder) SetDirs

func (b *ApplierBuilder) SetDirs(values ...string) *ApplierBuilder

SetDirs sets a set of directories within the templates filesystem root that contain templates for the Kubernetes API objects. This is optional. If no directory is specified then all the templates in the filesystem will be used. Note that this removes all previously configured directories, use AddDirs if you want to preserve them.

func (*ApplierBuilder) SetFS

func (b *ApplierBuilder) SetFS(value fs.FS) *ApplierBuilder

SetFS sets the file system containing the templates. This is mandatory.

func (*ApplierBuilder) SetListener

func (b *ApplierBuilder) SetListener(value func(*ApplierEvent)) *ApplierBuilder

SetListener sets a function that will be called when an event is generated. This is optional. Note that this removes any previously added listener. If you want to preserve them use the AddListener function.

func (*ApplierBuilder) SetLogger

func (b *ApplierBuilder) SetLogger(value logr.Logger) *ApplierBuilder

SetLogger sets the logger that the renderer will use to write log messages. This is mandatory.

func (*ApplierBuilder) SetRoot

func (b *ApplierBuilder) SetRoot(value string) *ApplierBuilder

SetRoot sets the root directory of the templates file system. Directories specified with the AddDir method are relative to this. This is optional.

type ApplierEvent

type ApplierEvent struct {
	Type   ApplierEventType
	Object *unstructured.Unstructured
	Error  error
}

ApplierEvents represents an event generated by the applier to inform of the progress of its work.

type ApplierEventType

type ApplierEventType string

ApplierEventType defines the possible types of events.

const (
	// ApplierObjectCreated indicates that an object didn't exist and has been created.
	ApplierObjectCreated ApplierEventType = "ObjectCreated"

	// ApplierObjectExist indicates that an object already existed and therefore it hasn't been
	// created.
	ApplierObjectExist ApplierEventType = "ObjectExists"

	// ApplierCreateError indicates that an error occurred while trying to create an object.
	ApplierCreateError ApplierEventType = "CreateError"

	// ApplierStatusUpdated indicates that the status of an object has been updated.
	ApplierStatusUpdated ApplierEventType = "StatusUpdated"

	// ApplierStatusError indicates that an error occurred while trying to update the status of
	// an object.
	ApplierStatusError ApplierEventType = "StatusError"

	// ApplierObjectDeleted indicates that an object was deleted.
	ApplierObjectDeleted ApplierEventType = "ObjectDeleted"

	// ApplierDeleteError indicates that an error occurred while tring to delete an object.
	ApplierDeleteError ApplierEventType = "DeleteError"

	// ApplierObjectNotExist indicates that an object doesn't exist.
	ApplierObjectNotExist ApplierEventType = "ObjectNotExist"

	// ApplierWaitingCRD indicates that the applier is waiting for a custom resource definition
	// to exist before trying to create an object.
	ApplierWaitingCRD ApplierEventType = "WaitingCRD"

	// ApplierWaitingDisappear indicates that the applier is waiting for an object to completely
	// disappear before deleting the namespace.
	ApplierWaitingDisappear ApplierEventType = "WaitingDisappear"
)

type ApplierListener

type ApplierListener struct {
	// contains filtered or unexported fields
}

ApplierListener knows how to write to the console human friendly representations of applier events.

func (*ApplierListener) Func

func (l *ApplierListener) Func(event *ApplierEvent)

Func is the listener function that should be passed to the SetListener or AddListener methods of the applier builder.

type ApplierListenerBuilder

type ApplierListenerBuilder struct {
	// contains filtered or unexported fields
}

ApplierListenerBuilder contains the data and logic needed to create an object that listens for applier events and writes them to the console using a human friendly format.

func NewApplierListener

func NewApplierListener() *ApplierListenerBuilder

NewApplierListener creates a builder that can then be used to create a listener.

func (*ApplierListenerBuilder) Build

func (b *ApplierListenerBuilder) Build() (result *ApplierListener, err error)

Build uses the data stored in the builder to create a new listener.

func (*ApplierListenerBuilder) SetConsole

func (b *ApplierListenerBuilder) SetConsole(value *Console) *ApplierListenerBuilder

SetConsole sets the console. This is mandatory.

func (*ApplierListenerBuilder) SetLogger

SetLogger sets the logger that the listener will use to write log messages. This is mandatory.

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) AddAnnotation

func (c *Client) AddAnnotation(ctx context.Context, object clnt.Object, name, value string) error

AddAnnotation adds an annotation with the given name and value to an object.

func (*Client) AddAnnotations

func (c *Client) AddAnnotations(ctx context.Context, object clnt.Object,
	annotations map[string]string) error

AddAnnotations adds multiple annotations with the given name and value to an object.

func (*Client) AddLabel

func (c *Client) AddLabel(ctx context.Context, object clnt.Object, name, value string) error

AddLabel adds a label with the given name and value to an object.

func (*Client) AddLabels

func (c *Client) AddLabels(ctx context.Context, object clnt.Object,
	labels map[string]string) error

AddLabels adds multiple labels with the given names and values to an object.

func (*Client) Close

func (c *Client) Close() error

Close closes the client and releases all the resources it is using. It is specially important to call this method when the client is using as SSH tunnel, as otherwise the tunnel will remain open.

func (*Client) Create

func (c *Client) Create(ctx context.Context, obj clnt.Object, opts ...clnt.CreateOption) error

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, obj clnt.Object, opts ...clnt.DeleteOption) error

func (*Client) DeleteAllOf

func (c *Client) DeleteAllOf(ctx context.Context, obj clnt.Object,
	opts ...clnt.DeleteAllOfOption) error

func (*Client) DeleteAnnotation

func (c *Client) DeleteAnnotation(ctx context.Context, object clnt.Object, name string) error

DeleteAnnotation deletes the annotation with the given name from an object.

func (*Client) DeleteAnnotations

func (c *Client) DeleteAnnotations(ctx context.Context, object clnt.Object, names ...string) error

DeleteAnnotations deletes multiple annotations with the given names from an object.

func (*Client) DeleteCRDGroup

func (c *Client) DeleteCRDGroup(ctx context.Context, group string) (n int, err error)

DeleteCRDGroup deletes all the custom resource definitions in the given group. Returns the number of CRDs actually deleted.

func (*Client) DeleteLabel

func (c *Client) DeleteLabel(ctx context.Context, object clnt.Object, name string) error

DeleteLabels deletes the annotation with the given name from an object.

func (*Client) DeleteLabels

func (c *Client) DeleteLabels(ctx context.Context, object clnt.Object, names ...string) error

DeleteLabels deletes multiple labels with the given names from an object.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key types.NamespacedName, obj clnt.Object,
	opts ...clnt.GetOption) error

func (*Client) List

func (c *Client) List(ctx context.Context, list clnt.ObjectList,
	opts ...clnt.ListOption) error

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, obj clnt.Object, patch clnt.Patch,
	opts ...clnt.PatchOption) error

func (*Client) RESTMapper

func (c *Client) RESTMapper() meta.RESTMapper

func (*Client) Scheme

func (c *Client) Scheme() *runtime.Scheme

func (*Client) Status

func (c *Client) Status() clnt.SubResourceWriter

func (*Client) SubResource

func (c *Client) SubResource(subResource string) clnt.SubResourceClient

func (*Client) Update

func (c *Client) Update(ctx context.Context, obj clnt.Object, opts ...clnt.UpdateOption) error

func (*Client) Watch

func (c *Client) Watch(ctx context.Context, list clnt.ObjectList,
	options ...clnt.ListOption) (result apiwatch.Interface, err error)

type ClientBuilder

type ClientBuilder struct {
	// contains filtered or unexported fields
}

Client builder contains the data and logic needed to create a Kubernetes API client that implements the controller-runtime WithWatch interface. Don't create instances of this type directly, use the NewClient function instead.

func NewClient

func NewClient() *ClientBuilder

NewClient creates a builder that can then be used to configure and create a Kubernetes API client that implements the controller-runtime WithWatch interface.

func (*ClientBuilder) AddSSHServer

func (b *ClientBuilder) AddSSHServer(value string) *ClientBuilder

AddSSHServer adds the address of the SSH server. When there are multiple SSH servers they will be tried in order till one succeeds. The value must be the host name or IP address of the server, followed by an optional colon and port number. If no port number is specified the default 22 will be used.

func (*ClientBuilder) AddSSHServers

func (b *ClientBuilder) AddSSHServers(values ...string) *ClientBuilder

AddSSHServers adds the addresses of multiple SSH servers. When there are multiple SSH servers they will be tried in order till one succeeds.

func (*ClientBuilder) AddWrapper

func (b *ClientBuilder) AddWrapper(value func(http.RoundTripper) http.RoundTripper) *ClientBuilder

AddWrapper adds a function that will be called to wrap the HTTP transport. When multiple wrappers are added they will be called in the the reverse order, so that the request processing logic of those wrappers will be executed in the right order. For example, example if you want to add a wrapper that adds a `X-My` to the request header, and then another wrapper that reads that header you should add them in this order:

client, err := NewClient().
	SetLogger(logger).
	AddWrapper(addMyHeader).
	AddWrapper(readMyHeader).
	Build()
if err != nil {
	...
}

The opposite happens with response processing logic: it happens in the same order that the wrappers were added.

The logging wrapper should not be added with this method, but with the SetLoggingWrapper methods, otherwise a default logging wrapper will be automatically added.

func (*ClientBuilder) Build

func (b *ClientBuilder) Build() (result *Client, err error)

Build uses the data stored in the builder to configure and create a new Kubernetes API client.

func (*ClientBuilder) SetFlags

func (b *ClientBuilder) SetFlags(flags *pflag.FlagSet) *ClientBuilder

SetFlags sets the command line flags that should be used to configure the client. This is optional.

func (*ClientBuilder) SetKubeconfig

func (b *ClientBuilder) SetKubeconfig(value any) *ClientBuilder

SetKubeconfig sets the bytes of the kubeconfig file that will be used to create the client. The value can be an array of bytes containing the configuration data or a string containing the name of a file. This is optional, and if not specified then the configuration will be loaded from the typical default locations: the `~/.kube/config` file, the `KUBECONFIG` environment variable, etc.

func (*ClientBuilder) SetLogger

func (b *ClientBuilder) SetLogger(value logr.Logger) *ClientBuilder

SetLogger sets the logger that the client will use to write to the log.

func (*ClientBuilder) SetLoggingWrapper

func (b *ClientBuilder) SetLoggingWrapper(
	value func(http.RoundTripper) http.RoundTripper) *ClientBuilder

SetLoggingWrapper sets the logging transport wrapper. If this isn't set then a default one will be created. Note that this wrapper, either the one explicitly set or the default, will always be the last to process requests and the first to process responses.

func (*ClientBuilder) SetSSHKey

func (b *ClientBuilder) SetSSHKey(value []byte) *ClientBuilder

SetSSHKey sets the SSH key. This is required when the SSH server is specified. The value should be a PEM encoded private key.

func (*ClientBuilder) SetSSHServer

func (b *ClientBuilder) SetSSHServer(value string) *ClientBuilder

SetSSHServer sets the address of the SSH server. Note that this removes any previously configured one. If you want to preserve them use the AddSSHServer method. The value must be the host name or IP address of the server, followed by an optional colon and port number. If no port number is specified the default 22 will be used.

func (*ClientBuilder) SetSSHServers

func (b *ClientBuilder) SetSSHServers(values ...string) *ClientBuilder

SetSSHServers sets the addresses of multiple SSH servers. Note that this removes any previously configured one. If you want to preserve them use the AddSSHServers method. The value must be the host name or IP address of the server, followed by an optional colon and port number. If no port number is specified the default 22 will be used.

func (*ClientBuilder) SetSSHUser

func (b *ClientBuilder) SetSSHUser(value string) *ClientBuilder

SetSSHUser sets the name of the SSH user. This is mandatory when a SSH server is specified.

type Console

type Console struct {
	// contains filtered or unexported fields
}

Console knows how to write messages to the terminal. Don't create instances of this directly, use the NewConsole function instead.

func ConsoleFromContext

func ConsoleFromContext(ctx context.Context) *Console

ConsoleFromContext returns the console from the context. It panics if the given context doesn't contain a console.

func (*Console) Error

func (c *Console) Error(format string, args ...any)

Info writes an error message to the console.

func (*Console) Info

func (c *Console) Info(format string, args ...any)

Info writes an informative message to the console.

func (*Console) Warn

func (c *Console) Warn(format string, args ...any)

Wanr writes an warning message to the console.

type ConsoleBuilder

type ConsoleBuilder struct {
	// contains filtered or unexported fields
}

ConsoleBuilder contains the data and logic needed to create an instance of the console. Don't create instances of this directly, use the NewConsole function instead.

func NewConsole

func NewConsole() *ConsoleBuilder

NewConsole creates a builder that can then be used to configure and create a console.

func (*ConsoleBuilder) Build

func (b *ConsoleBuilder) Build() (result *Console, err error)

Build uses the data stored in the buider to create a new instance of the console.

func (*ConsoleBuilder) SetColor

func (b *ConsoleBuilder) SetColor(value bool) *ConsoleBuilder

SetColor enables or disables use of color in the console. By default color is enabled if the console is a terminal and disabled otherwise.

func (*ConsoleBuilder) SetErr

func (b *ConsoleBuilder) SetErr(value io.Writer) *ConsoleBuilder

SetErr sets the standard error stream. This is mandatory, but will be ignored if the console is muted.

func (*ConsoleBuilder) SetFlags

func (b *ConsoleBuilder) SetFlags(flags *pflag.FlagSet) *ConsoleBuilder

SetFlags sets the command line flags that that indicate how to configure the console. This is optional.

func (*ConsoleBuilder) SetLogger

func (b *ConsoleBuilder) SetLogger(value logr.Logger) *ConsoleBuilder

SetLogger sets the logger that the console will use to write messages to the log. This is mandatory.

func (*ConsoleBuilder) SetMute

func (b *ConsoleBuilder) SetMute(value bool) *ConsoleBuilder

SetMute sets or clears the flag that indicates if the console should not write to its outpout and error streams. This is optional and by default the console does write to those streams. But in situations where the console and the logger write to the same streams it may be convenient to mute the console so it doesn't interfere with the JSON text written by the logger.

Note that this setting doesn't affect how the log is written, in particular it doesn't affect the log messages generated by the console itself.

func (*ConsoleBuilder) SetOut

func (b *ConsoleBuilder) SetOut(value io.Writer) *ConsoleBuilder

SetOut sets the standard output stream. This is mandatory, but will be ignored if the console is muted.

type Enricher

type Enricher struct {
	// contains filtered or unexported fields
}

Enricher knows how to add information to the description of a cluster. Don't create instances of this type directly, use the NewEnricher function instead.

func (*Enricher) Enrich

func (e *Enricher) Enrich(ctx context.Context, config *models.Config) error

Enrich completes the configuration adding the information that will be required later to create the clusters.

type EnricherBuilder

type EnricherBuilder struct {
	// contains filtered or unexported fields
}

EnricherBuilder contains the data and logic needed to create an object that knows how to add information to the description of a cluster. Don't create instances of this type directly, use the NewEnricher function instead.

func NewEnricher

func NewEnricher() *EnricherBuilder

NewEnricher creates a builder that can then be used to create an object that knows how to add information to the description of a cluster.

func (*EnricherBuilder) Build

func (b *EnricherBuilder) Build() (result *Enricher, err error)

Build uses the data stored in the builder to create a new object that knows how to add information to the description of a cluster.

func (*EnricherBuilder) SetClient

func (b *EnricherBuilder) SetClient(value clnt.Client) *EnricherBuilder

SetClient sets the Kubernetes API client that the enricher will use to talk to the hub cluster in order to extract the additional information.

func (*EnricherBuilder) SetFlags

func (b *EnricherBuilder) SetFlags(flags *pflag.FlagSet) *EnricherBuilder

SetFlags sets the command line flags that that indicate how to configure the enricher. This is optional.

func (*EnricherBuilder) SetLogger

func (b *EnricherBuilder) SetLogger(value logr.Logger) *EnricherBuilder

SetLogger sets the logger that the enricher will use to write log messages. This is mandatory.

func (*EnricherBuilder) SetResolver

func (b *EnricherBuilder) SetResolver(value string) *EnricherBuilder

SetResolver sets the IP address and port number of DNS server that the enricher will resolve names, for example `127.0.0.1:53`. There is usually no need to change this, it is intended for use in unit tests.

type RegistryTool

type RegistryTool struct {
	// contains filtered or unexported fields
}

RegistryTool is a tool that knows how to perform tasks related to image registries. For example, it knows how to add a trusted registry to an OpenShift cluster. Don't create instances of this directly, use the NewRegistryTool function instead.

func (*RegistryTool) AddTrusted

func (t *RegistryTool) AddTrusted(ctx context.Context, server string, ca []byte) error

AddTrusted sets the given server as an additional trusted registry. If the CA is nil it will be fetched from the registry server.

func (*RegistryTool) FetchCA

func (t *RegistryTool) FetchCA(address string) (result []byte, err error)

FetchCA fetches the CA certificate from the given address.

func (*RegistryTool) IsTrusted

func (t *RegistryTool) IsTrusted(ctx context.Context, server string, ca []byte) (result bool,
	err error)

IsTrusted checks if the given server is an additional trusted registry. If the CA is nil it will be fetched from the registry server.

type RegistryToolBuilder

type RegistryToolBuilder struct {
	// contains filtered or unexported fields
}

RegistryToolBuilder contains the data and logic needed to create an instance of the registry tool. Don't create instances of this directly, use the NewRegistryTool function instead.

func NewRegistryTool

func NewRegistryTool() *RegistryToolBuilder

NewRegistryTool creates a builder that can then be used to configure and create an instance of the registry tool.

func (*RegistryToolBuilder) Build

func (b *RegistryToolBuilder) Build() (result *RegistryTool, err error)

Build uses the data stored in the buider to create a new instance of the registry tool.

func (*RegistryToolBuilder) SetClient

func (b *RegistryToolBuilder) SetClient(value *Client) *RegistryToolBuilder

SetClient sets the Kubernetes API client that the tool will use to interact with the cluster. This is mandatory.

func (*RegistryToolBuilder) SetConfigName

func (b *RegistryToolBuilder) SetConfigName(value string) *RegistryToolBuilder

SetConfigName sets the name of the image configuration object that will be updated. The default is to use `cluster` and there is usually no reason to change it, as that is the name used by OpenShift. This is intended for use in unit tests where it is convenient to use a different name.

func (*RegistryToolBuilder) SetConfigmapName

func (b *RegistryToolBuilder) SetConfigmapName(value string) *RegistryToolBuilder

SetConfigmapName sets the name of the CA configmap object that will created if it doesn't exist. The default is to use the `registry-cas` and there is usually no reason to change it. This is intended for use in unit tests where it is convenient to use a different name.

func (*RegistryToolBuilder) SetLogger

func (b *RegistryToolBuilder) SetLogger(value logr.Logger) *RegistryToolBuilder

SetLogger sets the logger that the tool will use to write messages to the log. This is mandatory.

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool is an instance of the command line tool. Don't create instances of this directly, use the NewTool function instead.

func ToolFromContext

func ToolFromContext(ctx context.Context) *Tool

ToolFromContext returns the tool from the context. It panics if the given context doesn't contain the tool.

func (*Tool) Console

func (t *Tool) Console() *Console

Console returns the console of the tool.

func (*Tool) Err

func (t *Tool) Err() io.Writer

Err returns the error output stream of the tool.

func (*Tool) In

func (t *Tool) In() io.Reader

In returns the input stream of the tool.

func (*Tool) Out

func (t *Tool) Out() io.Writer

Out returns the output stream of the tool.

func (*Tool) Run

func (t *Tool) Run(ctx context.Context) error

Run rus the tool.

type ToolBuilder

type ToolBuilder struct {
	// contains filtered or unexported fields
}

ToolBuilder contains the data and logic needed to create an instance of the command line tool. Don't create instances of this directly, use the NewTool function instead.

func NewTool

func NewTool() *ToolBuilder

NewTool creates a builder that can then be used to configure and create an instance of the command line tool.

func (*ToolBuilder) AddArg

func (b *ToolBuilder) AddArg(value string) *ToolBuilder

AddArg adds one command line argument.

func (*ToolBuilder) AddArgs

func (b *ToolBuilder) AddArgs(values ...string) *ToolBuilder

AddArgs adds a list of command line arguments.

func (*ToolBuilder) AddCommand

func (b *ToolBuilder) AddCommand(value func() *cobra.Command) *ToolBuilder

AddCommand adds a sub-command.

func (*ToolBuilder) AddCommands

func (b *ToolBuilder) AddCommands(values ...func() *cobra.Command) *ToolBuilder

AddCommands adds a list of sub-commands.

func (*ToolBuilder) Build

func (b *ToolBuilder) Build() (result *Tool, err error)

Build uses the data stored in the buider to create a new instance of the command line tool.

func (*ToolBuilder) SetArgs

func (b *ToolBuilder) SetArgs(values ...string) *ToolBuilder

SetArgs sets the list of command line arguments.

func (*ToolBuilder) SetErr

func (b *ToolBuilder) SetErr(value io.Writer) *ToolBuilder

SetErr sets the standard error output stream. This is mandatory.

func (*ToolBuilder) SetIn

func (b *ToolBuilder) SetIn(value io.Reader) *ToolBuilder

SetIn sets the standard input stream. This is mandatory.

func (*ToolBuilder) SetLogger

func (b *ToolBuilder) SetLogger(value logr.Logger) *ToolBuilder

SetLogger sets the logger that the tool will use to write messages to the log. This is optional, and if not specified a new one will be created that writes JSON messages to a file `ztp.log` file inside the tool cache directory.

func (*ToolBuilder) SetOut

func (b *ToolBuilder) SetOut(value io.Writer) *ToolBuilder

SetOut sets the standard output stream. This is mandatory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL