Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .devcontainer/Dockerfile

This file was deleted.

22 changes: 10 additions & 12 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.217.4/containers/go
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "Go",
"build": {
"dockerfile": "Dockerfile"
},
"image": "mcr.microsoft.com/devcontainers/go:1.24-bookworm",
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"features": {
// Pins golangci-lint to match version expected by .golangci.yaml
"ghcr.io/guiyomh/features/golangci-lint:0": {}
},
"customizations": {
"vscode": {
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go"
"go.goroot": "/usr/local/go",
"go.lintTool": "golangci-lint",
"go.lintOnSave": "workspace",
"go.formatTool": "goimports"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
1 change: 0 additions & 1 deletion .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ jobs:
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options

1 change: 0 additions & 1 deletion .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ jobs:
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr:*)'

30 changes: 8 additions & 22 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,6 @@ linters:
# Default: []
disable:
- fieldalignment # too strict
# Settings per analyzer.
settings:
shadow:
# Whether to be strict about shadowing; can be noisy.
# Default: false
strict: true

inamedparam:
# Skips check for interface methods with only a single parameter.
Expand Down Expand Up @@ -376,7 +370,8 @@ linters:
# - "default": report only the default slog logger
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global
# Default: ""
no-global: all
# Disabled: server package is intentionally designed around a global structured logger
no-global: ""
# Enforce using methods that accept a context.
# Values:
# - "": disabled
Expand Down Expand Up @@ -421,22 +416,13 @@ linters:
# Allow unused params at the cobra command level
- linters: [revive]
text: "unused-parameter: parameter ('cmd'|'args') seems to be unused, consider removing or renaming it as _"
# GQL client autogens to artifactId and orgId
- linters: [revive]
text: "var-naming: var artifactId should be artifactID"
# 'api' is a domain-appropriate package name for this layer; revive flags it as "meaningless"
- linters: [revive]
text: "var-naming: (var|func parameter) orgId should be orgID"
- linters: [stylecheck]
text: "ST1003: func parameter orgId should be orgID"
- source: "^//\\s*go:generate\\s"
linters: [lll]
# Allow TODO for now
- source: "(noinspection|TODO)"
linters: [godox]
- source: "//noinspection"
linters: [gocritic]
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
linters: [errorlint]
text: "var-naming: avoid meaningless package names"
path: "pkg/api/"
# cmd/ uses "json"/"text" as CLI output-format literals; extracting them as constants adds no value
- linters: [goconst]
path: "^cmd/"
- path: "_test\\.go"
linters:
- revive
Expand Down
4 changes: 3 additions & 1 deletion cmd/application.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package cmd
// Package cmd provides the CLI commands for the mass tool.
package cmd //nolint:dupl // application and infrastructure are intentionally duplicated deprecated compatibility shims

import (
"github.com/spf13/cobra"
)

// NewCmdApp returns a deprecated cobra command for managing applications (renamed to package).
func NewCmdApp() *cobra.Command {
appCmd := &cobra.Command{
Use: "application",
Expand Down
20 changes: 11 additions & 9 deletions cmd/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
//go:embed templates/artifact.get.md.tmpl
var artifactTemplates embed.FS

// NewCmdArtifact returns a cobra command for managing artifacts.
func NewCmdArtifact() *cobra.Command {
artifactCmd := &cobra.Command{
Use: "artifact",
Expand All @@ -37,9 +38,9 @@ func NewCmdArtifact() *cobra.Command {
artifactImportCmd.Flags().StringP("name", "n", "", "Artifact name")
artifactImportCmd.Flags().StringP("type", "t", "", "Artifact type")
artifactImportCmd.Flags().StringP("file", "f", "", "Artifact file")
artifactImportCmd.MarkFlagRequired("name")
artifactImportCmd.MarkFlagRequired("type")
artifactImportCmd.MarkFlagRequired("file")
_ = artifactImportCmd.MarkFlagRequired("name")
_ = artifactImportCmd.MarkFlagRequired("type")
_ = artifactImportCmd.MarkFlagRequired("file")

// Get
artifactGetCmd := &cobra.Command{
Expand Down Expand Up @@ -88,7 +89,7 @@ func NewCmdArtifact() *cobra.Command {
}
artifactUpdateCmd.Flags().StringP("name", "n", "", "New artifact name")
artifactUpdateCmd.Flags().StringP("file", "f", "", "Artifact payload file")
artifactUpdateCmd.MarkFlagRequired("file")
_ = artifactUpdateCmd.MarkFlagRequired("file")

artifactCmd.AddCommand(artifactImportCmd)
artifactCmd.AddCommand(artifactGetCmd)
Expand Down Expand Up @@ -153,6 +154,7 @@ func runArtifactUpdate(cmd *cobra.Command, args []string) error {
return updateErr
}

//nolint:dupl // runArtifactGet and runDefinitionGet share the same output-format pattern; refactoring would add complexity for marginal gain
func runArtifactGet(cmd *cobra.Command, args []string) error {
ctx := context.Background()

Expand All @@ -175,9 +177,9 @@ func runArtifactGet(cmd *cobra.Command, args []string) error {

switch outputFormat {
case "json":
jsonBytes, err := json.MarshalIndent(artifact, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal artifact to JSON: %w", err)
jsonBytes, marshalErr := json.MarshalIndent(artifact, "", " ")
if marshalErr != nil {
return fmt.Errorf("failed to marshal artifact to JSON: %w", marshalErr)
}
fmt.Println(string(jsonBytes))
case "text":
Expand Down Expand Up @@ -262,8 +264,8 @@ func renderArtifact(artifact *api.Artifact) error {
}

var buf bytes.Buffer
if err := tmpl.Execute(&buf, data); err != nil {
return fmt.Errorf("failed to execute template: %w", err)
if renderErr := tmpl.Execute(&buf, data); renderErr != nil {
return fmt.Errorf("failed to execute template: %w", renderErr)
}

r, err := glamour.NewTermRenderer(glamour.WithAutoStyle())
Expand Down
31 changes: 17 additions & 14 deletions cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ type bundleList struct {
output string
}

func NewCmdBundle() *cobra.Command {
// NewCmdBundle returns a cobra command for generating and publishing bundles.
func NewCmdBundle() *cobra.Command { //nolint:funlen // cobra command builders are necessarily long
bundleCmd := &cobra.Command{
Use: "bundle",
Short: "Generate and publish bundles",
Expand Down Expand Up @@ -340,11 +341,12 @@ func runBundleLint(cmd *cobra.Command, args []string) error {

results := cmdbundle.RunLint(unmarshalledBundle, mdClient)

if results.HasErrors() {
switch {
case results.HasErrors():
return fmt.Errorf("linting failed with %d error(s)", len(results.Errors()))
} else if results.HasWarnings() {
case results.HasWarnings():
fmt.Printf("Linting completed with %d warning(s)\n", len(results.Warnings()))
} else {
default:
fmt.Println("Linting completed, massdriver.yaml is valid!")
}

Expand Down Expand Up @@ -395,16 +397,17 @@ func runBundlePublish(cmd *cobra.Command, args []string) error {
if !skipLint {
results := cmdbundle.RunLint(unmarshalledBundle, mdClient)

if results.HasErrors() {
switch {
case results.HasErrors():
fmt.Printf("Halting publish: Linting failed with %d error(s)\n", len(results.Errors()))
os.Exit(1)
} else if results.HasWarnings() {
case results.HasWarnings():
if failWarnings {
fmt.Printf("Halting publish: linting failed with %d warning(s)\n", len(results.Warnings()))
os.Exit(1)
}
fmt.Printf("Linting completed with %d warning(s)\n", len(results.Warnings()))
} else {
default:
fmt.Println("Linting completed, massdriver.yaml is valid!")
}
}
Expand Down Expand Up @@ -503,7 +506,7 @@ func runBundleGet(cmd *cobra.Command, args []string) error {

arg := args[0]
parts := strings.Split(arg, "@")
bundleId := parts[0]
bundleID := parts[0]
version := "latest"
if len(parts) == 2 {
version = parts[1]
Expand All @@ -520,16 +523,16 @@ func runBundleGet(cmd *cobra.Command, args []string) error {
return fmt.Errorf("error initializing massdriver client: %w", mdClientErr)
}

bundle, err := api.GetBundle(ctx, mdClient, bundleId, &version)
bundle, err := api.GetBundle(ctx, mdClient, bundleID, &version)
if err != nil {
return err
}

switch outputFormat {
case "json":
jsonBytes, err := json.MarshalIndent(bundle, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal bundle to JSON: %w", err)
jsonBytes, marshalErr := json.MarshalIndent(bundle, "", " ")
if marshalErr != nil {
return fmt.Errorf("failed to marshal bundle to JSON: %w", marshalErr)
}
fmt.Println(string(jsonBytes))
case "text":
Expand Down Expand Up @@ -572,8 +575,8 @@ func renderBundle(b *api.Bundle, mdClient *client.Client) error {
}

var buf bytes.Buffer
if err := tmpl.Execute(&buf, data); err != nil {
return fmt.Errorf("failed to execute template: %w", err)
if renderErr := tmpl.Execute(&buf, data); renderErr != nil {
return fmt.Errorf("failed to execute template: %w", renderErr)
}

r, err := glamour.NewTermRenderer(glamour.WithAutoStyle())
Expand Down
1 change: 1 addition & 0 deletions cmd/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"
)

// NewCmdCredential returns a cobra command for managing credentials.
func NewCmdCredential() *cobra.Command {
credentialCmd := &cobra.Command{
Use: "credential",
Expand Down
12 changes: 7 additions & 5 deletions cmd/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
//go:embed templates/definition.get.md.tmpl
var definitionTemplates embed.FS

// NewCmdDefinition returns a cobra command for managing artifact definitions.
func NewCmdDefinition() *cobra.Command {
definitionCmd := &cobra.Command{
Use: "definition",
Expand Down Expand Up @@ -74,6 +75,7 @@ func NewCmdDefinition() *cobra.Command {
return definitionCmd
}

//nolint:dupl // runDefinitionGet and runArtifactGet share the same output-format pattern; refactoring would add complexity for marginal gain
func runDefinitionGet(cmd *cobra.Command, args []string) error {
ctx := context.Background()

Expand All @@ -96,9 +98,9 @@ func runDefinitionGet(cmd *cobra.Command, args []string) error {

switch outputFormat {
case "json":
jsonBytes, err := json.MarshalIndent(ad, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal definition to JSON: %w", err)
jsonBytes, marshalErr := json.MarshalIndent(ad, "", " ")
if marshalErr != nil {
return fmt.Errorf("failed to marshal definition to JSON: %w", marshalErr)
}
fmt.Println(string(jsonBytes))
case "text":
Expand Down Expand Up @@ -183,8 +185,8 @@ func renderDefinition(ad *api.ArtifactDefinitionWithSchema) error {
}

var buf bytes.Buffer
if err := tmpl.Execute(&buf, data); err != nil {
return fmt.Errorf("failed to execute template: %w", err)
if renderErr := tmpl.Execute(&buf, data); renderErr != nil {
return fmt.Errorf("failed to execute template: %w", renderErr)
}

r, err := glamour.NewTermRenderer(glamour.WithAutoStyle())
Expand Down
Loading
Loading