@@ -65,16 +65,6 @@ func (r *runner) runContainer(image string) error {
65
65
ctx , cancel := context .WithTimeout (context .Background (), time .Second * 30 )
66
66
defer cancel ()
67
67
68
- var (
69
- err error
70
- mounts []mount.Mount
71
- )
72
-
73
- mounts , err = r .mounts (mounts , image )
74
- if err != nil {
75
- return xerrors .Errorf ("failed to assemble mounts: %w" , err )
76
- }
77
-
78
68
projectDir , err := r .projectDir (image )
79
69
if err != nil {
80
70
return err
@@ -122,6 +112,14 @@ func (r *runner) runContainer(image string) error {
122
112
return xerrors .Errorf ("failed to add image defined labels: %w" , err )
123
113
}
124
114
115
+ var mounts []mount.Mount
116
+ mounts = r .addHatMount (mounts , containerConfig .Labels )
117
+
118
+ mounts , err = r .mounts (mounts , image )
119
+ if err != nil {
120
+ return xerrors .Errorf ("failed to assemble mounts: %w" , err )
121
+ }
122
+
125
123
hostConfig := & container.HostConfig {
126
124
Mounts : mounts ,
127
125
NetworkMode : "host" ,
@@ -154,6 +152,20 @@ func (r *runner) runContainer(image string) error {
154
152
return nil
155
153
}
156
154
155
+ // addHatMount mounts the hat into the user's container if they've specified one.
156
+ func (r * runner ) addHatMount (mounts []mount.Mount , labels map [string ]string ) []mount.Mount {
157
+ hatPath , ok := labels [hatLabel ]
158
+ if ! ok {
159
+ return mounts
160
+ }
161
+
162
+ return append (mounts , mount.Mount {
163
+ Type : "bind" ,
164
+ Source : hatPath ,
165
+ Target : "~/.hat" ,
166
+ })
167
+ }
168
+
157
169
func (r * runner ) mounts (mounts []mount.Mount , image string ) ([]mount.Mount , error ) {
158
170
// Mount in VS Code configs.
159
171
mounts = append (mounts , mount.Mount {
0 commit comments