This repository has been archived by the owner on Feb 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
/
install.go
85 lines (76 loc) · 1.89 KB
/
install.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
79
80
81
82
83
84
85
package compose
import (
"context"
"io"
"os"
"os/exec"
"time"
"github.com/docker/compose-on-kubernetes/api/constants"
"github.com/docker/compose-on-kubernetes/install"
"github.com/docker/compose-on-kubernetes/internal/e2e/cluster"
"github.com/docker/compose-on-kubernetes/internal/e2e/wait"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/rest"
)
// Install installs the compose api extension
func Install(config *rest.Config, ns, tag, pullSecret string) (func(), error) {
_, deleteNs, err := cluster.CreateNamespace(config, config, ns)
if err != nil {
return nil, err
}
err = install.Uninstall(config, ns, false)
if err != nil {
return nil, err
}
err = install.WaitNPods(config, ns, 0, install.TimeoutDefault)
if err != nil {
return nil, err
}
err = install.Unsafe(context.Background(), config, install.UnsafeOptions{
OptionsCommon: install.OptionsCommon{
Namespace: ns,
Tag: tag,
PullSecret: pullSecret,
ReconciliationInterval: constants.DefaultFullSyncInterval,
HealthzCheckPort: 8080,
},
Coverage: true,
})
if err != nil {
return nil, err
}
err = install.WaitNPods(config, ns, 2, 2*time.Minute)
if err != nil {
return nil, err
}
err = wait.For(30, func() (bool, error) {
return install.IsRunning(config)
})
if err != nil {
return nil, err
}
cleanup := func() {
{
cmd := exec.Command("./retrieve-coverage")
stdout, err := cmd.StdoutPipe()
if err != nil {
log.Errorf("Unable to retrieve stdout: %s", err)
} else {
go io.Copy(os.Stdout, stdout)
}
stderr, err := cmd.StderrPipe()
if err != nil {
log.Errorf("Unable to retrieve stderr: %s", err)
} else {
go io.Copy(os.Stderr, stderr)
}
err = cmd.Run()
if err != nil {
log.Errorf("Unable to retrieve coverage: %s", err)
}
}
install.Uninstall(config, ns, false)
deleteNs()
}
return cleanup, nil
}