File tree 2 files changed +29
-0
lines changed 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,15 @@ func (optSet *OptionSet) ParseEnv(vs []EnvVar) error {
262
262
}
263
263
264
264
envVal , ok := envs [opt .Env ]
265
+ if ! ok {
266
+ // Homebrew strips all environment variables that do not start with `HOMEBREW_`.
267
+ // This prevented using brew to invoke the Coder agent, because the environment
268
+ // variables to not get passed down.
269
+ //
270
+ // A customer wanted to use their custom tap inside a workspace, which was failing
271
+ // because the agent lacked the environment variables to authenticate with Git.
272
+ envVal , ok = envs [`HOMEBREW_` + opt .Env ]
273
+ }
265
274
// Currently, empty values are treated as if the environment variable is
266
275
// unset. This behavior is technically not correct as there is now no
267
276
// way for a user to change a Default value to an empty string from
Original file line number Diff line number Diff line change @@ -206,6 +206,26 @@ func TestOptionSet_ParseEnv(t *testing.T) {
206
206
require .NoError (t , err )
207
207
require .EqualValues (t , expected , actual .Value )
208
208
})
209
+
210
+ t .Run ("Homebrew" , func (t * testing.T ) {
211
+ t .Parallel ()
212
+
213
+ var agentToken clibase.String
214
+
215
+ os := clibase.OptionSet {
216
+ clibase.Option {
217
+ Name : "Agent Token" ,
218
+ Value : & agentToken ,
219
+ Env : "AGENT_TOKEN" ,
220
+ },
221
+ }
222
+
223
+ err := os .ParseEnv ([]clibase.EnvVar {
224
+ {Name : "HOMEBREW_AGENT_TOKEN" , Value : "foo" },
225
+ })
226
+ require .NoError (t , err )
227
+ require .EqualValues (t , "foo" , agentToken )
228
+ })
209
229
}
210
230
211
231
func TestOptionSet_JsonMarshal (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments