@@ -704,6 +704,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
704704 PreviousParameterValues : convertRichParameterValues (lastWorkspaceBuildParameters ),
705705 VariableValues : asVariableValues (templateVariables ),
706706 ExternalAuthProviders : externalAuthProviders ,
707+ ReuseTerraformWorkspace : false , // TODO: Toggle based on experiment
707708 Metadata : & sdkproto.Metadata {
708709 CoderUrl : s .AccessURL .String (),
709710 WorkspaceTransition : transition ,
@@ -773,6 +774,11 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
773774 return nil , failJob (err .Error ())
774775 }
775776
777+ templateID := ""
778+ if input .TemplateID .Valid {
779+ templateID = input .TemplateID .UUID .String ()
780+ }
781+
776782 protoJob .Type = & proto.AcquiredJob_TemplateImport_ {
777783 TemplateImport : & proto.AcquiredJob_TemplateImport {
778784 UserVariableValues : convertVariableValues (userVariableValues ),
@@ -781,6 +787,8 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
781787 // There is no owner for a template import, but we can assume
782788 // the "Everyone" group as a placeholder.
783789 WorkspaceOwnerGroups : []string {database .EveryoneGroup },
790+ TemplateId : templateID ,
791+ TemplateVersionId : input .TemplateVersionID .String (),
784792 },
785793 },
786794 }
@@ -3210,6 +3218,10 @@ func auditActionFromTransition(transition database.WorkspaceTransition) database
32103218}
32113219
32123220type TemplateVersionImportJob struct {
3221+ // TemplateID is not guaranteed to be set. Template versions can be created
3222+ // without being associated with a template. Resulting in a template id of
3223+ // `uuid.Nil`
3224+ TemplateID uuid.NullUUID `json:"template_id"`
32133225 TemplateVersionID uuid.UUID `json:"template_version_id"`
32143226 UserVariableValues []codersdk.VariableValue `json:"user_variable_values"`
32153227}
0 commit comments