cmd/up: disable output list when not a tty + better error handling
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
571b5c8618
commit
efb4ee209e
@ -46,6 +46,10 @@ func ListOutputs(ctx context.Context, st *state.State, all bool) {
|
|||||||
Str("environment", st.Name).
|
Str("environment", st.Name).
|
||||||
Logger()
|
Logger()
|
||||||
|
|
||||||
|
if st.Computed == "" {
|
||||||
|
lg.Fatal().Msg("cannot list environment outputs: please run `dagger up` first")
|
||||||
|
}
|
||||||
|
|
||||||
c, err := client.New(ctx, "", false)
|
c, err := client.New(ctx, "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lg.Fatal().Err(err).Msg("unable to create client")
|
lg.Fatal().Err(err).Msg("unable to create client")
|
||||||
@ -87,7 +91,7 @@ func ListOutputs(ctx context.Context, st *state.State, all bool) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lg.Warn().Err(err).Msg("failed to query environment")
|
lg.Fatal().Err(err).Msg("failed to query environment")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,11 @@ var upCmd = &cobra.Command{
|
|||||||
lg.Fatal().Err(err).Msg("failed to update environment")
|
lg.Fatal().Err(err).Msg("failed to update environment")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !term.IsTerminal(int(os.Stdout.Fd())) {
|
||||||
|
lg.Debug().Msg("not a tty, output list disabled")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
output.ListOutputs(ctx, st, false)
|
output.ListOutputs(ctx, st, false)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ func (e *Environment) ScanInputs(ctx context.Context, mergeUserInputs bool) ([]*
|
|||||||
|
|
||||||
func (e *Environment) ScanOutputs(ctx context.Context) ([]*compiler.Value, error) {
|
func (e *Environment) ScanOutputs(ctx context.Context) ([]*compiler.Value, error) {
|
||||||
if e.state.Computed == "" {
|
if e.state.Computed == "" {
|
||||||
return nil, errors.New("cannot query environment outputs: please run `dagger up` first")
|
return nil, errors.New("environment has been computed yet")
|
||||||
}
|
}
|
||||||
|
|
||||||
src, err := e.prepare(ctx)
|
src, err := e.prepare(ctx)
|
||||||
|
Reference in New Issue
Block a user