verifyNoLegacyParameters verifies that initiator can't start the workspace build if it uses legacy parameters (database.ParameterSchemas).
()
| 1030 | // verifyNoLegacyParameters verifies that initiator can't start the workspace build |
| 1031 | // if it uses legacy parameters (database.ParameterSchemas). |
| 1032 | func (b *Builder) verifyNoLegacyParameters() error { |
| 1033 | if b.verifyNoLegacyParametersOnce { |
| 1034 | return nil |
| 1035 | } |
| 1036 | b.verifyNoLegacyParametersOnce = true |
| 1037 | |
| 1038 | // Block starting the workspace with legacy parameters. |
| 1039 | if b.trans != database.WorkspaceTransitionStart { |
| 1040 | return nil |
| 1041 | } |
| 1042 | |
| 1043 | templateVersionJob, err := b.getTemplateVersionJob() |
| 1044 | if err != nil { |
| 1045 | return xerrors.Errorf("failed to fetch template version job: %w", err) |
| 1046 | } |
| 1047 | |
| 1048 | parameterSchemas, err := b.store.GetParameterSchemasByJobID(b.ctx, templateVersionJob.ID) |
| 1049 | if xerrors.Is(err, sql.ErrNoRows) { |
| 1050 | return nil |
| 1051 | } |
| 1052 | if err != nil { |
| 1053 | return xerrors.Errorf("failed to get parameter schemas: %w", err) |
| 1054 | } |
| 1055 | |
| 1056 | if len(parameterSchemas) > 0 { |
| 1057 | return xerrors.Errorf("Legacy parameters in use on this version are not supported anymore. Contact your administrator for assistance.") |
| 1058 | } |
| 1059 | return nil |
| 1060 | } |
| 1061 | |
| 1062 | func (b *Builder) getLastBuildJob() (*database.ProvisionerJob, error) { |
| 1063 | if b.lastBuildJob != nil { |
no test coverage detected