mirror of https://github.com/databricks/cli.git
Prefix errors with additional context during deploy
This commit is contained in:
parent
fe96f80de1
commit
41fb73222f
|
@ -46,12 +46,10 @@ func (m *release) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
|
|||
|
||||
log.Infof(ctx, "Releasing deployment lock")
|
||||
switch m.goal {
|
||||
case GoalDeploy:
|
||||
return diag.FromErr(b.Locker.Unlock(ctx))
|
||||
case GoalBind, GoalUnbind:
|
||||
return diag.FromErr(b.Locker.Unlock(ctx))
|
||||
case GoalDeploy, GoalBind, GoalUnbind:
|
||||
return diag.FromErrPrefix("failed to unlock: ", b.Locker.Unlock(ctx))
|
||||
case GoalDestroy:
|
||||
return diag.FromErr(b.Locker.Unlock(ctx, locker.AllowLockFileNotExist))
|
||||
return diag.FromErrPrefix("failed to unlock: ", b.Locker.Unlock(ctx, locker.AllowLockFileNotExist))
|
||||
default:
|
||||
return diag.Errorf("unknown goal for lock release: %s", m.goal)
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ func setPermissions(ctx context.Context, w workspace.WorkspaceInterface, path st
|
|||
|
||||
obj, err := w.GetStatusByPath(ctx, path)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("GetStatusByPath(%s) failed: %w", path, err)
|
||||
}
|
||||
|
||||
_, err = w.SetPermissions(ctx, workspace.WorkspaceObjectPermissionsRequest{
|
||||
|
@ -84,7 +84,7 @@ func setPermissions(ctx context.Context, w workspace.WorkspaceInterface, path st
|
|||
AccessControlList: permissions,
|
||||
})
|
||||
|
||||
return err
|
||||
return fmt.Errorf("SetPermissions(%d) failed: %w", obj.ObjectId, err)
|
||||
}
|
||||
|
||||
func GetWorkspaceObjectPermissionLevel(bundlePermission string) (workspace.WorkspaceObjectPermissionLevel, error) {
|
||||
|
|
|
@ -53,6 +53,19 @@ func FromErr(err error) Diagnostics {
|
|||
}
|
||||
}
|
||||
|
||||
// FromErrPrefix returns a new error diagnostic from the specified error, if any.
|
||||
func FromErrPrefix(prefix string, err error) Diagnostics {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return []Diagnostic{
|
||||
{
|
||||
Severity: Error,
|
||||
Summary: prefix + err.Error(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// FromErr returns a new warning diagnostic from the specified error, if any.
|
||||
func WarningFromErr(err error) Diagnostics {
|
||||
if err == nil {
|
||||
|
|
Loading…
Reference in New Issue