Skip to content

Commit 75165cc

Browse files
committed
add no-ui options to web, add auth tokens
1 parent 0bf513f commit 75165cc

File tree

31 files changed

+1436
-418
lines changed

31 files changed

+1436
-418
lines changed

.golangci.yaml

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,56 @@
1-
# More info on config here: https://github.com/golangci/golangci-lint#config-file
2-
run:
3-
deadline: 10s
4-
issues-exit-code: 1
5-
tests: true
6-
1+
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
2+
version: "2"
73
output:
84
formats:
9-
- format: colored-line-number
10-
print-issued-lines: true
11-
print-linter-name: true
12-
13-
linters-settings:
14-
govet:
15-
shadow: true
16-
golint:
17-
min-confidence: 0
18-
dupl:
19-
threshold: 100
20-
goconst:
21-
min-len: 2
22-
min-occurrences: 2
23-
5+
text:
6+
path: stdout
7+
print-linter-name: true
8+
print-issued-lines: true
249
linters:
25-
disable-all: true
10+
default: none
2611
enable:
27-
- revive
28-
- govet
29-
- errcheck
30-
- unused
31-
- ineffassign
32-
- typecheck
3312
- dupl
13+
- errcheck
3414
- goconst
3515
- gosec
36-
- goimports
37-
- gosimple
16+
- govet
17+
- ineffassign
18+
- revive
3819
- staticcheck
3920
- unused
40-
41-
issues:
42-
exclude-use-default: false
43-
exclude-dirs:
44-
- bin
45-
- vendor
46-
- var
47-
- tmp
48-
exclude-files:
49-
- \.pb\.go$
50-
- \.pb\.goclay\.go$
51-
- \.gen.go$
52-
- server/streams.go # @fixme remove when implemented
53-
exclude:
54-
# # _ instead of err checks
55-
# - G104
56-
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
57-
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv|.*Rollback). is not checked
21+
settings:
22+
dupl:
23+
threshold: 100
24+
goconst:
25+
min-len: 2
26+
min-occurrences: 2
27+
exclusions:
28+
generated: lax
29+
rules:
30+
- path: (.+)\.go$
31+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv|.*Rollback). is not checked
32+
paths:
33+
- \.pb\.go$
34+
- \.pb\.goclay\.go$
35+
- bin
36+
- vendor
37+
- var
38+
- tmp
39+
- third_party$
40+
- builtin$
41+
- examples$
42+
formatters:
43+
enable:
44+
- goimports
45+
exclusions:
46+
generated: lax
47+
paths:
48+
- \.pb\.go$
49+
- \.pb\.goclay\.go$
50+
- bin
51+
- vendor
52+
- var
53+
- tmp
54+
- third_party$
55+
- builtin$
56+
- examples$

Makefile

Lines changed: 150 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
GOPATH?=$(HOME)/go
22
FIRST_GOPATH:=$(firstword $(subst :, ,$(GOPATH)))
33

4-
NODE_TAG=22 # Always use LTS
5-
SWAGGER_UI_DIR:=./swagger-ui
6-
74
# Build available information.
85
GIT_HASH:=$(shell git log --format="%h" -n 1 2> /dev/null)
96
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
@@ -26,83 +23,186 @@ LOCAL_BIN:=$(CURDIR)/bin
2623

