chore: fmt.Errorf(static) → errors.New
This commit is contained in:
parent
efa2f59e6e
commit
801bbe15e5
35 changed files with 134 additions and 98 deletions
|
|
@ -3,6 +3,7 @@ package ansible
|
|||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -178,7 +179,7 @@ func (e *Executor) moduleShell(ctx context.Context, client *SSHClient, args map[
|
|||
cmd = getStringArg(args, "cmd", "")
|
||||
}
|
||||
if cmd == "" {
|
||||
return nil, fmt.Errorf("shell: no command specified")
|
||||
return nil, errors.New("shell: no command specified")
|
||||
}
|
||||
|
||||
// Handle chdir
|
||||
|
|
@ -206,7 +207,7 @@ func (e *Executor) moduleCommand(ctx context.Context, client *SSHClient, args ma
|
|||
cmd = getStringArg(args, "cmd", "")
|
||||
}
|
||||
if cmd == "" {
|
||||
return nil, fmt.Errorf("command: no command specified")
|
||||
return nil, errors.New("command: no command specified")
|
||||
}
|
||||
|
||||
// Handle chdir
|
||||
|
|
@ -231,7 +232,7 @@ func (e *Executor) moduleCommand(ctx context.Context, client *SSHClient, args ma
|
|||
func (e *Executor) moduleRaw(ctx context.Context, client *SSHClient, args map[string]any) (*TaskResult, error) {
|
||||
cmd := getStringArg(args, "_raw_params", "")
|
||||
if cmd == "" {
|
||||
return nil, fmt.Errorf("raw: no command specified")
|
||||
return nil, errors.New("raw: no command specified")
|
||||
}
|
||||
|
||||
stdout, stderr, rc, err := client.Run(ctx, cmd)
|
||||
|
|
@ -250,7 +251,7 @@ func (e *Executor) moduleRaw(ctx context.Context, client *SSHClient, args map[st
|
|||
func (e *Executor) moduleScript(ctx context.Context, client *SSHClient, args map[string]any) (*TaskResult, error) {
|
||||
script := getStringArg(args, "_raw_params", "")
|
||||
if script == "" {
|
||||
return nil, fmt.Errorf("script: no script specified")
|
||||
return nil, errors.New("script: no script specified")
|
||||
}
|
||||
|
||||
// Read local script
|
||||
|
|
@ -278,7 +279,7 @@ func (e *Executor) moduleScript(ctx context.Context, client *SSHClient, args map
|
|||
func (e *Executor) moduleCopy(ctx context.Context, client *SSHClient, args map[string]any, host string, task *Task) (*TaskResult, error) {
|
||||
dest := getStringArg(args, "dest", "")
|
||||
if dest == "" {
|
||||
return nil, fmt.Errorf("copy: dest required")
|
||||
return nil, errors.New("copy: dest required")
|
||||
}
|
||||
|
||||
var content []byte
|
||||
|
|
@ -292,7 +293,7 @@ func (e *Executor) moduleCopy(ctx context.Context, client *SSHClient, args map[s
|
|||
} else if c := getStringArg(args, "content", ""); c != "" {
|
||||
content = []byte(c)
|
||||
} else {
|
||||
return nil, fmt.Errorf("copy: src or content required")
|
||||
return nil, errors.New("copy: src or content required")
|
||||
}
|
||||
|
||||
mode := os.FileMode(0644)
|
||||
|
|
@ -322,7 +323,7 @@ func (e *Executor) moduleTemplate(ctx context.Context, client *SSHClient, args m
|
|||
src := getStringArg(args, "src", "")
|
||||
dest := getStringArg(args, "dest", "")
|
||||
if src == "" || dest == "" {
|
||||
return nil, fmt.Errorf("template: src and dest required")
|
||||
return nil, errors.New("template: src and dest required")
|
||||
}
|
||||
|
||||
// Process template
|
||||
|
|
@ -352,7 +353,7 @@ func (e *Executor) moduleFile(ctx context.Context, client *SSHClient, args map[s
|
|||
path = getStringArg(args, "dest", "")
|
||||
}
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("file: path required")
|
||||
return nil, errors.New("file: path required")
|
||||
}
|
||||
|
||||
state := getStringArg(args, "state", "file")
|
||||
|
|
@ -383,7 +384,7 @@ func (e *Executor) moduleFile(ctx context.Context, client *SSHClient, args map[s
|
|||
case "link":
|
||||
src := getStringArg(args, "src", "")
|
||||
if src == "" {
|
||||
return nil, fmt.Errorf("file: src required for link state")
|
||||
return nil, errors.New("file: src required for link state")
|
||||
}
|
||||
cmd := fmt.Sprintf("ln -sf %q %q", src, path)
|
||||
_, stderr, rc, err := client.Run(ctx, cmd)
|
||||
|
|
@ -420,7 +421,7 @@ func (e *Executor) moduleLineinfile(ctx context.Context, client *SSHClient, args
|
|||
path = getStringArg(args, "dest", "")
|
||||
}
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("lineinfile: path required")
|
||||
return nil, errors.New("lineinfile: path required")
|
||||
}
|
||||
|
||||
line := getStringArg(args, "line", "")
|
||||
|
|
@ -460,7 +461,7 @@ func (e *Executor) moduleLineinfile(ctx context.Context, client *SSHClient, args
|
|||
func (e *Executor) moduleStat(ctx context.Context, client *SSHClient, args map[string]any) (*TaskResult, error) {
|
||||
path := getStringArg(args, "path", "")
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("stat: path required")
|
||||
return nil, errors.New("stat: path required")
|
||||
}
|
||||
|
||||
stat, err := client.Stat(ctx, path)
|
||||
|
|
@ -480,7 +481,7 @@ func (e *Executor) moduleSlurp(ctx context.Context, client *SSHClient, args map[
|
|||
path = getStringArg(args, "src", "")
|
||||
}
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("slurp: path required")
|
||||
return nil, errors.New("slurp: path required")
|
||||
}
|
||||
|
||||
content, err := client.Download(ctx, path)
|
||||
|
|
@ -500,7 +501,7 @@ func (e *Executor) moduleFetch(ctx context.Context, client *SSHClient, args map[
|
|||
src := getStringArg(args, "src", "")
|
||||
dest := getStringArg(args, "dest", "")
|
||||
if src == "" || dest == "" {
|
||||
return nil, fmt.Errorf("fetch: src and dest required")
|
||||
return nil, errors.New("fetch: src and dest required")
|
||||
}
|
||||
|
||||
content, err := client.Download(ctx, src)
|
||||
|
|
@ -524,7 +525,7 @@ func (e *Executor) moduleGetURL(ctx context.Context, client *SSHClient, args map
|
|||
url := getStringArg(args, "url", "")
|
||||
dest := getStringArg(args, "dest", "")
|
||||
if url == "" || dest == "" {
|
||||
return nil, fmt.Errorf("get_url: url and dest required")
|
||||
return nil, errors.New("get_url: url and dest required")
|
||||
}
|
||||
|
||||
// Use curl or wget
|
||||
|
|
@ -591,7 +592,7 @@ func (e *Executor) moduleAptKey(ctx context.Context, client *SSHClient, args map
|
|||
}
|
||||
|
||||
if url == "" {
|
||||
return nil, fmt.Errorf("apt_key: url required")
|
||||
return nil, errors.New("apt_key: url required")
|
||||
}
|
||||
|
||||
var cmd string
|
||||
|
|
@ -615,7 +616,7 @@ func (e *Executor) moduleAptRepository(ctx context.Context, client *SSHClient, a
|
|||
state := getStringArg(args, "state", "present")
|
||||
|
||||
if repo == "" {
|
||||
return nil, fmt.Errorf("apt_repository: repo required")
|
||||
return nil, errors.New("apt_repository: repo required")
|
||||
}
|
||||
|
||||
if filename == "" {
|
||||
|
|
@ -690,7 +691,7 @@ func (e *Executor) moduleService(ctx context.Context, client *SSHClient, args ma
|
|||
enabled := args["enabled"]
|
||||
|
||||
if name == "" {
|
||||
return nil, fmt.Errorf("service: name required")
|
||||
return nil, errors.New("service: name required")
|
||||
}
|
||||
|
||||
var cmds []string
|
||||
|
|
@ -742,7 +743,7 @@ func (e *Executor) moduleUser(ctx context.Context, client *SSHClient, args map[s
|
|||
state := getStringArg(args, "state", "present")
|
||||
|
||||
if name == "" {
|
||||
return nil, fmt.Errorf("user: name required")
|
||||
return nil, errors.New("user: name required")
|
||||
}
|
||||
|
||||
if state == "absent" {
|
||||
|
|
@ -799,7 +800,7 @@ func (e *Executor) moduleGroup(ctx context.Context, client *SSHClient, args map[
|
|||
state := getStringArg(args, "state", "present")
|
||||
|
||||
if name == "" {
|
||||
return nil, fmt.Errorf("group: name required")
|
||||
return nil, errors.New("group: name required")
|
||||
}
|
||||
|
||||
if state == "absent" {
|
||||
|
|
@ -834,7 +835,7 @@ func (e *Executor) moduleURI(ctx context.Context, client *SSHClient, args map[st
|
|||
method := getStringArg(args, "method", "GET")
|
||||
|
||||
if url == "" {
|
||||
return nil, fmt.Errorf("uri: url required")
|
||||
return nil, errors.New("uri: url required")
|
||||
}
|
||||
|
||||
var curlOpts []string
|
||||
|
|
@ -912,7 +913,7 @@ func (e *Executor) moduleFail(args map[string]any) (*TaskResult, error) {
|
|||
func (e *Executor) moduleAssert(args map[string]any, host string) (*TaskResult, error) {
|
||||
that, ok := args["that"]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("assert: 'that' required")
|
||||
return nil, errors.New("assert: 'that' required")
|
||||
}
|
||||
|
||||
conditions := normalizeConditions(that)
|
||||
|
|
@ -1013,7 +1014,7 @@ func (e *Executor) moduleGit(ctx context.Context, client *SSHClient, args map[st
|
|||
version := getStringArg(args, "version", "HEAD")
|
||||
|
||||
if repo == "" || dest == "" {
|
||||
return nil, fmt.Errorf("git: repo and dest required")
|
||||
return nil, errors.New("git: repo and dest required")
|
||||
}
|
||||
|
||||
// Check if dest exists
|
||||
|
|
@ -1042,7 +1043,7 @@ func (e *Executor) moduleUnarchive(ctx context.Context, client *SSHClient, args
|
|||
remote := getBoolArg(args, "remote_src", false)
|
||||
|
||||
if src == "" || dest == "" {
|
||||
return nil, fmt.Errorf("unarchive: src and dest required")
|
||||
return nil, errors.New("unarchive: src and dest required")
|
||||
}
|
||||
|
||||
// Create dest directory (best-effort)
|
||||
|
|
@ -1117,7 +1118,7 @@ func getBoolArg(args map[string]any, key string, def bool) bool {
|
|||
func (e *Executor) moduleHostname(ctx context.Context, client *SSHClient, args map[string]any) (*TaskResult, error) {
|
||||
name := getStringArg(args, "name", "")
|
||||
if name == "" {
|
||||
return nil, fmt.Errorf("hostname: name required")
|
||||
return nil, errors.New("hostname: name required")
|
||||
}
|
||||
|
||||
// Set hostname
|
||||
|
|
@ -1139,7 +1140,7 @@ func (e *Executor) moduleSysctl(ctx context.Context, client *SSHClient, args map
|
|||
state := getStringArg(args, "state", "present")
|
||||
|
||||
if name == "" {
|
||||
return nil, fmt.Errorf("sysctl: name required")
|
||||
return nil, errors.New("sysctl: name required")
|
||||
}
|
||||
|
||||
if state == "absent" {
|
||||
|
|
@ -1209,7 +1210,7 @@ func (e *Executor) moduleBlockinfile(ctx context.Context, client *SSHClient, arg
|
|||
path = getStringArg(args, "dest", "")
|
||||
}
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("blockinfile: path required")
|
||||
return nil, errors.New("blockinfile: path required")
|
||||
}
|
||||
|
||||
block := getStringArg(args, "block", "")
|
||||
|
|
@ -1357,7 +1358,7 @@ func (e *Executor) moduleAuthorizedKey(ctx context.Context, client *SSHClient, a
|
|||
state := getStringArg(args, "state", "present")
|
||||
|
||||
if user == "" || key == "" {
|
||||
return nil, fmt.Errorf("authorized_key: user and key required")
|
||||
return nil, errors.New("authorized_key: user and key required")
|
||||
}
|
||||
|
||||
// Get user's home directory
|
||||
|
|
@ -1407,7 +1408,7 @@ func (e *Executor) moduleDockerCompose(ctx context.Context, client *SSHClient, a
|
|||
state := getStringArg(args, "state", "present")
|
||||
|
||||
if projectSrc == "" {
|
||||
return nil, fmt.Errorf("docker_compose: project_src required")
|
||||
return nil, errors.New("docker_compose: project_src required")
|
||||
}
|
||||
|
||||
var cmd string
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ import (
|
|||
"archive/zip"
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Snider/Borg/pkg/compress"
|
||||
io_interface "forge.lthn.ai/core/go/pkg/io"
|
||||
"github.com/Snider/Borg/pkg/compress"
|
||||
)
|
||||
|
||||
// ArchiveFormat specifies the compression format for archives.
|
||||
|
|
@ -48,7 +49,7 @@ func ArchiveXZ(fs io_interface.Medium, artifact Artifact) (Artifact, error) {
|
|||
// Returns a new Artifact with Path pointing to the archive.
|
||||
func ArchiveWithFormat(fs io_interface.Medium, artifact Artifact, format ArchiveFormat) (Artifact, error) {
|
||||
if artifact.Path == "" {
|
||||
return Artifact{}, fmt.Errorf("build.Archive: artifact path is empty")
|
||||
return Artifact{}, errors.New("build.Archive: artifact path is empty")
|
||||
}
|
||||
|
||||
// Verify the source file exists
|
||||
|
|
@ -57,7 +58,7 @@ func ArchiveWithFormat(fs io_interface.Medium, artifact Artifact, format Archive
|
|||
return Artifact{}, fmt.Errorf("build.Archive: source file not found: %w", err)
|
||||
}
|
||||
if info.IsDir() {
|
||||
return Artifact{}, fmt.Errorf("build.Archive: source path is a directory, expected file")
|
||||
return Artifact{}, errors.New("build.Archive: source path is a directory, expected file")
|
||||
}
|
||||
|
||||
// Determine archive type based on OS and format
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package builders
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -38,7 +39,7 @@ func (b *CPPBuilder) Detect(fs io.Medium, dir string) (bool, error) {
|
|||
// Cross-compilation is handled via Conan profiles specified in .core/build.yaml.
|
||||
func (b *CPPBuilder) Build(ctx context.Context, cfg *build.Config, targets []build.Target) ([]build.Artifact, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("builders.CPPBuilder.Build: config is nil")
|
||||
return nil, errors.New("builders.CPPBuilder.Build: config is nil")
|
||||
}
|
||||
|
||||
// Validate make is available
|
||||
|
|
@ -244,7 +245,7 @@ func (b *CPPBuilder) targetToProfile(target build.Target) string {
|
|||
// validateMake checks if make is available.
|
||||
func (b *CPPBuilder) validateMake() error {
|
||||
if _, err := exec.LookPath("make"); err != nil {
|
||||
return fmt.Errorf("cpp: make not found. Install build-essential (Linux) or Xcode Command Line Tools (macOS)")
|
||||
return errors.New("cpp: make not found. Install build-essential (Linux) or Xcode Command Line Tools (macOS)")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package builders
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -186,7 +187,7 @@ func (b *DockerBuilder) Build(ctx context.Context, cfg *build.Config, targets []
|
|||
func (b *DockerBuilder) validateDockerCli() error {
|
||||
cmd := exec.Command("docker", "--version")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("docker: docker CLI not found. Install it from https://docs.docker.com/get-docker/")
|
||||
return errors.New("docker: docker CLI not found. Install it from https://docs.docker.com/get-docker/")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -196,7 +197,7 @@ func (b *DockerBuilder) ensureBuildx(ctx context.Context) error {
|
|||
// Check if buildx is available
|
||||
cmd := exec.CommandContext(ctx, "docker", "buildx", "version")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("docker: buildx is not available. Install it from https://docs.docker.com/buildx/working-with-buildx/")
|
||||
return errors.New("docker: buildx is not available. Install it from https://docs.docker.com/buildx/working-with-buildx/")
|
||||
}
|
||||
|
||||
// Check if we have a builder, create one if not
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package builders
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -37,11 +38,11 @@ func (b *GoBuilder) Detect(fs io.Medium, dir string) (bool, error) {
|
|||
// applies ldflags and trimpath, and runs go build.
|
||||
func (b *GoBuilder) Build(ctx context.Context, cfg *build.Config, targets []build.Target) ([]build.Artifact, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("builders.GoBuilder.Build: config is nil")
|
||||
return nil, errors.New("builders.GoBuilder.Build: config is nil")
|
||||
}
|
||||
|
||||
if len(targets) == 0 {
|
||||
return nil, fmt.Errorf("builders.GoBuilder.Build: no targets specified")
|
||||
return nil, errors.New("builders.GoBuilder.Build: no targets specified")
|
||||
}
|
||||
|
||||
// Ensure output directory exists
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package builders
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -78,7 +79,7 @@ func (b *LinuxKitBuilder) Build(ctx context.Context, cfg *build.Config, targets
|
|||
}
|
||||
|
||||
if configPath == "" {
|
||||
return nil, fmt.Errorf("linuxkit.Build: no LinuxKit config file found. Specify with --config or create linuxkit.yml")
|
||||
return nil, errors.New("linuxkit.Build: no LinuxKit config file found. Specify with --config or create linuxkit.yml")
|
||||
}
|
||||
|
||||
// Validate config file exists
|
||||
|
|
@ -266,5 +267,5 @@ func (b *LinuxKitBuilder) validateLinuxKitCli() error {
|
|||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("linuxkit: linuxkit CLI not found. Install with: brew install linuxkit (macOS) or see https://github.com/linuxkit/linuxkit")
|
||||
return errors.New("linuxkit: linuxkit CLI not found. Install with: brew install linuxkit (macOS) or see https://github.com/linuxkit/linuxkit")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package builders
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -271,5 +272,5 @@ func (b *TaskfileBuilder) validateTaskCli() error {
|
|||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("taskfile: task CLI not found. Install with: brew install go-task (macOS), go install github.com/go-task/task/v3/cmd/task@latest, or see https://taskfile.dev/installation/")
|
||||
return errors.New("taskfile: task CLI not found. Install with: brew install go-task (macOS), go install github.com/go-task/task/v3/cmd/task@latest, or see https://taskfile.dev/installation/")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package builders
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -37,11 +38,11 @@ func (b *WailsBuilder) Detect(fs io.Medium, dir string) (bool, error) {
|
|||
// - Wails v2: Uses 'wails build' command
|
||||
func (b *WailsBuilder) Build(ctx context.Context, cfg *build.Config, targets []build.Target) ([]build.Artifact, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("builders.WailsBuilder.Build: config is nil")
|
||||
return nil, errors.New("builders.WailsBuilder.Build: config is nil")
|
||||
}
|
||||
|
||||
if len(targets) == 0 {
|
||||
return nil, fmt.Errorf("builders.WailsBuilder.Build: no targets specified")
|
||||
return nil, errors.New("builders.WailsBuilder.Build: no targets specified")
|
||||
}
|
||||
|
||||
// Detect Wails version
|
||||
|
|
@ -53,7 +54,7 @@ func (b *WailsBuilder) Build(ctx context.Context, cfg *build.Config, targets []b
|
|||
if detected, _ := taskBuilder.Detect(cfg.FS, cfg.ProjectDir); detected {
|
||||
return taskBuilder.Build(ctx, cfg, targets)
|
||||
}
|
||||
return nil, fmt.Errorf("wails v3 projects require a Taskfile for building")
|
||||
return nil, errors.New("wails v3 projects require a Taskfile for building")
|
||||
}
|
||||
|
||||
// Wails v2 strategy: Use 'wails build'
|
||||
|
|
|
|||
|
|
@ -4,19 +4,21 @@ package build
|
|||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
io_interface "forge.lthn.ai/core/go/pkg/io"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
io_interface "forge.lthn.ai/core/go/pkg/io"
|
||||
)
|
||||
|
||||
// Checksum computes SHA256 for an artifact and returns the artifact with the Checksum field filled.
|
||||
func Checksum(fs io_interface.Medium, artifact Artifact) (Artifact, error) {
|
||||
if artifact.Path == "" {
|
||||
return Artifact{}, fmt.Errorf("build.Checksum: artifact path is empty")
|
||||
return Artifact{}, errors.New("build.Checksum: artifact path is empty")
|
||||
}
|
||||
|
||||
// Open the file
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package signing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
|
@ -42,7 +43,7 @@ func (s *MacOSSigner) Available() bool {
|
|||
// Sign codesigns a binary with hardened runtime.
|
||||
func (s *MacOSSigner) Sign(ctx context.Context, fs io.Medium, binary string) error {
|
||||
if !s.Available() {
|
||||
return fmt.Errorf("codesign.Sign: codesign not available")
|
||||
return errors.New("codesign.Sign: codesign not available")
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, "codesign",
|
||||
|
|
@ -65,7 +66,7 @@ func (s *MacOSSigner) Sign(ctx context.Context, fs io.Medium, binary string) err
|
|||
// This blocks until Apple responds (typically 1-5 minutes).
|
||||
func (s *MacOSSigner) Notarize(ctx context.Context, fs io.Medium, binary string) error {
|
||||
if s.config.AppleID == "" || s.config.TeamID == "" || s.config.AppPassword == "" {
|
||||
return fmt.Errorf("codesign.Notarize: missing Apple credentials (apple_id, team_id, app_password)")
|
||||
return errors.New("codesign.Notarize: missing Apple credentials (apple_id, team_id, app_password)")
|
||||
}
|
||||
|
||||
// Create ZIP for submission
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package signing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ func (s *GPGSigner) Available() bool {
|
|||
// For file.txt, creates file.txt.asc
|
||||
func (s *GPGSigner) Sign(ctx context.Context, fs io.Medium, file string) error {
|
||||
if !s.Available() {
|
||||
return fmt.Errorf("gpg.Sign: gpg not available or key not configured")
|
||||
return errors.New("gpg.Sign: gpg not available or key not configured")
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, "gpg",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package signing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ func NotarizeBinaries(ctx context.Context, fs io.Medium, cfg SignConfig, artifac
|
|||
|
||||
signer := NewMacOSSigner(cfg.MacOS)
|
||||
if !signer.Available() {
|
||||
return fmt.Errorf("notarization requested but codesign not available")
|
||||
return errors.New("notarization requested but codesign not available")
|
||||
}
|
||||
|
||||
for _, artifact := range artifacts {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package prod
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
|
@ -56,7 +57,7 @@ func getDNSClient() (*infra.CloudNSClient, error) {
|
|||
authID := os.Getenv("CLOUDNS_AUTH_ID")
|
||||
authPass := os.Getenv("CLOUDNS_AUTH_PASSWORD")
|
||||
if authID == "" || authPass == "" {
|
||||
return nil, fmt.Errorf("CLOUDNS_AUTH_ID and CLOUDNS_AUTH_PASSWORD required")
|
||||
return nil, errors.New("CLOUDNS_AUTH_ID and CLOUDNS_AUTH_PASSWORD required")
|
||||
}
|
||||
return infra.NewCloudNSClient(authID, authPass), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package prod
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
|
@ -39,7 +40,7 @@ func init() {
|
|||
func getHCloudClient() (*infra.HCloudClient, error) {
|
||||
token := os.Getenv("HCLOUD_TOKEN")
|
||||
if token == "" {
|
||||
return nil, fmt.Errorf("HCLOUD_TOKEN environment variable required")
|
||||
return nil, errors.New("HCLOUD_TOKEN environment variable required")
|
||||
}
|
||||
return infra.NewHCloudClient(token), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package prod
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
|
@ -141,7 +142,7 @@ func stepDiscover(ctx context.Context, cfg *infra.Config) error {
|
|||
func stepLoadBalancer(ctx context.Context, cfg *infra.Config) error {
|
||||
hcloudToken := os.Getenv("HCLOUD_TOKEN")
|
||||
if hcloudToken == "" {
|
||||
return fmt.Errorf("HCLOUD_TOKEN required for load balancer management")
|
||||
return errors.New("HCLOUD_TOKEN required for load balancer management")
|
||||
}
|
||||
|
||||
hc := infra.NewHCloudClient(hcloudToken)
|
||||
|
|
@ -237,7 +238,7 @@ func stepDNS(ctx context.Context, cfg *infra.Config) error {
|
|||
authID := os.Getenv("CLOUDNS_AUTH_ID")
|
||||
authPass := os.Getenv("CLOUDNS_AUTH_PASSWORD")
|
||||
if authID == "" || authPass == "" {
|
||||
return fmt.Errorf("CLOUDNS_AUTH_ID and CLOUDNS_AUTH_PASSWORD required")
|
||||
return errors.New("CLOUDNS_AUTH_ID and CLOUDNS_AUTH_PASSWORD required")
|
||||
}
|
||||
|
||||
dns := infra.NewCloudNSClient(authID, authPass)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package container
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -249,7 +250,7 @@ func DetectHypervisor() (Hypervisor, error) {
|
|||
return qemu, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no hypervisor available: install qemu or hyperkit (macOS)")
|
||||
return nil, errors.New("no hypervisor available: install qemu or hyperkit (macOS)")
|
||||
}
|
||||
|
||||
// GetHypervisor returns a specific hypervisor by name.
|
||||
|
|
@ -258,13 +259,13 @@ func GetHypervisor(name string) (Hypervisor, error) {
|
|||
case "qemu":
|
||||
h := NewQemuHypervisor()
|
||||
if !h.Available() {
|
||||
return nil, fmt.Errorf("qemu is not available")
|
||||
return nil, errors.New("qemu is not available")
|
||||
}
|
||||
return h, nil
|
||||
case "hyperkit":
|
||||
h := NewHyperkitHypervisor()
|
||||
if !h.Available() {
|
||||
return nil, fmt.Errorf("hyperkit is not available (requires macOS)")
|
||||
return nil, errors.New("hyperkit is not available (requires macOS)")
|
||||
}
|
||||
return h, nil
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package coolify
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
|
@ -41,10 +42,10 @@ func DefaultConfig() Config {
|
|||
// NewClient creates a new Coolify client.
|
||||
func NewClient(cfg Config) (*Client, error) {
|
||||
if cfg.BaseURL == "" {
|
||||
return nil, fmt.Errorf("COOLIFY_URL not set")
|
||||
return nil, errors.New("COOLIFY_URL not set")
|
||||
}
|
||||
if cfg.APIToken == "" {
|
||||
return nil, fmt.Errorf("COOLIFY_TOKEN not set")
|
||||
return nil, errors.New("COOLIFY_TOKEN not set")
|
||||
}
|
||||
|
||||
// Initialize Python runtime
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package devops
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -116,14 +117,14 @@ func DefaultBootOptions() BootOptions {
|
|||
// Boot starts the dev environment.
|
||||
func (d *DevOps) Boot(ctx context.Context, opts BootOptions) error {
|
||||
if !d.images.IsInstalled() {
|
||||
return fmt.Errorf("dev image not installed (run 'core dev install' first)")
|
||||
return errors.New("dev image not installed (run 'core dev install' first)")
|
||||
}
|
||||
|
||||
// Check if already running
|
||||
if !opts.Fresh {
|
||||
running, err := d.IsRunning(ctx)
|
||||
if err == nil && running {
|
||||
return fmt.Errorf("dev environment already running (use 'core dev stop' first or --fresh)")
|
||||
return errors.New("dev environment already running (use 'core dev stop' first or --fresh)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +178,7 @@ func (d *DevOps) Stop(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
if c == nil {
|
||||
return fmt.Errorf("dev environment not found")
|
||||
return errors.New("dev environment not found")
|
||||
}
|
||||
return d.container.Stop(ctx, c.ID)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package devops
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -109,7 +110,7 @@ func (m *ImageManager) Install(ctx context.Context, progress func(downloaded, to
|
|||
}
|
||||
}
|
||||
if src == nil {
|
||||
return fmt.Errorf("no image source available")
|
||||
return errors.New("no image source available")
|
||||
}
|
||||
|
||||
// Get version
|
||||
|
|
@ -139,7 +140,7 @@ func (m *ImageManager) Install(ctx context.Context, progress func(downloaded, to
|
|||
func (m *ImageManager) CheckUpdate(ctx context.Context) (current, latest string, hasUpdate bool, err error) {
|
||||
info, ok := m.manifest.Images[ImageName()]
|
||||
if !ok {
|
||||
return "", "", false, fmt.Errorf("image not installed")
|
||||
return "", "", false, errors.New("image not installed")
|
||||
}
|
||||
current = info.Version
|
||||
|
||||
|
|
@ -152,7 +153,7 @@ func (m *ImageManager) CheckUpdate(ctx context.Context) (current, latest string,
|
|||
}
|
||||
}
|
||||
if src == nil {
|
||||
return current, "", false, fmt.Errorf("no image source available")
|
||||
return current, "", false, errors.New("no image source available")
|
||||
}
|
||||
|
||||
latest, err = src.LatestVersion(ctx)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package devops
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -23,7 +24,7 @@ func (d *DevOps) Serve(ctx context.Context, projectDir string, opts ServeOptions
|
|||
return err
|
||||
}
|
||||
if !running {
|
||||
return fmt.Errorf("dev environment not running (run 'core dev boot' first)")
|
||||
return errors.New("dev environment not running (run 'core dev boot' first)")
|
||||
}
|
||||
|
||||
if opts.Port == 0 {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package devops
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -20,7 +21,7 @@ func (d *DevOps) Shell(ctx context.Context, opts ShellOptions) error {
|
|||
return err
|
||||
}
|
||||
if !running {
|
||||
return fmt.Errorf("dev environment not running (run 'core dev boot' first)")
|
||||
return errors.New("dev environment not running (run 'core dev boot' first)")
|
||||
}
|
||||
|
||||
if opts.Console {
|
||||
|
|
@ -61,7 +62,7 @@ func (d *DevOps) serialConsole(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
if c == nil {
|
||||
return fmt.Errorf("console not available: container not found")
|
||||
return errors.New("console not available: container not found")
|
||||
}
|
||||
|
||||
// Use socat to connect to the console socket
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package devops
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -37,7 +38,7 @@ func ensureHostKey(ctx context.Context, port int) error {
|
|||
}
|
||||
|
||||
if len(out) == 0 {
|
||||
return fmt.Errorf("ssh-keyscan returned no keys")
|
||||
return errors.New("ssh-keyscan returned no keys")
|
||||
}
|
||||
|
||||
// Read existing known_hosts to avoid duplicates
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package devops
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -38,7 +39,7 @@ func (d *DevOps) Test(ctx context.Context, projectDir string, opts TestOptions)
|
|||
return err
|
||||
}
|
||||
if !running {
|
||||
return fmt.Errorf("dev environment not running (run 'core dev boot' first)")
|
||||
return errors.New("dev environment not running (run 'core dev boot' first)")
|
||||
}
|
||||
|
||||
var cmd string
|
||||
|
|
@ -63,7 +64,7 @@ func (d *DevOps) Test(ctx context.Context, projectDir string, opts TestOptions)
|
|||
} else {
|
||||
cmd = DetectTestCommand(d.medium, projectDir)
|
||||
if cmd == "" {
|
||||
return fmt.Errorf("could not detect test command (create .core/test.yaml)")
|
||||
return errors.New("could not detect test command (create .core/test.yaml)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -47,7 +48,7 @@ func (p *AURPublisher) Publish(ctx context.Context, release *Release, pubCfg Pub
|
|||
cfg := p.parseConfig(pubCfg, relCfg)
|
||||
|
||||
if cfg.Maintainer == "" {
|
||||
return fmt.Errorf("aur.Publish: maintainer is required (set publish.aur.maintainer in config)")
|
||||
return errors.New("aur.Publish: maintainer is required (set publish.aur.maintainer in config)")
|
||||
}
|
||||
|
||||
repo := ""
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -231,7 +232,7 @@ func (p *ChocolateyPublisher) pushToChocolatey(ctx context.Context, packageDir s
|
|||
// Check for CHOCOLATEY_API_KEY
|
||||
apiKey := os.Getenv("CHOCOLATEY_API_KEY")
|
||||
if apiKey == "" {
|
||||
return fmt.Errorf("chocolatey.Publish: CHOCOLATEY_API_KEY environment variable is required for push")
|
||||
return errors.New("chocolatey.Publish: CHOCOLATEY_API_KEY environment variable is required for push")
|
||||
}
|
||||
|
||||
// Pack the package
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package publishers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -250,7 +251,7 @@ func (p *DockerPublisher) ensureBuildx(ctx context.Context) error {
|
|||
// Check if buildx is available
|
||||
cmd := exec.CommandContext(ctx, "docker", "buildx", "version")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("docker: buildx is not available. Install it from https://docs.docker.com/buildx/working-with-buildx/")
|
||||
return errors.New("docker: buildx is not available. Install it from https://docs.docker.com/buildx/working-with-buildx/")
|
||||
}
|
||||
|
||||
// Check if we have a builder, create one if not
|
||||
|
|
@ -272,7 +273,7 @@ func (p *DockerPublisher) ensureBuildx(ctx context.Context) error {
|
|||
func validateDockerCli() error {
|
||||
cmd := exec.Command("docker", "--version")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("docker: docker CLI not found. Install it from https://docs.docker.com/get-docker/")
|
||||
return errors.New("docker: docker CLI not found. Install it from https://docs.docker.com/get-docker/")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package publishers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -146,18 +147,18 @@ func validateGhCli() error {
|
|||
// Check if gh is installed
|
||||
cmd := exec.Command("gh", "--version")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("github: gh CLI not found. Install it from https://cli.github.com")
|
||||
return errors.New("github: gh CLI not found. Install it from https://cli.github.com")
|
||||
}
|
||||
|
||||
// Check if authenticated
|
||||
cmd = exec.Command("gh", "auth", "status")
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("github: not authenticated with gh CLI. Run 'gh auth login' first")
|
||||
return errors.New("github: not authenticated with gh CLI. Run 'gh auth login' first")
|
||||
}
|
||||
|
||||
if !strings.Contains(string(output), "Logged in") {
|
||||
return fmt.Errorf("github: not authenticated with gh CLI. Run 'gh auth login' first")
|
||||
return errors.New("github: not authenticated with gh CLI. Run 'gh auth login' first")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -57,7 +58,7 @@ func (p *HomebrewPublisher) Publish(ctx context.Context, release *Release, pubCf
|
|||
|
||||
// Validate configuration
|
||||
if cfg.Tap == "" && (cfg.Official == nil || !cfg.Official.Enabled) {
|
||||
return fmt.Errorf("homebrew.Publish: tap is required (set publish.homebrew.tap in config)")
|
||||
return errors.New("homebrew.Publish: tap is required (set publish.homebrew.tap in config)")
|
||||
}
|
||||
|
||||
// Get repository and project info
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package publishers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -48,7 +49,7 @@ func (p *LinuxKitPublisher) Publish(ctx context.Context, release *Release, pubCf
|
|||
|
||||
// Validate config file exists
|
||||
if release.FS == nil {
|
||||
return fmt.Errorf("linuxkit.Publish: release filesystem (FS) is nil")
|
||||
return errors.New("linuxkit.Publish: release filesystem (FS) is nil")
|
||||
}
|
||||
if !release.FS.Exists(lkCfg.Config) {
|
||||
return fmt.Errorf("linuxkit.Publish: config file not found: %s", lkCfg.Config)
|
||||
|
|
@ -297,7 +298,7 @@ func (p *LinuxKitPublisher) getFormatExtension(format string) string {
|
|||
func validateLinuxKitCli() error {
|
||||
cmd := exec.Command("linuxkit", "version")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("linuxkit: linuxkit CLI not found. Install it from https://github.com/linuxkit/linuxkit")
|
||||
return errors.New("linuxkit: linuxkit CLI not found. Install it from https://github.com/linuxkit/linuxkit")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -47,7 +48,7 @@ func (p *NpmPublisher) Publish(ctx context.Context, release *Release, pubCfg Pub
|
|||
|
||||
// Validate configuration
|
||||
if npmCfg.Package == "" {
|
||||
return fmt.Errorf("npm.Publish: package name is required (set publish.npm.package in config)")
|
||||
return errors.New("npm.Publish: package name is required (set publish.npm.package in config)")
|
||||
}
|
||||
|
||||
// Get repository
|
||||
|
|
@ -162,7 +163,7 @@ func (p *NpmPublisher) dryRunPublish(m io.Medium, data npmTemplateData, cfg *Npm
|
|||
func (p *NpmPublisher) executePublish(ctx context.Context, m io.Medium, data npmTemplateData, cfg *NpmConfig) error {
|
||||
// Check for NPM_TOKEN
|
||||
if os.Getenv("NPM_TOKEN") == "" {
|
||||
return fmt.Errorf("npm.Publish: NPM_TOKEN environment variable is required")
|
||||
return errors.New("npm.Publish: NPM_TOKEN environment variable is required")
|
||||
}
|
||||
|
||||
// Create temp directory for package
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -45,7 +46,7 @@ func (p *ScoopPublisher) Publish(ctx context.Context, release *Release, pubCfg P
|
|||
cfg := p.parseConfig(pubCfg, relCfg)
|
||||
|
||||
if cfg.Bucket == "" && (cfg.Official == nil || !cfg.Official.Enabled) {
|
||||
return fmt.Errorf("scoop.Publish: bucket is required (set publish.scoop.bucket in config)")
|
||||
return errors.New("scoop.Publish: bucket is required (set publish.scoop.bucket in config)")
|
||||
}
|
||||
|
||||
repo := ""
|
||||
|
|
|
|||
|
|
@ -5,14 +5,15 @@ package release
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"forge.lthn.ai/core/go-devops/build"
|
||||
"forge.lthn.ai/core/go-devops/build/builders"
|
||||
"forge.lthn.ai/core/go/pkg/io"
|
||||
"forge.lthn.ai/core/go-devops/release/publishers"
|
||||
"forge.lthn.ai/core/go/pkg/io"
|
||||
)
|
||||
|
||||
// Release represents a release with its version, artifacts, and changelog.
|
||||
|
|
@ -34,7 +35,7 @@ type Release struct {
|
|||
// If dryRun is true, it will show what would be done without actually publishing.
|
||||
func Publish(ctx context.Context, cfg *Config, dryRun bool) (*Release, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("release.Publish: config is nil")
|
||||
return nil, errors.New("release.Publish: config is nil")
|
||||
}
|
||||
|
||||
m := io.Local
|
||||
|
|
@ -67,7 +68,7 @@ func Publish(ctx context.Context, cfg *Config, dryRun bool) (*Release, error) {
|
|||
}
|
||||
|
||||
if len(artifacts) == 0 {
|
||||
return nil, fmt.Errorf("release.Publish: no artifacts found in dist/\nRun 'core build' first to create artifacts")
|
||||
return nil, errors.New("release.Publish: no artifacts found in dist/\nRun 'core build' first to create artifacts")
|
||||
}
|
||||
|
||||
// Step 3: Generate changelog
|
||||
|
|
@ -109,7 +110,7 @@ func Publish(ctx context.Context, cfg *Config, dryRun bool) (*Release, error) {
|
|||
// findArtifacts discovers pre-built artifacts in the dist directory.
|
||||
func findArtifacts(m io.Medium, distDir string) ([]build.Artifact, error) {
|
||||
if !m.IsDir(distDir) {
|
||||
return nil, fmt.Errorf("dist/ directory not found")
|
||||
return nil, errors.New("dist/ directory not found")
|
||||
}
|
||||
|
||||
var artifacts []build.Artifact
|
||||
|
|
@ -145,7 +146,7 @@ func findArtifacts(m io.Medium, distDir string) ([]build.Artifact, error) {
|
|||
// If dryRun is true, it will show what would be done without actually publishing.
|
||||
func Run(ctx context.Context, cfg *Config, dryRun bool) (*Release, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("release.Run: config is nil")
|
||||
return nil, errors.New("release.Run: config is nil")
|
||||
}
|
||||
|
||||
m := io.Local
|
||||
|
|
@ -317,9 +318,9 @@ func getBuilder(projectType build.ProjectType) (build.Builder, error) {
|
|||
case build.ProjectTypeGo:
|
||||
return builders.NewGoBuilder(), nil
|
||||
case build.ProjectTypeNode:
|
||||
return nil, fmt.Errorf("node.js builder not yet implemented")
|
||||
return nil, errors.New("node.js builder not yet implemented")
|
||||
case build.ProjectTypePHP:
|
||||
return nil, fmt.Errorf("PHP builder not yet implemented")
|
||||
return nil, errors.New("PHP builder not yet implemented")
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported project type: %s", projectType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package release
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"forge.lthn.ai/core/go-devops/sdk"
|
||||
|
|
@ -22,10 +23,10 @@ type SDKRelease struct {
|
|||
// If dryRun is true, it shows what would be done without generating.
|
||||
func RunSDK(ctx context.Context, cfg *Config, dryRun bool) (*SDKRelease, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("release.RunSDK: config is nil")
|
||||
return nil, errors.New("release.RunSDK: config is nil")
|
||||
}
|
||||
if cfg.SDK == nil {
|
||||
return nil, fmt.Errorf("release.RunSDK: sdk not configured in .core/release.yaml")
|
||||
return nil, errors.New("release.RunSDK: sdk not configured in .core/release.yaml")
|
||||
}
|
||||
|
||||
projectDir := cfg.projectDir
|
||||
|
|
@ -51,7 +52,7 @@ func RunSDK(ctx context.Context, cfg *Config, dryRun bool) (*SDKRelease, error)
|
|||
fmt.Printf("Warning: diff check failed: %v\n", err)
|
||||
} else if breaking {
|
||||
if cfg.SDK.Diff.FailOnBreaking {
|
||||
return nil, fmt.Errorf("release.RunSDK: breaking API changes detected")
|
||||
return nil, errors.New("release.RunSDK: breaking API changes detected")
|
||||
}
|
||||
fmt.Printf("Warning: breaking API changes detected\n")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package sdk
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -46,14 +47,14 @@ func (s *SDK) DetectSpec() (string, error) {
|
|||
return specPath, nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("sdk.DetectSpec: no OpenAPI spec found (checked config, common paths, Scramble)")
|
||||
return "", errors.New("sdk.DetectSpec: no OpenAPI spec found (checked config, common paths, Scramble)")
|
||||
}
|
||||
|
||||
// detectScramble checks for Laravel Scramble and exports the spec.
|
||||
func (s *SDK) detectScramble() (string, error) {
|
||||
composerPath := filepath.Join(s.projectDir, "composer.json")
|
||||
if !coreio.Local.IsFile(composerPath) {
|
||||
return "", fmt.Errorf("no composer.json")
|
||||
return "", errors.New("no composer.json")
|
||||
}
|
||||
|
||||
// Check for scramble in composer.json
|
||||
|
|
@ -64,11 +65,11 @@ func (s *SDK) detectScramble() (string, error) {
|
|||
|
||||
// Simple check for scramble package
|
||||
if !containsScramble(data) {
|
||||
return "", fmt.Errorf("scramble not found in composer.json")
|
||||
return "", errors.New("scramble not found in composer.json")
|
||||
}
|
||||
|
||||
// TODO: Run php artisan scramble:export
|
||||
return "", fmt.Errorf("scramble export not implemented")
|
||||
return "", errors.New("scramble export not implemented")
|
||||
}
|
||||
|
||||
// containsScramble checks if composer.json includes scramble.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package generators
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -37,7 +38,7 @@ func (g *PHPGenerator) Install() string {
|
|||
// Generate creates SDK from OpenAPI spec.
|
||||
func (g *PHPGenerator) Generate(ctx context.Context, opts Options) error {
|
||||
if !g.Available() {
|
||||
return fmt.Errorf("php.Generate: Docker is required but not available")
|
||||
return errors.New("php.Generate: Docker is required but not available")
|
||||
}
|
||||
|
||||
if err := coreio.Local.EnsureDir(opts.OutputDir); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue