(millis *int64, templateDefault time.Duration)
| 2946 | } |
| 2947 | |
| 2948 | func validWorkspaceTTLMillis(millis *int64, templateDefault time.Duration) (sql.NullInt64, error) { |
| 2949 | if ptr.NilOrZero(millis) { |
| 2950 | if templateDefault == 0 { |
| 2951 | return sql.NullInt64{}, nil |
| 2952 | } |
| 2953 | |
| 2954 | return sql.NullInt64{ |
| 2955 | Int64: int64(templateDefault), |
| 2956 | Valid: true, |
| 2957 | }, nil |
| 2958 | } |
| 2959 | |
| 2960 | dur := time.Duration(*millis) * time.Millisecond |
| 2961 | truncated := dur.Truncate(time.Minute) |
| 2962 | if truncated < ttlMinimum { |
| 2963 | return sql.NullInt64{}, errTTLMin |
| 2964 | } |
| 2965 | |
| 2966 | if truncated > ttlMaximum { |
| 2967 | return sql.NullInt64{}, errTTLMax |
| 2968 | } |
| 2969 | |
| 2970 | return sql.NullInt64{ |
| 2971 | Valid: true, |
| 2972 | Int64: int64(truncated), |
| 2973 | }, nil |
| 2974 | } |
| 2975 | |
| 2976 | func validWorkspaceAutomaticUpdates(updates codersdk.AutomaticUpdates) (database.AutomaticUpdates, error) { |
| 2977 | if updates == "" { |
no test coverage detected