provider

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Docker

type Docker struct {
	DockerClient    DockerClient
	Excludes        []string
	AutoAPI         bool
	APIPrefix       string
	RefreshInterval time.Duration
}

Docker provider watches compatible for stop/start changes from containers and maps by default from ^/api/%s/(.*) to http://%s:%d/$1, i.e. http://example.com/api/my_container/something will be mapped to http://172.17.42.1:8080/something. Ip will be the internal ip of the container and port exposed in the Dockerfile. Alternatively labels can alter this. reproxy.route sets source route, and reproxy.dest sets the destination. Optional reproxy.server enforces match by server name (hostname) and reproxy.ping sets the health check url Labels can be presented multiple times with a numeric suffix to provide multiple matches for a single container i.e. reproxy.1.server=example.com, reproxy.1.port=12345 and so on

func (*Docker) Events

func (d *Docker) Events(ctx context.Context) (res <-chan discovery.ProviderID)

Events gets eventsCh with all containers-related docker events events

func (*Docker) List

func (d *Docker) List() ([]discovery.URLMapper, error)

List all containers and make url mappers If AutoAPI enabled all each container and set all params, if not - allow only container with reproxy.* labels

type DockerClient

type DockerClient interface {
	ListContainers() ([]containerInfo, error)
}

DockerClient defines interface listing containers and subscribing to events

func NewDockerClient added in v0.3.0

func NewDockerClient(host, network string) DockerClient

NewDockerClient constructs docker client for given host and network

type DockerClientMock

type DockerClientMock struct {
	// ListContainersFunc mocks the ListContainers method.
	ListContainersFunc func() ([]containerInfo, error)
	// contains filtered or unexported fields
}

DockerClientMock is a mock implementation of DockerClient.

func TestSomethingThatUsesDockerClient(t *testing.T) {

	// make and configure a mocked DockerClient
	mockedDockerClient := &DockerClientMock{
		ListContainersFunc: func() ([]containerInfo, error) {
			panic("mock out the ListContainers method")
		},
	}

	// use mockedDockerClient in code that requires DockerClient
	// and then make assertions.

}

func (*DockerClientMock) ListContainers

func (mock *DockerClientMock) ListContainers() ([]containerInfo, error)

ListContainers calls ListContainersFunc.

func (*DockerClientMock) ListContainersCalls

func (mock *DockerClientMock) ListContainersCalls() []struct {
}

ListContainersCalls gets all the calls that were made to ListContainers. Check the length with:

len(mockedDockerClient.ListContainersCalls())

type File

type File struct {
	FileName      string
	CheckInterval time.Duration
	Delay         time.Duration
}

File implements file-based provider, defined with yaml file

func (*File) Events

func (d *File) Events(ctx context.Context) <-chan discovery.ProviderID

Events returns channel updating on file change only

func (*File) List

func (d *File) List() (res []discovery.URLMapper, err error)

List all src dst pairs

type Static

type Static struct {
	Rules []string // each rule is 4 elements comma separated - server,source_url,destination,ping
}

Static provider, rules are server,source_url,destination[,ping]

func (*Static) Events

func (s *Static) Events(_ context.Context) <-chan discovery.ProviderID

Events returns channel updating once

func (*Static) List

func (s *Static) List() (res []discovery.URLMapper, err error)

List all src dst pairs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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