docker

package
v0.0.0-...-af8a533 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Copyright 2020 The Matrix.org Foundation C.I.C.

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.

Copyright 2020 The Matrix.org Foundation C.I.C.

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.

Index

Constants

This section is empty.

Variables

View Source
var (
	// HostnameRunningComplement is the hostname of Complement from the perspective of a Homeserver.
	HostnameRunningComplement = "host.docker.internal"
	// HostnameRunningDocker is the hostname of the docker daemon from the perspective of Complement.
	HostnameRunningDocker = "localhost"
)

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Config         *config.Complement
	CSAPIPort      int
	FederationPort int
	Docker         *client.Client
}

func NewBuilder

func NewBuilder(cfg *config.Complement) (*Builder, error)

func (*Builder) Cleanup

func (d *Builder) Cleanup()

func (*Builder) ConstructBlueprints

func (d *Builder) ConstructBlueprints(bs []b.Blueprint) error

func (*Builder) ConstructBlueprintsIfNotExist

func (d *Builder) ConstructBlueprintsIfNotExist(bs []b.Blueprint) error

type Deployer

type Deployer struct {
	DeployNamespace string
	Docker          *client.Client
	Counter         int
	// contains filtered or unexported fields
}

func NewDeployer

func NewDeployer(deployNamespace string, cfg *config.Complement) (*Deployer, error)

func (*Deployer) Deploy

func (d *Deployer) Deploy(ctx context.Context, blueprintName string) (*Deployment, error)

func (*Deployer) Destroy

func (d *Deployer) Destroy(dep *Deployment, printServerLogs bool)

Destroy a deployment. This will kill all running containers.

type Deployment

type Deployment struct {
	// The Deployer which was responsible for this deployment
	Deployer *Deployer
	// The name of the deployed blueprint
	BlueprintName string
	// A map of HS name to a HomeserverDeployment
	HS map[string]HomeserverDeployment
}

Deployment is the complete instantiation of a Blueprint, with running containers for each homeserver in the Blueprint.

func (*Deployment) Client

func (d *Deployment) Client(t *testing.T, hsName, userID string) *client.CSAPI

Client returns a CSAPI client targeting the given hsName, using the access token for the given userID. Fails the test if the hsName is not found. Returns an unauthenticated client if userID is "", fails the test if the userID is otherwise not found.

func (*Deployment) Destroy

func (d *Deployment) Destroy(t *testing.T)

Destroy the entire deployment. Destroys all running containers. If `printServerLogs` is true, will print container logs before killing the container.

func (*Deployment) RegisterUser

func (d *Deployment) RegisterUser(t *testing.T, hsName, localpart, password string) *client.CSAPI

RegisterUser within a homeserver and return an authenticatedClient, Fails the test if the hsName is not found.

type HomeserverDeployment

type HomeserverDeployment struct {
	BaseURL             string            // e.g http://localhost:38646
	FedBaseURL          string            // e.g https://localhost:48373
	ContainerID         string            // e.g 10de45efba
	AccessTokens        map[string]string // e.g { "@alice:hs1": "myAcc3ssT0ken" }
	ApplicationServices map[string]string // e.g { "my-as-id": "id: xxx\nas_token: xxx ..."} }
}

HomeserverDeployment represents a running homeserver in a container.

type RoundTripper

type RoundTripper struct {
	Deployment *Deployment
}

RoundTripper is a round tripper that maps https://hs1 to the federation port of the container e.g https://localhost:35352

func (*RoundTripper) RoundTrip

func (t *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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