@@ -62,16 +62,6 @@ func (r *runner) runContainer(image string) error {
62
62
ctx , cancel := context .WithTimeout (context .Background (), time .Second * 30 )
63
63
defer cancel ()
64
64
65
- var (
66
- err error
67
- mounts []mount.Mount
68
- )
69
-
70
- mounts , err = r .mounts (mounts , image )
71
- if err != nil {
72
- return xerrors .Errorf ("failed to assemble mounts: %w" , err )
73
- }
74
-
75
65
projectDir , err := r .projectDir (image )
76
66
if err != nil {
77
67
return err
@@ -116,6 +106,14 @@ func (r *runner) runContainer(image string) error {
116
106
return xerrors .Errorf ("failed to add image defined labels: %w" , err )
117
107
}
118
108
109
+ var mounts []mount.Mount
110
+ mounts = r .addHatMount (mounts , containerConfig .Labels )
111
+
112
+ mounts , err = r .mounts (mounts , image )
113
+ if err != nil {
114
+ return xerrors .Errorf ("failed to assemble mounts: %w" , err )
115
+ }
116
+
119
117
hostConfig := & container.HostConfig {
120
118
Mounts : mounts ,
121
119
NetworkMode : "host" ,
@@ -138,6 +136,20 @@ func (r *runner) runContainer(image string) error {
138
136
return nil
139
137
}
140
138
139
+ // addHatMount mounts the hat into the user's container if they've specified one.
140
+ func (r * runner ) addHatMount (mounts []mount.Mount , labels map [string ]string ) []mount.Mount {
141
+ hatPath , ok := labels [hatLabel ]
142
+ if ! ok {
143
+ return mounts
144
+ }
145
+
146
+ return append (mounts , mount.Mount {
147
+ Type : "bind" ,
148
+ Source : hatPath ,
149
+ Target : "~/.hat" ,
150
+ })
151
+ }
152
+
141
153
func (r * runner ) mounts (mounts []mount.Mount , image string ) ([]mount.Mount , error ) {
142
154
// Mount in VS Code configs.
143
155
mounts = append (mounts , mount.Mount {
0 commit comments