| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "os" | 8 "os" |
| 9 | 9 |
| 10 "github.com/luci/luci-go/common/errors" | 10 "github.com/luci/luci-go/common/errors" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 }.Errorf(a, "Failed to open input stream file.") | 71 }.Errorf(a, "Failed to open input stream file.") |
| 72 return runtimeErrorReturnCode | 72 return runtimeErrorReturnCode |
| 73 } | 73 } |
| 74 streamFile = file | 74 streamFile = file |
| 75 } | 75 } |
| 76 if cmd.stream.Name == "" { | 76 if cmd.stream.Name == "" { |
| 77 cmd.stream.Name = defaultStreamName | 77 cmd.stream.Name = defaultStreamName |
| 78 } | 78 } |
| 79 | 79 |
| 80 // We think everything should work. Configure our Output instance. | 80 // We think everything should work. Configure our Output instance. |
| 81 » output, err := a.configOutput() | 81 » of, err := a.getOutputFactory() |
| 82 » if err != nil { |
| 83 » » log.WithError(err).Errorf(a, "Failed to get output factory insta
nce.") |
| 84 » » return runtimeErrorReturnCode |
| 85 » } |
| 86 » output, err := of.configOutput(a) |
| 82 if err != nil { | 87 if err != nil { |
| 83 log.WithError(err).Errorf(a, "Failed to create output instance."
) | 88 log.WithError(err).Errorf(a, "Failed to create output instance."
) |
| 84 return runtimeErrorReturnCode | 89 return runtimeErrorReturnCode |
| 85 } | 90 } |
| 86 defer output.Close() | 91 defer output.Close() |
| 87 | 92 |
| 88 // Instantiate our Processor. | 93 // Instantiate our Processor. |
| 89 err = a.runWithButler(a, output, func(ctx context.Context, b *butler.But
ler) error { | 94 err = a.runWithButler(a, output, func(ctx context.Context, b *butler.But
ler) error { |
| 90 if err := b.AddStream(streamFile, cmd.stream.properties()); err
!= nil { | 95 if err := b.AddStream(streamFile, cmd.stream.properties()); err
!= nil { |
| 91 return errors.Annotate(err).Reason("failed to add stream
").Err() | 96 return errors.Annotate(err).Reason("failed to add stream
").Err() |
| 92 } | 97 } |
| 93 | 98 |
| 94 b.Activate() | 99 b.Activate() |
| 95 return b.Wait() | 100 return b.Wait() |
| 96 }) | 101 }) |
| 97 if err != nil { | 102 if err != nil { |
| 98 logAnnotatedErr(a, err, "Failed to stream file.") | 103 logAnnotatedErr(a, err, "Failed to stream file.") |
| 99 return runtimeErrorReturnCode | 104 return runtimeErrorReturnCode |
| 100 } | 105 } |
| 101 | 106 |
| 102 return 0 | 107 return 0 |
| 103 } | 108 } |
| OLD | NEW |