From 5c3087bcefc72bf6f2292c3cb41f08a827962b52 Mon Sep 17 00:00:00 2001 From: tdstein Date: Fri, 8 Sep 2023 11:11:24 -0400 Subject: [PATCH 1/4] Sets omitempty on optional fields. --- internal/state/connect.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/state/connect.go b/internal/state/connect.go index c60a840b8..c0409808c 100644 --- a/internal/state/connect.go +++ b/internal/state/connect.go @@ -14,24 +14,24 @@ type ConnectDeployment struct { } type ConnectContent struct { - Name types.ContentName `json:"name,omitempty"` + Name types.ContentName `json:"name"` Title string `json:"title,omitempty"` - Description string `json:"description,omitempty"` - AccessType string `json:"access_type,omitempty"` - ConnectionTimeout types.NullInt32 `json:"connection_timeout"` - ReadTimeout types.NullInt32 `json:"read_timeout"` - InitTimeout types.NullInt32 `json:"init_timeout"` - IdleTimeout types.NullInt32 `json:"idle_timeout"` - MaxProcesses types.NullInt32 `json:"max_processes"` - MinProcesses types.NullInt32 `json:"min_processes"` - MaxConnsPerProcess types.NullInt32 `json:"max_conns_per_process" kong:"name='max-connections'"` - LoadFactor types.NullFloat64 `json:"load_factor"` + Description string `json:"description"` + AccessType string `json:"access_type"` + ConnectionTimeout types.NullInt32 `json:"connection_timeout,omitempty"` + ReadTimeout types.NullInt32 `json:"read_timeout,omitempty"` + InitTimeout types.NullInt32 `json:"init_timeout,omitempty"` + IdleTimeout types.NullInt32 `json:"idle_timeout,omitempty"` + MaxProcesses types.NullInt32 `json:"max_processes,omitempty"` + MinProcesses types.NullInt32 `json:"min_processes,omitempty"` + MaxConnsPerProcess types.NullInt32 `json:"max_conns_per_process,omitempty" kong:"name='max-connections'"` + LoadFactor types.NullFloat64 `json:"load_factor,omitempty"` RunAs string `json:"run_as,omitempty"` - RunAsCurrentUser types.NullBool `json:"run_as_current_user"` - MemoryRequest types.NullInt64 `json:"memory_request"` - MemoryLimit types.NullInt64 `json:"memory_limit"` - CPURequest types.NullFloat64 `json:"cpu_request"` - CPULimit types.NullFloat64 `json:"cpu_limit"` + RunAsCurrentUser types.NullBool `json:"run_as_current_user,omitempty"` + MemoryRequest types.NullInt64 `json:"memory_request,omitempty"` + MemoryLimit types.NullInt64 `json:"memory_limit,omitempty"` + CPURequest types.NullFloat64 `json:"cpu_request,omitempty"` + CPULimit types.NullFloat64 `json:"cpu_limit,omitempty"` ServiceAccountName string `json:"service_account_name,omitempty"` DefaultImageName string `json:"default_image_name,omitempty"` } From 85690d2406d761895001e9416c73aa590069803b Mon Sep 17 00:00:00 2001 From: tdstein Date: Tue, 19 Sep 2023 11:49:04 -0400 Subject: [PATCH 2/4] Removes JSON tags from out-of-scope fields. --- internal/state/connect.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/state/connect.go b/internal/state/connect.go index c0409808c..5e38225b4 100644 --- a/internal/state/connect.go +++ b/internal/state/connect.go @@ -17,23 +17,23 @@ type ConnectContent struct { Name types.ContentName `json:"name"` Title string `json:"title,omitempty"` Description string `json:"description"` - AccessType string `json:"access_type"` - ConnectionTimeout types.NullInt32 `json:"connection_timeout,omitempty"` - ReadTimeout types.NullInt32 `json:"read_timeout,omitempty"` - InitTimeout types.NullInt32 `json:"init_timeout,omitempty"` - IdleTimeout types.NullInt32 `json:"idle_timeout,omitempty"` - MaxProcesses types.NullInt32 `json:"max_processes,omitempty"` - MinProcesses types.NullInt32 `json:"min_processes,omitempty"` - MaxConnsPerProcess types.NullInt32 `json:"max_conns_per_process,omitempty" kong:"name='max-connections'"` - LoadFactor types.NullFloat64 `json:"load_factor,omitempty"` - RunAs string `json:"run_as,omitempty"` - RunAsCurrentUser types.NullBool `json:"run_as_current_user,omitempty"` - MemoryRequest types.NullInt64 `json:"memory_request,omitempty"` - MemoryLimit types.NullInt64 `json:"memory_limit,omitempty"` - CPURequest types.NullFloat64 `json:"cpu_request,omitempty"` - CPULimit types.NullFloat64 `json:"cpu_limit,omitempty"` - ServiceAccountName string `json:"service_account_name,omitempty"` - DefaultImageName string `json:"default_image_name,omitempty"` + AccessType string + ConnectionTimeout types.NullInt32 + ReadTimeout types.NullInt32 + InitTimeout types.NullInt32 + IdleTimeout types.NullInt32 + MaxProcesses types.NullInt32 + MinProcesses types.NullInt32 + MaxConnsPerProcess types.NullInt32 + LoadFactor types.NullFloat64 + RunAs string + RunAsCurrentUser types.NullBool + MemoryRequest types.NullInt64 + MemoryLimit types.NullInt64 + CPURequest types.NullFloat64 + CPULimit types.NullFloat64 + ServiceAccountName string + DefaultImageName string } func (d *ConnectDeployment) Merge(other *ConnectDeployment) { From f2b70b56de5914e47b75200edb681e1851d73d1e Mon Sep 17 00:00:00 2001 From: tdstein Date: Fri, 6 Oct 2023 10:37:10 -0400 Subject: [PATCH 3/4] Updates type to reflect API changes --- web/src/api/types/connect.ts | 17 ----------------- .../configurePublish/FilesToPublish.test.ts | 14 -------------- 2 files changed, 31 deletions(-) diff --git a/web/src/api/types/connect.ts b/web/src/api/types/connect.ts index 13c32c2f5..c7d7b9188 100644 --- a/web/src/api/types/connect.ts +++ b/web/src/api/types/connect.ts @@ -4,23 +4,6 @@ export type ConnectContent = { name: string; title?: string; description?: string; - accessType?: string; - connectionTimeout: number | null; - readTimeout: number | null; - initTimeout: number | null; - idleTimeout: number | null; - maxProcesses: number | null; - minProcesses: number | null; - maxConnsPerProcess: number | null; - loadFactor: number | null; - runAs?: string; - runAsCurrentUser: boolean | null; - memoryRequest: number | null; - memoryLimit: number | null; - cpuRequest: number | null; - cpuLimit: number | null; - serviceAccountName?: string; - defaultImageName?: string; } export type ConnectEnvironmentVariable = { diff --git a/web/tests/unit/components/configurePublish/FilesToPublish.test.ts b/web/tests/unit/components/configurePublish/FilesToPublish.test.ts index ed46a6729..d8f581f4b 100644 --- a/web/tests/unit/components/configurePublish/FilesToPublish.test.ts +++ b/web/tests/unit/components/configurePublish/FilesToPublish.test.ts @@ -170,19 +170,6 @@ describe('description', () => { connect: { connect: { name: '', - connectionTimeout: null, - readTimeout: null, - initTimeout: null, - idleTimeout: null, - maxProcesses: null, - minProcesses: null, - maxConnsPerProcess: null, - loadFactor: null, - runAsCurrentUser: null, - memoryRequest: null, - memoryLimit: null, - cpuRequest: null, - cpuLimit: null }, environment: [ { @@ -200,4 +187,3 @@ describe('description', () => { expect(wrapper.text()).toContain('4 files selected from test/sample-content/fastapi-simple (total = 1.0 KB)'); }); }); - From 2c68d8d2439e2dab4bf2e7d0865a609eddfad95c Mon Sep 17 00:00:00 2001 From: tdstein Date: Tue, 10 Oct 2023 15:41:28 -0400 Subject: [PATCH 4/4] Sets `json:"-"` on ignored fields --- internal/state/connect.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/state/connect.go b/internal/state/connect.go index 5e38225b4..67342b6a9 100644 --- a/internal/state/connect.go +++ b/internal/state/connect.go @@ -16,24 +16,24 @@ type ConnectDeployment struct { type ConnectContent struct { Name types.ContentName `json:"name"` Title string `json:"title,omitempty"` - Description string `json:"description"` - AccessType string - ConnectionTimeout types.NullInt32 - ReadTimeout types.NullInt32 - InitTimeout types.NullInt32 - IdleTimeout types.NullInt32 - MaxProcesses types.NullInt32 - MinProcesses types.NullInt32 - MaxConnsPerProcess types.NullInt32 - LoadFactor types.NullFloat64 - RunAs string - RunAsCurrentUser types.NullBool - MemoryRequest types.NullInt64 - MemoryLimit types.NullInt64 - CPURequest types.NullFloat64 - CPULimit types.NullFloat64 - ServiceAccountName string - DefaultImageName string + Description string `json:"description,omitempty"` + AccessType string `json:"-"` + ConnectionTimeout types.NullInt32 `json:"-"` + ReadTimeout types.NullInt32 `json:"-"` + InitTimeout types.NullInt32 `json:"-"` + IdleTimeout types.NullInt32 `json:"-"` + MaxProcesses types.NullInt32 `json:"-"` + MinProcesses types.NullInt32 `json:"-"` + MaxConnsPerProcess types.NullInt32 `json:"-"` + LoadFactor types.NullFloat64 `json:"-"` + RunAs string `json:"-"` + RunAsCurrentUser types.NullBool `json:"-"` + MemoryRequest types.NullInt64 `json:"-"` + MemoryLimit types.NullInt64 `json:"-"` + CPURequest types.NullFloat64 `json:"-"` + CPULimit types.NullFloat64 `json:"-"` + ServiceAccountName string `json:"-"` + DefaultImageName string `json:"-"` } func (d *ConnectDeployment) Merge(other *ConnectDeployment) {