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
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"features": {
"ghcr.io/guiyomh/features/golangci-lint:0": {
"version": "0.1.2",
"resolved": "ghcr.io/guiyomh/features/golangci-lint@sha256:6a8e1856aedb04681f0a81b974721ab86140058f4992c02c81c204be755474f2",
"integrity": "sha256:6a8e1856aedb04681f0a81b974721ab86140058f4992c02c81c204be755474f2"
}
}
}
6 changes: 4 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"seccomp=unconfined"
],
"features": {
// Pins golangci-lint to match version expected by .golangci.yaml
"ghcr.io/guiyomh/features/golangci-lint:0": {}
// Keep in lockstep with the version CI runs (.github/workflows/lint.yaml).
"ghcr.io/guiyomh/features/golangci-lint:0": {
"version": "2.12"
}
},
"customizations": {
"vscode": {
Expand Down
7 changes: 2 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This file is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021-2025 Marat Reymers

## Golden config for golangci-lint v2.1.6
## Golden config for golangci-lint v2.1.6, run against v2.12 (see
## .github/workflows/lint.yaml and .devcontainer/devcontainer.json).
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
Expand Down Expand Up @@ -416,10 +417,6 @@ 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 _"
# 'api' is a domain-appropriate package name for this layer; revive flags it as "meaningless"
- linters: [revive]
text: "var-naming: avoid meaningless package names"
path: "internal/api/"
- path: "_test\\.go"
linters:
- revive
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ build:

.PHONY: build.macos
build.macos: bin
@GOOS=darwin GOARCH=arm64 go build -o bin/mass-darwin-arm64 -ldflags=${LD_FLAGS}
@CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/mass-darwin-arm64 -ldflags=${LD_FLAGS}

.PHONY: build.linux
build.linux: bin
@GOOS=linux GOARCH=amd64 go build -o bin/mass-linux-amd64 -ldflags=${LD_FLAGS}
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/mass-linux-amd64 -ldflags=${LD_FLAGS}

.PHONY: build.windows
build.windows: bin
@GOOS=windows GOARCH=amd64 go build -o bin/mass-windows-amd64.exe -ldflags=${LD_FLAGS}
@CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/mass-windows-amd64.exe -ldflags=${LD_FLAGS}

.PHONY: install.macos
install.macos: build.macos
Expand Down
24 changes: 19 additions & 5 deletions cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,13 @@ func NewCmdBundle() *cobra.Command { //nolint:funlen // cobra command builders a
bundleGetCmd.Flags().StringP("output", "o", "text", "Output format (text or json)")

bundlePullCmd := &cobra.Command{
Use: "pull <bundle-name>",
Use: "pull <bundle-name>[@<version>]",
Short: "Pull bundle from Massdriver to local directory",
Args: cobra.ExactArgs(1),
RunE: runBundlePull,
}
bundlePullCmd.Flags().StringP("directory", "d", "", "Directory to output the bundle. Defaults to bundle name.")
bundlePullCmd.Flags().BoolP("force", "f", false, "Force pull even if the directory already exists. This will overwrite existing files.")
bundlePullCmd.Flags().StringP("version", "v", "latest", "Bundle version or release channel")

bundleTemplateCmd := &cobra.Command{
Use: "template",
Expand Down Expand Up @@ -397,12 +396,17 @@ func runBundleLint(cmd *cobra.Command, args []string) error {
return fmt.Errorf("error initializing massdriver client: %w", err)
}

// Schema validation runs before dereferencing, which assumes a valid bundle.
if err = cmdbundle.ValidateSchema(unmarshalledBundle, mdClient.Config().URL); err != nil {
return err
}

err = unmarshalledBundle.DereferenceSchemas(bundleDirectory, resourcetype.NewMassdriverResolver(mdClient))
if err != nil {
return err
}

results := cmdbundle.RunLint(unmarshalledBundle, mdClient)
results := cmdbundle.RunLint(unmarshalledBundle)

switch {
case results.HasErrors():
Expand Down Expand Up @@ -452,13 +456,18 @@ func runBundlePublish(cmd *cobra.Command, args []string) error {
return fmt.Errorf("error initializing massdriver client: %w", err)
}

// Schema validation runs before Build, which dereferences and assumes a valid bundle.
if err = cmdbundle.ValidateSchema(unmarshalledBundle, mdClient.Config().URL); err != nil {
return err
}

err = unmarshalledBundle.Build(bundleDirectory, resourcetype.NewMassdriverResolver(mdClient))
if err != nil {
return err
}

if !skipLint {
results := cmdbundle.RunLint(unmarshalledBundle, mdClient)
results := cmdbundle.RunLint(unmarshalledBundle)

switch {
case results.HasErrors():
Expand All @@ -482,12 +491,17 @@ func runBundlePull(cmd *cobra.Command, args []string) error {
ctx := context.Background()

bundleName := args[0]
version := "latest"
if name, ref, found := strings.Cut(bundleName, "@"); found {
bundleName = name
version = ref
}

directory, _ := cmd.Flags().GetString("directory")
if directory == "" {
directory = bundleName
}
force, _ := cmd.Flags().GetBool("force")
version, _ := cmd.Flags().GetString("version")
cmd.SilenceUsage = true

// Check if bundle exists in the specified directory and if so prompt the user
Expand Down
Loading
Loading