-
Notifications
You must be signed in to change notification settings - Fork 244
/
adapter.go
78 lines (61 loc) · 2.46 KB
/
adapter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package docker
import (
versionsCommon "github.com/openshift/odo/pkg/devfile/parser/data/common"
"github.com/openshift/odo/pkg/machineoutput"
"io"
"github.com/openshift/odo/pkg/devfile/adapters/common"
"github.com/openshift/odo/pkg/devfile/adapters/docker/component"
"github.com/openshift/odo/pkg/lclient"
"github.com/pkg/errors"
)
// Adapter maps Devfiles to Docker resources and actions
type Adapter struct {
componentAdapter common.ComponentAdapter
}
// New instantiates a Docker adapter
func New(adapterContext common.AdapterContext, client lclient.Client) Adapter {
compAdapter := component.New(adapterContext, client)
return Adapter{
componentAdapter: compAdapter,
}
}
// Push creates Docker resources that correspond to the devfile if they don't already exist
func (d Adapter) Push(parameters common.PushParameters) error {
err := d.componentAdapter.Push(parameters)
if err != nil {
return errors.Wrap(err, "Failed to create the component")
}
return nil
}
// DoesComponentExist returns true if a component with the specified name exists
func (d Adapter) DoesComponentExist(cmpName string) (bool, error) {
return d.componentAdapter.DoesComponentExist(cmpName)
}
// Delete attempts to delete the component with the specified labels, returning an error if it fails
func (d Adapter) Delete(labels map[string]string, show bool) error {
return d.componentAdapter.Delete(labels, show)
}
// Test runs devfile test command
func (d Adapter) Test(testCmd string, show bool) error {
return d.componentAdapter.Test(testCmd, show)
}
// Log show logs from component
func (d Adapter) Log(follow, debug bool) (io.ReadCloser, error) {
return d.componentAdapter.Log(follow, debug)
}
// Exec executes a command in the component
func (d Adapter) Exec(command []string) error {
return d.componentAdapter.Exec(command)
}
func (d Adapter) ExecCMDInContainer(info common.ComponentInfo, cmd []string, stdOut io.Writer, stdErr io.Writer, stdIn io.Reader, show bool) error {
return d.componentAdapter.ExecCMDInContainer(info, cmd, stdOut, stdErr, stdIn, show)
}
func (d Adapter) Logger() machineoutput.MachineEventLoggingClient {
return d.componentAdapter.Logger()
}
func (d Adapter) ComponentInfo(command versionsCommon.DevfileCommand) (common.ComponentInfo, error) {
return d.componentAdapter.ComponentInfo(command)
}
func (d Adapter) SupervisorComponentInfo(command versionsCommon.DevfileCommand) (common.ComponentInfo, error) {
return d.componentAdapter.SupervisorComponentInfo(command)
}