@@ -623,8 +623,8 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
623
623
validErrs = append (validErrs , codersdk.ValidationError {Field : "time_til_dormant_autodelete_ms" , Detail : "Value must be at least one minute." })
624
624
}
625
625
maxPortShareLevel := template .MaxPortSharingLevel
626
- if req .MaxPortShareLevel != nil && * req .MaxPortShareLevel != codersdk . WorkspaceAgentPortShareLevel ( maxPortShareLevel ) {
627
- err := portSharer .ValidateTemplateMaxPortSharingLevel (* req .MaxPortShareLevel )
626
+ if req .MaxPortShareLevel != nil && * req .MaxPortShareLevel != portSharer . ConvertMaxLevel ( template . MaxPortSharingLevel ) {
627
+ err := portSharer .ValidateTemplateMaxLevel (* req .MaxPortShareLevel )
628
628
if err != nil {
629
629
validErrs = append (validErrs , codersdk.ValidationError {Field : "max_port_sharing_level" , Detail : err .Error ()})
630
630
} else {
@@ -857,6 +857,9 @@ func (api *API) convertTemplate(
857
857
autostopRequirementWeeks = 1
858
858
}
859
859
860
+ portSharer := * (api .PortSharer .Load ())
861
+ maxPortShareLevel := portSharer .ConvertMaxLevel (template .MaxPortSharingLevel )
862
+
860
863
return codersdk.Template {
861
864
ID : template .ID ,
862
865
CreatedAt : template .CreatedAt ,
@@ -891,6 +894,6 @@ func (api *API) convertTemplate(
891
894
RequireActiveVersion : templateAccessControl .RequireActiveVersion ,
892
895
Deprecated : templateAccessControl .IsDeprecated (),
893
896
DeprecationMessage : templateAccessControl .Deprecated ,
894
- MaxPortShareLevel : codersdk . WorkspaceAgentPortShareLevel ( template . MaxPortSharingLevel ) ,
897
+ MaxPortShareLevel : maxPortShareLevel ,
895
898
}
896
899
}
0 commit comments