2724
# Linter config.
2825
GOLANGCI_BIN:=$(LOCAL_BIN)/golangci-lint
29-
GOLANGCI_TAG:=1.64.5
26+
GOLANGCI_TAG:=2.5.0
27+
28+
GOTESTFMT_BIN:=$(GOBIN)/gotestfmt
29+
30+
# Color definitions
31+
RED=\033[0;31m
32+
GREEN=\033[0;32m
33+
YELLOW=\033[0;33m
34+
BLUE=\033[0;34m
35+
MAGENTA=\033[0;35m
36+
CYAN=\033[0;36m
37+
WHITE=\033[0;37m
38+
BOLD=\033[1m
39+
RESET=\033[0m
40+
41+
# Disable colors on Windows.
42+
ifeq ($(OS),Windows_NT)
43+
RED=
44+
GREEN=
45+
YELLOW=
46+
BLUE=
47+
MAGENTA=
48+
CYAN=
49+
WHITE=
50+
BOLD=
51+
RESET=
52+
endif
53+
54+
# Print functions
55+
define print_header
56+
@echo "$(BOLD)$(CYAN)╔═════════════════════════════════════════════════════════════╗$(RESET)"
57+
@echo "$(BOLD)$(CYAN)║ LAUNCHR ║$(RESET)"
58+
@echo "$(BOLD)$(CYAN)╚═════════════════════════════════════════════════════════════╝$(RESET)"
59+
endef
60+
61+
define print_success
62+
@echo "$(BOLD)$(GREEN)$(1)$(RESET)"
63+
@echo
64+
endef
65+
66+
define print_info
67+
@echo "$(BOLD)$(BLUE)📋 $(1)$(RESET)"
68+
@echo
69+
endef
70+
71+
define print_warning
72+
@echo "$(BOLD)$(YELLOW)⚠️ $(1)$(RESET)"
73+
@echo
74+
endef
75+
76+
define print_error
77+
@echo "$(BOLD)$(RED)$(1)$(RESET)"
78+
@echo
79+
endef
80+
81+
define print_step
82+
@echo "$(BOLD)$(MAGENTA)🔧 $(1)$(RESET)"
83+
endef
3084

3185
.PHONY: all
32-
all: deps front test build
86+
all: banner deps test-short build
87+
$(call print_success,"🎉 All tasks completed successfully!")
88+
89+
.PHONY: banner
90+
banner:
91+
$(call print_header)
92+
@echo "$(BOLD)$(WHITE)📦 Version: $(APP_VERSION)$(RESET)"
93+
@echo "$(BOLD)$(WHITE)🌿 Branch: $(GIT_BRANCH)$(RESET)"
94+
@echo "$(BOLD)$(WHITE)🔗 Hash: $(GIT_HASH)$(RESET)"
95+
@echo
3396

3497
# Install go dependencies
3598
.PHONY: deps
3699
deps:
37-
$(info Installing go dependencies...)
38-
go mod download
39-
40-
# Build front dependencies.
41-
.PHONY: front
42-
front: front-install front-build
43-
@if [ ! -d "$(SWAGGER_UI_DIR)" ]; then \
44-
echo "Downloading Swagger UI..."; \
45-
curl -Ss https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | grep tarball_url | cut -d '"' -f 4 |\
46-
xargs curl -LsS -o swagger-ui.tar.gz; \
47-
rm -rf $(SWAGGER_UI_DIR) $(SWAGGER_UI_DIR)-tmp && mkdir $(SWAGGER_UI_DIR)-tmp; \
48-
tar xzf swagger-ui.tar.gz -C $(SWAGGER_UI_DIR)-tmp --strip=1; \
49-
mv $(SWAGGER_UI_DIR)-tmp/dist $(SWAGGER_UI_DIR); \
50-
rm -rf $(SWAGGER_UI_DIR)-tmp && rm swagger-ui.tar.gz; \
51-
sed -i.bkp "s|https://petstore.swagger.io/v2/swagger.json|/api/swagger.json|g" $(SWAGGER_UI_DIR)/swagger-initializer.js; \
52-
fi
100+
$(call print_step,"Installing go dependencies...")
101+
@go mod download
102+
$(call print_success,"Dependencies installed successfully!")
53103

54104
# Run all tests
55105
.PHONY: test
56-
test:
57-
$(info Running tests...)
58-
go test ./...
106+
test: .install-gotestfmt
107+
$(call print_step,"Running all tests...")
108+
@go test -json -v ./... | $(GOTESTFMT_BIN) -hide all && \
109+
echo "$(BOLD)$(GREEN)🧪 ✅ All tests passed$(RESET)" || \
110+
echo "$(BOLD)$(RED)🧪 ❌ Some tests failed$(RESET)"
111+
@echo
112+
113+
# Run short tests
114+
.PHONY: test-short
115+
test-short: .install-gotestfmt
116+
$(call print_step,"Running short tests...")
117+
@go test -json -short -v ./... | $(GOTESTFMT_BIN) -hide all && \
118+
echo "$(BOLD)$(GREEN)🧪 ✅ All short tests passed$(RESET)" || \
119+
echo "$(BOLD)$(RED)🧪 ❌ Some short tests failed$(RESET)"
120+
@echo
59121

60122
# Build launchr
61123
.PHONY: build
62124
build:
63-
$(info Building launchr...)
125+
$(call print_step,"Building launchr...")
64126
# Application related information available on build time.
65127
$(eval LDFLAGS:=-X '$(GOPKG).name=launchr' -X '$(GOPKG).version=$(APP_VERSION)' $(LDFLAGS_EXTRA))
66128
$(eval BIN?=$(LOCAL_BIN)/launchr)
67-
go generate ./...
68-
$(BUILD_ENVPARMS) go build -ldflags "$(LDFLAGS)" $(BUILD_OPTS) -o $(BIN) ./cmd/launchr
129+
@go generate ./...
130+
@$(BUILD_ENVPARMS) go build -ldflags "$(LDFLAGS)" $(BUILD_OPTS) -o $(BIN) ./cmd/launchr
131+
$(call print_success,"🔨 Build completed: $(BIN)")
69132

70133
# Install launchr
71134
.PHONY: install
72135
install: all
73-
install:
74-
$(info Installing launchr to GOPATH...)
75-
cp $(LOCAL_BIN)/launchr $(GOBIN)/launchr
136+
$(call print_step,"Installing launchr to GOPATH...")
137+
@cp $(LOCAL_BIN)/launchr $(GOBIN)/launchr
138+
$(call print_success,"🚀 launchr installed to $(GOBIN)/launchr")
76139

77140
# Install and run linters
78141
.PHONY: lint
79-
lint: .install-lint .lint
142+
lint: .install-lint .lint-fix
80143

81144
# Install golangci-lint binary
82145
.PHONY: .install-lint
83146
.install-lint:
84147
ifeq ($(wildcard $(GOLANGCI_BIN)),)
85-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCAL_BIN) v$(GOLANGCI_TAG)
148+
$(call print_step,"Installing golangci-lint v$(GOLANGCI_TAG)...")
149+
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCAL_BIN) v$(GOLANGCI_TAG)
150+
$(call print_success,"golangci-lint installed!")
151+
endif
152+
153+
# Install gotestfmt binary
154+
.PHONY: .install-gotestfmt
155+
.install-gotestfmt:
156+
ifeq ($(wildcard $(GOTESTFMT_BIN)),)
157+
$(call print_step,"Installing gotestfmt...")
158+
@go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
159+
$(call print_success,"gotestfmt installed!")
86160
endif
87161

88162
# Runs linters
163+
.PHONY: .lint-fix
164+
.lint-fix:
165+
$(call print_step,"Running linters with auto-fix...")
166+
@$(GOLANGCI_BIN) run --fix ./... && \
167+
echo "$(BOLD)$(GREEN)🔍 ✅ All linting checks passed$(RESET)" || \
168+
echo "$(BOLD)$(YELLOW)🔍 ⚠️ Some linting issues found - please review$(RESET)"
169+
@echo
170+
89171
.PHONY: .lint
90172
.lint:
91-
$(info Running lint...)
92-
$(GOLANGCI_BIN) run --fix ./...
93-
94-
# Front tasks.
95-
front-install:
96-
docker run --rm -it -v $(PWD)/client:/usr/src/app -w /usr/src/app node:$(NODE_TAG) sh -c "corepack install && corepack enable && yarn install"
97-
98-
front-build:
99-
docker run --rm -it -v $(PWD)/client:/usr/src/app -w /usr/src/app node:$(NODE_TAG) sh -c "corepack install && corepack enable && yarn build"
100-
101-
front-dev:
102-
docker run --rm -it -v $(PWD)/client:/usr/src/app -p 5173:5173 -w /usr/src/app node:$(NODE_TAG) sh -c "corepack install && corepack enable && yarn dev -- --host"
103-
104-
front-lint-fix:
105-
docker run --rm -it -v $(PWD)/client:/usr/src/app -w /usr/src/app node:$(NODE_TAG) sh -c "corepack install && corepack enable && yarn lint --fix"
106-
107-
dev:
108-
DEV=1 make build && LAUNCHR_ACTIONS_PATH=example ./bin/launchr web --foreground -vvvv
173+
$(call print_step,"Running linters...")
174+
@$(GOLANGCI_BIN) run && \
175+
echo "$(BOLD)$(GREEN)🔍 ✅ All linting checks passed$(RESET)" || \
176+
echo "$(BOLD)$(YELLOW)🔍 ⚠️ Some linting issues found - please review$(RESET)"
177+
@echo
178+
179+
# Clean build artifacts
180+
.PHONY: clean
181+
clean:
182+
$(call print_step,"Cleaning build artifacts...")
183+
@rm -rf $(LOCAL_BIN)
184+
$(call print_success,"🧹 Cleanup completed!")
185+
186+
# Show help
187+
.PHONY: help
188+
help:
189+
$(call print_header)
190+
@echo "$(BOLD)$(WHITE)Available targets:$(RESET)"
191+
@echo ""
192+
@echo " $(BOLD)$(GREEN)all$(RESET) 🎯 Run deps, test, and build"
193+
@echo " $(BOLD)$(GREEN)deps$(RESET) 📦 Install go dependencies"
194+
@echo " $(BOLD)$(GREEN)test$(RESET) 🧪 Run all tests"
195+
@echo " $(BOLD)$(GREEN)test-short$(RESET) ⚡ Run short tests only"
196+
@echo " $(BOLD)$(GREEN)build$(RESET) 🔨 Build launchr binary"
197+
@echo " $(BOLD)$(GREEN)install$(RESET) 🚀 Install launchr to GOPATH"
198+
@echo " $(BOLD)$(GREEN)lint$(RESET) 🔍 Run linters with auto-fix"
199+
@echo " $(BOLD)$(GREEN)clean$(RESET) 🧹 Clean build artifacts"
200+
@echo " $(BOLD)$(GREEN)help$(RESET) ❓ Show this help message"
201+
@echo ""
202+
@echo "$(BOLD)$(CYAN)Environment variables:$(RESET)"
203+
@echo " $(BOLD)$(YELLOW)DEBUG=1$(RESET) Enable debug build"
204+
@echo " $(BOLD)$(YELLOW)BIN=path$(RESET) Custom binary output path"
205+
@echo ""
206+
207+
# Default target shows help
208+
.DEFAULT_GOAL := help

action.token.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
runtime: plugin
2+
action:
3+
title: Web Token Management
4+
description: Manage tokens for web server authentication
5+
arguments:
6+
- name: operation
7+
title: Operation
8+
description: "Token operation: create, list, delete, purge"
9+
type: string
10+
enum: [ create, list, export, delete, purge ]
11+
required: true
12+
- name: name
13+
title: Token name
14+
description: Token name to create/delete
15+
type: string
16+
default: ""
17+
- name: size
18+
title: Token Entropy Size
19+
description: Number of random bytes used to generate the token
20+
type: integer
21+
enum: [ 16, 24, 32, 48, 64 ]
22+
default: 32
23+
options:
24+
- name: expires-in
25+
title: Expires In
26+
description: Token expiration duration (e.g., 24h, 7d, 30d), 0 for forever. Empty for 30d.
27+
type: string
28+
default: ""

action.yaml renamed to action.web.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,17 @@ action:
4040
description: Serve swagger.json on /api/swagger.json and Swagger UI on /api/swagger-ui from specified directory.
4141
type: string
4242
default: ""
43+
- name: no-ui
44+
title: Headless Mode
45+
description: Run server without web interface (API-only mode)
46+
type: boolean
47+
default: false
48+
- name: enable-token-auth
49+
title: Enable Token Authentication
50+
description: >-
51+
Requires valid authentication tokens for Web access.
52+
type: boolean
53+
process:
54+
- processor: config.GetValue
55+
options:
56+
path: web.enable_token_auth

0 commit comments

Comments
 (0)