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.
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.
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.
Index ¶
- type ComposeManager
- func (cm *ComposeManager) Build(opts commands.DockerComposeBuildOptions) error
- func (cm *ComposeManager) Create(opts commands.DockerComposeCreateOptions) error
- func (cm *ComposeManager) Down(opts commands.DockerComposeDownOptions) error
- func (cm *ComposeManager) Logs(opts commands.DockerComposeLogsOptions) error
- func (c *ComposeManager) PS(opts commands.DockerComposePsOptions) ([]ComposeService, error)
- func (cm *ComposeManager) Pull(opts commands.DockerComposePullOptions) error
- func (cm *ComposeManager) Stop(opts DockerComposeStopOptions) error
- func (cm *ComposeManager) Up(opts commands.DockerComposeUpOptions) error
- type ComposeService
- type DockerComposeCmdError
- type DockerComposeStopOptions
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 ¶
func (cm *ComposeManager) Build(opts commands.DockerComposeBuildOptions) error
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)
}
func (*ComposeManager) Create ¶
func (cm *ComposeManager) Create(opts commands.DockerComposeCreateOptions) error
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)
}
func (*ComposeManager) Down ¶
func (cm *ComposeManager) Down(opts commands.DockerComposeDownOptions) error
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)
}
func (*ComposeManager) Logs ¶
func (cm *ComposeManager) Logs(opts commands.DockerComposeLogsOptions) error
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)
}
func (*ComposeManager) PS ¶
func (c *ComposeManager) PS(opts commands.DockerComposePsOptions) ([]ComposeService, error)
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)
}
func (*ComposeManager) Pull ¶
func (cm *ComposeManager) Pull(opts commands.DockerComposePullOptions) error
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)
}
func (*ComposeManager) Stop ¶
func (cm *ComposeManager) Stop(opts DockerComposeStopOptions) error
Stop runs the Docker Compose 'stop' command for the specified options.
func (*ComposeManager) Up ¶
func (cm *ComposeManager) Up(opts commands.DockerComposeUpOptions) error
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)
}
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.