File tree Expand file tree Collapse file tree 5 files changed +59
-2
lines changed Expand file tree Collapse file tree 5 files changed +59
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package hostagent
2
2
3
3
import (
4
4
"context"
5
+ "github.com/AkihiroSuda/lima/pkg/limayaml"
5
6
"time"
6
7
7
8
"github.com/AkihiroSuda/sshocker/pkg/ssh"
@@ -120,5 +121,14 @@ Also see "/var/log/cloud-init-output.log" in the guest.
120
121
` ,
121
122
})
122
123
}
124
+ for _ , probe := range a .y .Probes {
125
+ if probe .Mode == limayaml .ProbeModeReadiness {
126
+ req = append (req , requirement {
127
+ description : probe .Description ,
128
+ script : probe .Script ,
129
+ debugHint : probe .Hint ,
130
+ })
131
+ }
132
+ }
123
133
return req
124
134
}
Original file line number Diff line number Diff line change @@ -85,3 +85,17 @@ containerd:
85
85
# set number
86
86
# EOF
87
87
88
+ # probes:
89
+ # # Only `readiness` probes are supported right now.
90
+ # - mode: readiness
91
+ # description: vim to be installed
92
+ # script: |
93
+ # #!/bin/bash
94
+ # set -eux -o pipefail
95
+ # if ! timeout 30s bash -c "until command -v vim; do sleep 3; done"; then
96
+ # echo >&2 "vim is not installed yet"
97
+ # exit 1
98
+ # fi
99
+ # hint: |
100
+ # vim was not installed in the guest. Make sure the package system is working correctly.
101
+ # Also see "/var/log/cloud-init-output.log" in the guest.
Original file line number Diff line number Diff line change 1
1
package limayaml
2
2
3
- import "runtime"
3
+ import (
4
+ "fmt"
5
+ "runtime"
6
+ )
4
7
5
8
func FillDefault (y * LimaYAML ) {
6
9
y .Arch = resolveArch (y .Arch )
@@ -34,6 +37,15 @@ func FillDefault(y *LimaYAML) {
34
37
if y .Containerd .User == nil {
35
38
y .Containerd .User = & []bool {true }[0 ]
36
39
}
40
+ for i := range y .Probes {
41
+ probe := & y .Probes [i ]
42
+ if probe .Mode == "" {
43
+ probe .Mode = ProbeModeReadiness
44
+ }
45
+ if probe .Description == "" {
46
+ probe .Description = fmt .Sprintf ("user probe %d/%d" , i + 1 , len (y .Probes ))
47
+ }
48
+ }
37
49
}
38
50
39
51
func resolveArch (s string ) Arch {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ type LimaYAML struct {
12
12
Video Video `yaml:"video,omitempty"`
13
13
Provision []Provision `yaml:"provision,omitempty"`
14
14
Containerd Containerd `yaml:"containerd,omitempty"`
15
+ Probes []Probe `yaml:"probes,omitempty"`
15
16
}
16
17
17
18
type Arch = string
@@ -62,3 +63,16 @@ type Containerd struct {
62
63
System * bool `yaml:"system,omitempty"`
63
64
User * bool `yaml:"user,omitempty"`
64
65
}
66
+
67
+ type ProbeMode = string
68
+
69
+ const (
70
+ ProbeModeReadiness ProbeMode = "readiness"
71
+ )
72
+
73
+ type Probe struct {
74
+ Mode ProbeMode // default: "readiness"
75
+ Description string
76
+ Script string
77
+ Hint string
78
+ }
Original file line number Diff line number Diff line change @@ -111,6 +111,13 @@ func ValidateRaw(y LimaYAML) error {
111
111
i , ProvisionModeSystem , ProvisionModeUser )
112
112
}
113
113
}
114
-
114
+ for i , p := range y .Probes {
115
+ switch p .Mode {
116
+ case ProbeModeReadiness :
117
+ default :
118
+ return errors .Errorf ("field `probe[%d].mode` can only be %q" ,
119
+ i , ProbeModeReadiness )
120
+ }
121
+ }
115
122
return nil
116
123
}
You can’t perform that action at this time.
0 commit comments