()
| 822 | } |
| 823 | |
| 824 | func (b *Builder) getState() ([]byte, error) { |
| 825 | if b.state.orphan { |
| 826 | // Orphan means empty state. |
| 827 | return nil, nil |
| 828 | } |
| 829 | if b.state.explicit != nil { |
| 830 | return *b.state.explicit, nil |
| 831 | } |
| 832 | // Default is to use state from prior build |
| 833 | bld, err := b.getLastBuild() |
| 834 | if xerrors.Is(err, sql.ErrNoRows) { |
| 835 | // last build does not exist, which implies empty state |
| 836 | return nil, nil |
| 837 | } |
| 838 | if err != nil { |
| 839 | return nil, xerrors.Errorf("get last build to get state: %w", err) |
| 840 | } |
| 841 | // nolint: gocritic // Workspace builder needs to read provisioner state for the new build. |
| 842 | state, err := b.store.GetWorkspaceBuildProvisionerStateByID(dbauthz.AsWorkspaceBuilder(b.ctx), bld.ID) |
| 843 | if err != nil { |
| 844 | return nil, xerrors.Errorf("get workspace build provisioner state: %w", err) |
| 845 | } |
| 846 | return state.ProvisionerState, nil |
| 847 | } |
| 848 | |
| 849 | func (b *Builder) getParameters() (names, values []string, err error) { |
| 850 | if b.parameterNames != nil { |
no test coverage detected