firewaller

package
v0.0.0-...-3d086f3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: AGPL-3.0 Imports: 35 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

func Manifold(cfg ManifoldConfig) dependency.Manifold

Manifold returns a Manifold that encapsulates the firewaller worker.

func NewFirewaller

func NewFirewaller(cfg Config) (worker.Worker, error)

NewFirewaller returns a new Firewaller.

func NewRemoteRelationsFacade

func NewRemoteRelationsFacade(apiCaller base.APICaller) *remoterelations.Client

NewRemoteRelationsFacade creates a remote relations API facade.

func NewWorker

func NewWorker(cfg Config) (worker.Worker, error)

NewWorker creates a firewaller worker.

Types

type Config

type Config struct {
	ModelUUID              string
	Mode                   string
	FirewallerAPI          FirewallerAPI
	RemoteRelationsApi     *remoterelations.Client
	EnvironFirewaller      EnvironFirewaller
	EnvironModelFirewaller EnvironModelFirewaller
	EnvironInstances       EnvironInstances
	EnvironIPV6CIDRSupport bool

	NewCrossModelFacadeFunc newCrossModelFacadeFunc

	Clock  clock.Clock
	Logger Logger

	CredentialAPI common.CredentialAPI

	// TODO: (jack-w-shaw) Drop these once we move tests to mocks based
	// WatchMachineNotify is called when the Firewaller starts watching the
	// machine with the given tag (manual machines aren't watched). This
	// should only be used for testing.
	WatchMachineNotify func(tag names.MachineTag)
	// FlushModelNotify is called when the Firewaller flushes it's model.
	// This should only be used for testing
	FlushModelNotify func()
}

Config defines the operation of a Worker.

func (Config) Validate

func (cfg Config) Validate() error

Validate returns an error if cfg cannot drive a Worker.

type CrossModelFirewallerFacade

type CrossModelFirewallerFacade interface {
	PublishIngressNetworkChange(params.IngressNetworksChangeEvent) error
	WatchEgressAddressesForRelation(details params.RemoteEntityArg) (watcher.StringsWatcher, error)
}

CrossModelFirewallerFacade exposes firewaller functionality on the remote offering model to a worker.

type CrossModelFirewallerFacadeCloser

type CrossModelFirewallerFacadeCloser interface {
	io.Closer
	CrossModelFirewallerFacade
}

RemoteFirewallerAPICloser implements CrossModelFirewallerFacade and adds a Close() method.

type EnvironFirewaller

type EnvironFirewaller interface {
	environs.Firewaller
}

EnvironFirewaller defines methods to allow the worker to perform firewall operations (open/close ports) on a Juju global firewall.

type EnvironInstances

type EnvironInstances interface {
	Instances(ctx context.ProviderCallContext, ids []instance.Id) ([]instances.Instance, error)
}

EnvironInstances defines methods to allow the worker to perform operations on instances in a Juju cloud environment.

type EnvironModelFirewaller

type EnvironModelFirewaller interface {
	models.ModelFirewaller
}

EnvironModelFirewaller defines methods to allow the worker to perform firewall operations (open/close port) on a Juju model firewall.

type Firewaller

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

Firewaller watches the state for port ranges opened or closed on machines and reflects those changes onto the backing environment. Uses Firewaller API V1.

func (*Firewaller) Kill

func (fw *Firewaller) Kill()

Kill is part of the worker.Worker interface.

func (*Firewaller) Wait

func (fw *Firewaller) Wait() error

Wait is part of the worker.Worker interface.

type FirewallerAPI

type FirewallerAPI interface {
	WatchModelMachines() (watcher.StringsWatcher, error)
	WatchOpenedPorts() (watcher.StringsWatcher, error)
	WatchModelFirewallRules() (watcher.NotifyWatcher, error)
	ModelFirewallRules() (firewall.IngressRules, error)
	ModelConfig() (*config.Config, error)
	Machine(tag names.MachineTag) (*firewaller.Machine, error)
	Unit(tag names.UnitTag) (*firewaller.Unit, error)
	Relation(tag names.RelationTag) (*firewaller.Relation, error)
	WatchEgressAddressesForRelation(tag names.RelationTag) (watcher.StringsWatcher, error)
	WatchIngressAddressesForRelation(tag names.RelationTag) (watcher.StringsWatcher, error)
	ControllerAPIInfoForModel(modelUUID string) (*api.Info, error)
	MacaroonForRelation(relationKey string) (*macaroon.Macaroon, error)
	SetRelationStatus(relationKey string, status relation.Status, message string) error
	AllSpaceInfos() (network.SpaceInfos, error)
	WatchSubnets() (watcher.StringsWatcher, error)
}

FirewallerAPI exposes functionality off the firewaller API facade to a worker.

func NewFirewallerFacade

func NewFirewallerFacade(apiCaller base.APICaller) (FirewallerAPI, error)

NewFirewallerFacade creates a firewaller API facade.

type Logger

type Logger interface {
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Warningf(string, ...interface{})
	Infof(string, ...interface{})
	Errorf(string, ...interface{})
}

Logger represents the methods used by the worker to log details.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName     string
	APICallerName string
	EnvironName   string
	Logger        Logger

	NewControllerConnection      apicaller.NewExternalControllerConnectionFunc
	NewRemoteRelationsFacade     func(base.APICaller) *remoterelations.Client
	NewFirewallerFacade          func(base.APICaller) (FirewallerAPI, error)
	NewFirewallerWorker          func(Config) (worker.Worker, error)
	NewCredentialValidatorFacade func(base.APICaller) (common.CredentialAPI, error)
}

ManifoldConfig describes the resources used by the firewaller worker.

func (ManifoldConfig) Validate

func (cfg ManifoldConfig) Validate() error

Validate is called by start to check for bad configuration.

Jump to

Keyboard shortcuts

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