Skip to content

Commit b6c4b6f

Browse files
committed
Try to handle default arguments
1 parent 35e6669 commit b6c4b6f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

config.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ type Config struct {
3030

3131
// Service is the URL and its Env pair
3232
type Service struct {
33-
URL string `json:"url"`
34-
Env Env `json:"env"`
33+
URL string `json:"url"`
34+
Env Env `json:"env"`
35+
Args []string `json:"args"`
3536
}
3637

3738
// Env represents the environment variables needed to request to IAP-protected app
@@ -86,6 +87,7 @@ func (cfg *Config) Create() error {
8687
ClientID: "foobar.apps.googleusercontent.com",
8788
Binary: "curl",
8889
},
90+
Args: []string{},
8991
}}
9092
}
9193

@@ -212,3 +214,13 @@ func (cfg *Config) Register(s Service) error {
212214
w.Write(out.Bytes())
213215
return w.Flush()
214216
}
217+
218+
// GetServiceArgs returns ...
219+
func (cfg *Config) GetServiceArgs(url string) []string {
220+
for _, service := range cfg.Services {
221+
if service.URL == url {
222+
return service.Args
223+
}
224+
}
225+
return []string{}
226+
}

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ func (c CLI) run() int {
154154
authHeader := fmt.Sprintf("Authorization: Bearer %s", token)
155155
args := append(
156156
[]string{"-H", authHeader}, // For IAP
157-
c.args...,
157+
c.cfg.GetServiceArgs(url)...,
158158
)
159+
args = append(args, c.args...)
159160
args = append(args, url)
160161

161162
s := newShell(env.Binary, args)

0 commit comments

Comments
 (0)