Dev env setup.

This commit is contained in:
2025-10-11 21:40:45 +00:00
parent b76d2fb164
commit 92032202f4
13 changed files with 186 additions and 47 deletions

38
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,38 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Daemon (debug)",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"console": "integratedTerminal",
"env": {
"GO_ENV": "development",
"WILD_CENTRAL_ENV": "development",
"DEBUG": "true"
},
"args": [],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"showLog": true,
"trace": "verbose"
},
{
"name": "Daemon (no debug)",
"type": "go",
"request": "launch",
"program": "${workspaceFolder}",
"console": "integratedTerminal",
"env": {
"GO_ENV": "development",
"WILD_CENTRAL_ENV": "development"
},
"args": [],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"showLog": true
}
],
}

23
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,23 @@
{
"go.gopath": "",
"go.goroot": "",
"go.useLanguageServer": true,
"gopls": {
"experimentalWorkspaceModule": true,
"build.experimentalWorkspaceModule": true
},
"go.lintTool": "golangci-lint",
"go.lintOnSave": "workspace",
"go.formatTool": "goimports",
"go.testOnSave": false,
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.suggest.snippetsPreventQuickSuggestions": false
}
}

73
Makefile Normal file
View File

@@ -0,0 +1,73 @@
.PHONY: help build dev test clean install lint fmt vet
# Binary name
BINARY_NAME=wildd
BUILD_DIR=build
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
GOVET=$(GOCMD) vet
# Build flags
LDFLAGS=-ldflags "-s -w"
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Build the daemon binary
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) .
dev: ## Run the daemon in development mode with live reloading
@echo "Starting $(BINARY_NAME) in development mode..."
$(GOCMD) run .
test: ## Run tests
@echo "Running tests..."
$(GOTEST) -v ./...
test-cover: ## Run tests with coverage
@echo "Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
clean: ## Clean build artifacts
@echo "Cleaning..."
$(GOCLEAN)
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
install: build ## Install the binary to $(go env GOPATH)/bin
@echo "Installing $(BINARY_NAME)..."
@mkdir -p $$($(GOCMD) env GOPATH)/bin
@cp $(BUILD_DIR)/$(BINARY_NAME) $$($(GOCMD) env GOPATH)/bin/
deps: ## Download dependencies
@echo "Downloading dependencies..."
$(GOMOD) download
$(GOMOD) tidy
fmt: ## Format Go code
@echo "Formatting code..."
$(GOFMT) ./...
vet: ## Run go vet
@echo "Running go vet..."
$(GOVET) ./...
lint: fmt vet ## Run formatters and linters
check: lint test ## Run all checks (lint + test)
all: clean lint test build ## Clean, lint, test, and build

View File

@@ -95,6 +95,11 @@ func (m *Manager) GetSecret(secretsPath, key string) (string, error) {
return "", fmt.Errorf("getting secret %s: %w", key, err)
}
// yq returns "null" for non-existent keys
if value == "" || value == "null" {
return "", fmt.Errorf("secret not found: %s", key)
}
return value, nil
}