| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| package main |
| |
| import ( |
| "context" |
| "flag" |
| "log" |
| "os" |
| "syscall" |
| |
| "go.fuchsia.dev/infra/secrets" |
| "go.fuchsia.dev/tools/command" |
| "go.fuchsia.dev/tools/runner" |
| ) |
| |
| const usage = `usage: secretshim [command] |
| |
| Starts the secrets server before running the provided command. |
| ` |
| |
| func main() { |
| flag.Parse() |
| args := flag.Args() |
| if len(args) == 0 { |
| log.Fatal("must provide command to run") |
| } |
| |
| ctx := command.CancelOnSignals(context.Background(), syscall.SIGTERM) |
| |
| // The secrets server will start up iff LUCI_CONTEXT is set and contains secret bytes. |
| secrets.StartSecretsServer(ctx, 8081) |
| |
| runner := runner.SubprocessRunner{} |
| if err := runner.Run(ctx, args, os.Stdout, os.Stderr); err != nil { |
| log.Fatal(err) |
| } |
| } |