compose

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2022 Nethermind

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.

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.

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComposeManager

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

ComposeManager manages Docker Compose operations.

func NewComposeManager

func NewComposeManager(runner commands.CommandRunner) *ComposeManager

NewComposeManager creates a new instance of ComposeManager.

func (*ComposeManager) Build

Build runs the Docker Compose 'build' command for the specified options.

Example
package main

import (
	"github.com/NethermindEth/sedge/internal/compose"
	"github.com/NethermindEth/sedge/internal/pkg/commands"
)

func main() {
	// Create a new CMDRunner with admin privileges
	cmdRunner := commands.NewCMDRunner(commands.CMDRunnerOptions{RunAsAdmin: true})

	// Create a new ComposeManager with the CMDRunner
	manager := compose.NewComposeManager(cmdRunner)

	// Define the options for the Docker Compose Build command
	opts := commands.DockerComposeBuildOptions{
		Path:     "/path/to/docker-compose.yml",
		Services: []string{"service1", "service2"},
	}

	// Run the Docker Compose Build command
	manager.Build(opts)
}
Output:

func (*ComposeManager) Create

Create runs the Docker Compose 'create' command for the specified options.

Example
package main

import (
	"github.com/NethermindEth/sedge/internal/compose"
	"github.com/NethermindEth/sedge/internal/pkg/commands"
)

func main() {
	// Create a new CMDRunner with admin privileges
	cmdRunner := commands.NewCMDRunner(commands.CMDRunnerOptions{RunAsAdmin: true})

	// Create a new ComposeManager with the CMDRunner
	manager := compose.NewComposeManager(cmdRunner)

	// Define the options for the Docker Compose Create command
	opts := commands.DockerComposeCreateOptions{
		Path:     "/path/to/docker-compose.yml",
		Services: []string{"service1", "service2"},
	}

	// Run the Docker Compose Create command
	manager.Create(opts)
}
Output:

func (*ComposeManager) Down

Down runs the Docker Compose 'down' command for the specified options.

Example
package main

import (
	"github.com/NethermindEth/sedge/internal/compose"
	"github.com/NethermindEth/sedge/internal/pkg/commands"
)

func main() {
	// Create a new CMDRunner with admin privileges
	cmdRunner := commands.NewCMDRunner(commands.CMDRunnerOptions{RunAsAdmin: true})

	// Create a new ComposeManager with the CMDRunner
	manager := compose.NewComposeManager(cmdRunner)

	// Define the options for the Docker Compose Down command
	opts := commands.DockerComposeDownOptions{
		Path: "/path/to/docker-compose.yml",
	}

	// Run the Docker Compose Down command
	manager.Down(opts)
}
Output:

func (*ComposeManager) Logs

Logs runs the Docker Compose 'logs' command for the specified options.

Example
package main

import (
	"github.com/NethermindEth/sedge/internal/compose"
	"github.com/NethermindEth/sedge/internal/pkg/commands"
)

func main() {
	// Create a new CMDRunner with admin privileges
	cmdRunner := commands.NewCMDRunner(commands.CMDRunnerOptions{RunAsAdmin: true})

	// Create a new ComposeManager with the CMDRunner
	manager := compose.NewComposeManager(cmdRunner)

	// Define the options for the Docker Compose Logs command
	opts := commands.DockerComposeLogsOptions{
		Path:     "/path/to/docker-compose.yml",
		Services: []string{"service1", "service2"},
		Follow:   true,
		Tail:     10,
	}

	// Run the Docker Compose Logs command
	manager.Logs(opts)
}
Output:

func (*ComposeManager) PS

PS runs the Docker Compose 'ps' command for the specified options and returns the list of services.

Example
package main

import (
	"github.com/NethermindEth/sedge/internal/compose"
	"github.com/NethermindEth/sedge/internal/pkg/commands"
)

func main() {
	// Create a new CMDRunner with admin privileges
	cmdRunner := commands.NewCMDRunner(commands.CMDRunnerOptions{RunAsAdmin: true})

	// Create a new ComposeManager with the CMDRunner
	manager := compose.NewComposeManager(cmdRunner)

	// Define the options for the Docker Compose PS command
	opts := commands.DockerComposePsOptions{
		Path:          "/path/to/docker-compose.yml",
		Services:      true,
		Quiet:         true,
		FilterRunning: true,
		ServiceName:   "service1",
	}

	// Run the Docker Compose PS command
	manager.PS(opts)
}
Output:

func (*ComposeManager) Pull

Pull runs the Docker Compose 'pull' command for the specified options.

Example
package main

import (
	"github.com/NethermindEth/sedge/internal/compose"
	"github.com/NethermindEth/sedge/internal/pkg/commands"
)

func main() {
	// Create a new CMDRunner with admin privileges
	cmdRunner := commands.NewCMDRunner(commands.CMDRunnerOptions{RunAsAdmin: true})

	// Create a new ComposeManager with the CMDRunner
	manager := compose.NewComposeManager(cmdRunner)

	// Define the options for the Docker Compose Pull command
	opts := commands.DockerComposePullOptions{
		Path:     "/path/to/docker-compose.yml",
		Services: []string{"service1", "service2"},
	}

	// Run the Docker Compose Pull command
	manager.Pull(opts)
}
Output:

func (*ComposeManager) Stop

Stop runs the Docker Compose 'stop' command for the specified options.

func (*ComposeManager) Up

Up runs the Docker Compose 'up' command for the specified options.

Example
package main

import (
	"github.com/NethermindEth/sedge/internal/compose"
	"github.com/NethermindEth/sedge/internal/pkg/commands"
)

func main() {
	// Create a new CMDRunner with admin privileges
	cmdRunner := commands.NewCMDRunner(commands.CMDRunnerOptions{RunAsAdmin: true})

	// Create a new ComposeManager with the CMDRunner
	manager := compose.NewComposeManager(cmdRunner)

	// Define the options for the Docker Compose Up command
	opts := commands.DockerComposeUpOptions{
		Path:     "/path/to/docker-compose.yml",
		Services: []string{"service1", "service2"},
	}

	// Run the Docker Compose Up command
	manager.Up(opts)
}
Output:

type ComposeService

type ComposeService struct {
	// Id is the ID of the container.
	Id string `json:"ID"`
	// Service is the name of the service.
	Service string `json:"Service"`
	// Name is the name of the container.
	Name string `json:"Name"`
	// State is the state of the container.
	State string `json:"State"`
}

ComposeService defines the structure of a service in the output of the 'docker compose ps' command.

type DockerComposeCmdError

type DockerComposeCmdError struct {
	Cmd string
}

DockerComposeCmdError represents an error that occurs when running a Docker Compose command.

func (DockerComposeCmdError) Error

func (e DockerComposeCmdError) Error() string

Error returns a string representation of the DockerComposeCmdError.

type DockerComposeStopOptions

type DockerComposeStopOptions struct {
	// Path specifies the location of the docker-compose.yaml file.
	Path string
}

DockerComposeStopOptions defines the options for the 'docker compose stop' command.

Jump to

Keyboard shortcuts

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