From 845f4ec45426b4781f576918b4cec89227a74dd6 Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Thu, 21 Aug 2025 14:02:16 -0700 Subject: [PATCH 1/5] Add deadcode check to Makefile and remove unused writeFunc --- Makefile | 3 ++- internal/types/writer_func.go | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 internal/types/writer_func.go diff --git a/Makefile b/Makefile index bfc9238..eec7929 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ default: command -v goimports || go install golang.org/x/tools/cmd/goimports@latest goimports -w . go vet ./... + go run golang.org/x/tools/cmd/deadcode@latest ./... go test -cover ./... go install . # docs @@ -14,4 +15,4 @@ default: .PHONY: release release: - ./release \ No newline at end of file + ./release diff --git a/internal/types/writer_func.go b/internal/types/writer_func.go deleted file mode 100644 index c0363fe..0000000 --- a/internal/types/writer_func.go +++ /dev/null @@ -1,7 +0,0 @@ -package types - -type writeFunc func(p []byte) (n int, err error) - -func (w writeFunc) Write(p []byte) (n int, err error) { - return w(p) -} From e497cf189b712562045d17603318e9805aadeba6 Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Thu, 21 Aug 2025 14:07:08 -0700 Subject: [PATCH 2/5] feat: Add port field to Spec and support config file port override --- internal/types/spec.go | 2 ++ main.go | 13 ++++++++++-- tasks.yaml | 45 +++++++++++++++++++++--------------------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/internal/types/spec.go b/internal/types/spec.go index a617384..8b7991f 100644 --- a/internal/types/spec.go +++ b/internal/types/spec.go @@ -4,6 +4,8 @@ import "time" // Task is a unit of work that should be run. type Spec struct { + // Port is the port that should be used for the user interface. + Port int `json:"port,omitempty"` // TerminationGracePeriodSeconds is the grace period for terminating the workflow. TerminationGracePeriodSeconds *int32 `json:"terminationGracePeriodSeconds,omitempty"` // Tasks is a list of tasks that should be run. diff --git a/main.go b/main.go index 1a02bf9..e7da77c 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ func main() { printVersion := false configFile := "" tasksToSkip := "" - port := 0 + port := -1 // -1 means unspecified, 0 means disabled, >0 means specified openBrowser := false rewrite := false @@ -35,7 +35,7 @@ func main() { flag.BoolVar(&printVersion, "v", false, "print version and exit") flag.StringVar(&configFile, "f", "tasks.yaml", "config file (default tasks.yaml)") flag.StringVar(&tasksToSkip, "s", "", "tasks to skip (comma separated)") - flag.IntVar(&port, "p", 3000, "port to start UI on (default 3000, zero disables)") + flag.IntVar(&port, "p", port, "port to start UI on (default 3000, zero disables)") flag.BoolVar(&openBrowser, "b", false, "open the UI in the browser (default false)") flag.BoolVar(&rewrite, "w", false, "rewrite the config file") flag.Parse() @@ -75,6 +75,15 @@ func main() { return os.WriteFile(configFile, out, 0644) } + // if wf.Port is specified, use that, unless the user has specified a port on the command line + if port == -1 { + if wf.Port > 0 { + port = wf.Port + } else { + port = 3000 // default port + } + } + // split the tasks on comma, but don't end up with a single entry of "" split := strings.Split(tasksToSkip, ",") if len(split) == 1 && split[0] == "" { diff --git a/tasks.yaml b/tasks.yaml index fef2193..f07dd0f 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -1,12 +1,13 @@ +port: 3001 tasks: build-app: command: - - go - - build - - -v - - . + - go + - build + - -v + - . watch: - - main.go + - main.go workingDir: demo/go group: app error: @@ -23,25 +24,25 @@ tasks: stalledTimeout: 5s run-app: command: - - ./demo/go/go + - ./demo/go/go dependencies: - - build-app + - build-app env: PORT: "9090" ports: - - "9090" + - "9090" group: app run-container: image: httpd log: baz.log ports: - - 80:10080 + - 80:10080 readinessProbe: http://localhost:10080?failureThreshold=20&initialDelay=3s&period=5s&successThreshold=1 run-k8s: manifests: - - testdata + - testdata ports: - - 80:8080 + - 80:8080 script: sh: | set -eu @@ -55,18 +56,18 @@ tasks: type: Service skipped: targets: - - go.mod + - go.mod up: dependencies: - - run-app - - script - - run-container - - run-k8s - - service - - logs - - skipped + - run-app + - script + - run-container + - run-k8s + - service + - logs + - skipped terminationGracePeriodSeconds: 3 volumes: -- hostPath: - path: . - name: work + - hostPath: + path: . + name: work From 51033eb524fbfdef597aeb0e93458eebedf8c6d9 Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Thu, 21 Aug 2025 14:07:55 -0700 Subject: [PATCH 3/5] Document port property in workflow schema and reference docs --- .../workflow-defs-workflow-properties-port.md | 15 +++++++++++++++ docs/reference/workflow-defs-workflow.md | 19 +++++++++++++++++++ docs/reference/workflow.md | 19 +++++++++++++++++++ schema/workflow.schema.json | 4 ++++ 4 files changed, 57 insertions(+) create mode 100644 docs/reference/workflow-defs-workflow-properties-port.md diff --git a/docs/reference/workflow-defs-workflow-properties-port.md b/docs/reference/workflow-defs-workflow-properties-port.md new file mode 100644 index 0000000..cf5a170 --- /dev/null +++ b/docs/reference/workflow-defs-workflow-properties-port.md @@ -0,0 +1,15 @@ +# port Schema + +```txt +https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/port +``` + + + +| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | +| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------ | +| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [workflow.schema.json\*](../../out/workflow.schema.json "open original schema") | + +## port Type + +`integer` ([port](workflow-defs-workflow-properties-port.md)) diff --git a/docs/reference/workflow-defs-workflow.md b/docs/reference/workflow-defs-workflow.md index ccef201..81fa30c 100644 --- a/docs/reference/workflow-defs-workflow.md +++ b/docs/reference/workflow-defs-workflow.md @@ -18,6 +18,7 @@ https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow | Property | Type | Required | Nullable | Defined by | | :-------------------------------------------------------------- | :-------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [port](#port) | `integer` | Optional | cannot be null | [Untitled schema](workflow-defs-workflow-properties-port.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/port") | | [terminationGracePeriodSeconds](#terminationgraceperiodseconds) | `integer` | Optional | cannot be null | [Untitled schema](workflow-defs-workflow-properties-terminationgraceperiodseconds.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/terminationGracePeriodSeconds") | | [tasks](#tasks) | `object` | Optional | cannot be null | [Untitled schema](workflow-defs-tasks.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/tasks") | | [volumes](#volumes) | `array` | Optional | cannot be null | [Untitled schema](workflow-defs-workflow-properties-volumes.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/volumes") | @@ -25,6 +26,24 @@ https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow | [env](#env) | `object` | Optional | cannot be null | [Untitled schema](workflow-defs-envvars.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/env") | | [envfile](#envfile) | `array` | Optional | cannot be null | [Untitled schema](workflow-defs-envfile.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/envfile") | +## port + + + +`port` + +* is optional + +* Type: `integer` ([port](workflow-defs-workflow-properties-port.md)) + +* cannot be null + +* defined in: [Untitled schema](workflow-defs-workflow-properties-port.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/port") + +### port Type + +`integer` ([port](workflow-defs-workflow-properties-port.md)) + ## terminationGracePeriodSeconds diff --git a/docs/reference/workflow.md b/docs/reference/workflow.md index c9e948f..c9da189 100644 --- a/docs/reference/workflow.md +++ b/docs/reference/workflow.md @@ -1056,6 +1056,7 @@ Reference this group by using | Property | Type | Required | Nullable | Defined by | | :-------------------------------------------------------------- | :-------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [port](#port-2) | `integer` | Optional | cannot be null | [Untitled schema](workflow-defs-workflow-properties-port.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/port") | | [terminationGracePeriodSeconds](#terminationgraceperiodseconds) | `integer` | Optional | cannot be null | [Untitled schema](workflow-defs-workflow-properties-terminationgraceperiodseconds.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/terminationGracePeriodSeconds") | | [tasks](#tasks) | `object` | Optional | cannot be null | [Untitled schema](workflow-defs-tasks.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/tasks") | | [volumes](#volumes) | `array` | Optional | cannot be null | [Untitled schema](workflow-defs-workflow-properties-volumes.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/volumes") | @@ -1063,6 +1064,24 @@ Reference this group by using | [env](#env-1) | `object` | Optional | cannot be null | [Untitled schema](workflow-defs-envvars.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/env") | | [envfile](#envfile-1) | `array` | Optional | cannot be null | [Untitled schema](workflow-defs-envfile.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/envfile") | +### port + + + +`port` + +* is optional + +* Type: `integer` ([port](workflow-defs-workflow-properties-port.md)) + +* cannot be null + +* defined in: [Untitled schema](workflow-defs-workflow-properties-port.md "https://github.com/kitproj/kit/internal/types/workflow#/$defs/Workflow/properties/port") + +#### port Type + +`integer` ([port](workflow-defs-workflow-properties-port.md)) + ### terminationGracePeriodSeconds diff --git a/schema/workflow.schema.json b/schema/workflow.schema.json index d9b455b..c6806e5 100755 --- a/schema/workflow.schema.json +++ b/schema/workflow.schema.json @@ -354,6 +354,10 @@ }, "Workflow": { "properties": { + "port": { + "type": "integer", + "title": "port" + }, "terminationGracePeriodSeconds": { "type": "integer", "title": "terminationGracePeriodSeconds" From 63d50aa8267497eb40db09961f75918bd115bc2c Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Thu, 21 Aug 2025 14:18:27 -0700 Subject: [PATCH 4/5] Make Spec.Port a pointer and update usage in main --- internal/types/spec.go | 2 +- main.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/types/spec.go b/internal/types/spec.go index 8b7991f..885cf5a 100644 --- a/internal/types/spec.go +++ b/internal/types/spec.go @@ -5,7 +5,7 @@ import "time" // Task is a unit of work that should be run. type Spec struct { // Port is the port that should be used for the user interface. - Port int `json:"port,omitempty"` + Port *int `json:"port,omitempty"` // TerminationGracePeriodSeconds is the grace period for terminating the workflow. TerminationGracePeriodSeconds *int32 `json:"terminationGracePeriodSeconds,omitempty"` // Tasks is a list of tasks that should be run. diff --git a/main.go b/main.go index e7da77c..81bfb22 100644 --- a/main.go +++ b/main.go @@ -77,8 +77,8 @@ func main() { // if wf.Port is specified, use that, unless the user has specified a port on the command line if port == -1 { - if wf.Port > 0 { - port = wf.Port + if wf.Port != nil { + port = *wf.Port } else { port = 3000 // default port } From aa85c18f7754f0028c62a2aab6cbe9798e496855 Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Thu, 21 Aug 2025 14:21:36 -0700 Subject: [PATCH 5/5] Change Spec.Port type from *int to *uint16 --- internal/types/spec.go | 2 +- main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/types/spec.go b/internal/types/spec.go index 885cf5a..4b069e8 100644 --- a/internal/types/spec.go +++ b/internal/types/spec.go @@ -5,7 +5,7 @@ import "time" // Task is a unit of work that should be run. type Spec struct { // Port is the port that should be used for the user interface. - Port *int `json:"port,omitempty"` + Port *uint16 `json:"port,omitempty"` // TerminationGracePeriodSeconds is the grace period for terminating the workflow. TerminationGracePeriodSeconds *int32 `json:"terminationGracePeriodSeconds,omitempty"` // Tasks is a list of tasks that should be run. diff --git a/main.go b/main.go index 81bfb22..1c548d4 100644 --- a/main.go +++ b/main.go @@ -78,7 +78,7 @@ func main() { // if wf.Port is specified, use that, unless the user has specified a port on the command line if port == -1 { if wf.Port != nil { - port = *wf.Port + port = int(*wf.Port) } else { port = 3000 // default port }