From 64a4c88bd093a92a7283e9191bb33a0c8fe0f8fe Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 5 Dec 2023 13:29:21 +0000 Subject: [PATCH 1/2] fix(codersdk): make codersdk.ProvisionerDaemon.UpdatedAt a codersdk.NullTime --- coderd/apidoc/docs.go | 20 ++----------- coderd/apidoc/swagger.json | 20 ++----------- codersdk/provisionerdaemons.go | 3 +- docs/api/enterprise.md | 27 +++++++---------- docs/api/schemas.md | 39 +++++++------------------ enterprise/coderd/provisionerdaemons.go | 2 +- 6 files changed, 27 insertions(+), 84 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 72003c9273f9a..9980f070315fc 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -9558,12 +9558,8 @@ const docTemplate = `{ } }, "updated_at": { - "format": "date-time", - "allOf": [ - { - "$ref": "#/definitions/sql.NullTime" - } - ] + "type": "string", + "format": "date-time" } } }, @@ -12734,18 +12730,6 @@ const docTemplate = `{ } } }, - "sql.NullTime": { - "type": "object", - "properties": { - "time": { - "type": "string" - }, - "valid": { - "description": "Valid is true if Time is not NULL", - "type": "boolean" - } - } - }, "tailcfg.DERPHomeParams": { "type": "object", "properties": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 477bb430fc55c..0ad7558678a0e 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -8597,12 +8597,8 @@ } }, "updated_at": { - "format": "date-time", - "allOf": [ - { - "$ref": "#/definitions/sql.NullTime" - } - ] + "type": "string", + "format": "date-time" } } }, @@ -11607,18 +11603,6 @@ } } }, - "sql.NullTime": { - "type": "object", - "properties": { - "time": { - "type": "string" - }, - "valid": { - "description": "Valid is true if Time is not NULL", - "type": "boolean" - } - } - }, "tailcfg.DERPHomeParams": { "type": "object", "properties": { diff --git a/codersdk/provisionerdaemons.go b/codersdk/provisionerdaemons.go index 0b321e51662ab..993a3620e1626 100644 --- a/codersdk/provisionerdaemons.go +++ b/codersdk/provisionerdaemons.go @@ -2,7 +2,6 @@ package codersdk import ( "context" - "database/sql" "encoding/json" "fmt" "io" @@ -39,7 +38,7 @@ const ( type ProvisionerDaemon struct { ID uuid.UUID `json:"id" format:"uuid"` CreatedAt time.Time `json:"created_at" format:"date-time"` - UpdatedAt sql.NullTime `json:"updated_at" format:"date-time"` + UpdatedAt NullTime `json:"updated_at" format:"date-time"` Name string `json:"name"` Provisioners []ProvisionerType `json:"provisioners"` Tags map[string]string `json:"tags"` diff --git a/docs/api/enterprise.md b/docs/api/enterprise.md index e25b48aedb34a..294450f5d3f56 100644 --- a/docs/api/enterprise.md +++ b/docs/api/enterprise.md @@ -706,10 +706,7 @@ curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/provisi "property1": "string", "property2": "string" }, - "updated_at": { - "time": "string", - "valid": true - } + "updated_at": "2019-08-24T14:15:22Z" } ] ``` @@ -724,18 +721,16 @@ curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/provisi Status Code **200** -| Name | Type | Required | Restrictions | Description | -| ------------------- | -------------------------------------- | -------- | ------------ | --------------------------------- | -| `[array item]` | array | false | | | -| `» created_at` | string(date-time) | false | | | -| `» id` | string(uuid) | false | | | -| `» name` | string | false | | | -| `» provisioners` | array | false | | | -| `» tags` | object | false | | | -| `»» [any property]` | string | false | | | -| `» updated_at` | [sql.NullTime](schemas.md#sqlnulltime) | false | | | -| `»» time` | string | false | | | -| `»» valid` | boolean | false | | Valid is true if Time is not NULL | +| Name | Type | Required | Restrictions | Description | +| ------------------- | ----------------- | -------- | ------------ | ----------- | +| `[array item]` | array | false | | | +| `» created_at` | string(date-time) | false | | | +| `» id` | string(uuid) | false | | | +| `» name` | string | false | | | +| `» provisioners` | array | false | | | +| `» tags` | object | false | | | +| `»» [any property]` | string | false | | | +| `» updated_at` | string(date-time) | false | | | To perform this operation, you must be authenticated. [Learn more](authentication.md). diff --git a/docs/api/schemas.md b/docs/api/schemas.md index cf05ec3ba3f41..ee9d1e0b24bb6 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -3776,24 +3776,21 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "property1": "string", "property2": "string" }, - "updated_at": { - "time": "string", - "valid": true - } + "updated_at": "2019-08-24T14:15:22Z" } ``` ### Properties -| Name | Type | Required | Restrictions | Description | -| ------------------ | ---------------------------- | -------- | ------------ | ----------- | -| `created_at` | string | false | | | -| `id` | string | false | | | -| `name` | string | false | | | -| `provisioners` | array of string | false | | | -| `tags` | object | false | | | -| » `[any property]` | string | false | | | -| `updated_at` | [sql.NullTime](#sqlnulltime) | false | | | +| Name | Type | Required | Restrictions | Description | +| ------------------ | --------------- | -------- | ------------ | ----------- | +| `created_at` | string | false | | | +| `id` | string | false | | | +| `name` | string | false | | | +| `provisioners` | array of string | false | | | +| `tags` | object | false | | | +| » `[any property]` | string | false | | | +| `updated_at` | string | false | | | ## codersdk.ProvisionerJob @@ -8180,22 +8177,6 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `udp` | boolean | false | | a UDP STUN round trip completed | | `upnP` | string | false | | Upnp is whether UPnP appears present on the LAN. Empty means not checked. | -## sql.NullTime - -```json -{ - "time": "string", - "valid": true -} -``` - -### Properties - -| Name | Type | Required | Restrictions | Description | -| ------- | ------- | -------- | ------------ | --------------------------------- | -| `time` | string | false | | | -| `valid` | boolean | false | | Valid is true if Time is not NULL | - ## tailcfg.DERPHomeParams ```json diff --git a/enterprise/coderd/provisionerdaemons.go b/enterprise/coderd/provisionerdaemons.go index e10489f45a6c7..73822cd4d9340 100644 --- a/enterprise/coderd/provisionerdaemons.go +++ b/enterprise/coderd/provisionerdaemons.go @@ -312,7 +312,7 @@ func convertProvisionerDaemon(daemon database.ProvisionerDaemon) codersdk.Provis result := codersdk.ProvisionerDaemon{ ID: daemon.ID, CreatedAt: daemon.CreatedAt, - UpdatedAt: daemon.UpdatedAt, + UpdatedAt: codersdk.NullTime{NullTime: daemon.UpdatedAt}, Name: daemon.Name, Tags: daemon.Tags, } From 4fe9534a29350685808e46037e719c6cc23f36d8 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 5 Dec 2023 13:57:34 +0000 Subject: [PATCH 2/2] fixup! fix(codersdk): make codersdk.ProvisionerDaemon.UpdatedAt a codersdk.NullTime --- codersdk/provisionerdaemons.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codersdk/provisionerdaemons.go b/codersdk/provisionerdaemons.go index 993a3620e1626..be4e77fc29f5d 100644 --- a/codersdk/provisionerdaemons.go +++ b/codersdk/provisionerdaemons.go @@ -38,7 +38,7 @@ const ( type ProvisionerDaemon struct { ID uuid.UUID `json:"id" format:"uuid"` CreatedAt time.Time `json:"created_at" format:"date-time"` - UpdatedAt NullTime `json:"updated_at" format:"date-time"` + UpdatedAt NullTime `json:"updated_at,omitempty" format:"date-time"` Name string `json:"name"` Provisioners []ProvisionerType `json:"provisioners"` Tags map[string]string `json:"tags"`