Skip to content

Commit

Permalink
Small fixes (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Morozko authored Jun 22, 2024
1 parent 0021777 commit 67eee28
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
19 changes: 17 additions & 2 deletions .goreleaser-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
- CGO_ENABLED=0

snapshot:
name_template: "{{.Tag}}-dev{{if .IsGitDirty}}+dirty{{end}}+rev.{{.FullCommit}}"
name_template: "{{ .Version }}-dev+{{if .IsGitDirty}}dirty.{{end}}rev.{{.FullCommit}}"

builds:
# CLI
Expand All @@ -18,7 +18,7 @@ builds:
ldflags:
- -X github.com/blackstork-io/fabric/cmd.version={{.Version}}
- -X github.com/blackstork-io/fabric/cmd.builtBy=goreleaser

gcflags: all=-N -l
no_unique_dist_dir: true

# Plugins
Expand All @@ -27,88 +27,103 @@ builds:
main: ./internal/elastic/cmd
binary: "plugins/blackstork/elastic@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: github
main: ./internal/github/cmd
binary: "plugins/blackstork/github@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: graphql
main: ./internal/graphql/cmd
binary: "plugins/blackstork/graphql@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: openai
main: ./internal/openai/cmd
binary: "plugins/blackstork/openai@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: opencti
main: ./internal/opencti/cmd
binary: "plugins/blackstork/opencti@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: nistnvd
main: ./internal/nistnvd/cmd
binary: "plugins/blackstork/nist_nvd@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: postgresql
main: ./internal/postgresql/cmd
binary: "plugins/blackstork/postgresql@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: sqlite
main: ./internal/sqlite/cmd
binary: "plugins/blackstork/sqlite@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: terraform
main: ./internal/terraform/cmd
binary: "plugins/blackstork/terraform@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: hackerone
main: ./internal/hackerone/cmd
binary: "plugins/blackstork/hackerone@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: virustotal
main: ./internal/virustotal/cmd
binary: "plugins/blackstork/virustotal@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: splunk
main: ./internal/splunk/cmd
binary: "plugins/blackstork/splunk@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: stixview
main: ./internal/stixview/cmd
binary: "plugins/blackstork/stixview@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: snyk
main: ./internal/snyk/cmd
binary: "plugins/blackstork/snyk@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true

- id: microsoft
main: ./internal/microsoft/cmd
binary: "plugins/blackstork/microsoft@{{ .Version }}"
ldflags: "-X main.version={{.Version}}"
gcflags: all=-N -l
no_unique_dist_dir: true
10 changes: 7 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,29 @@ func versionFromBuildInfo() (result string) {
return
}
if info.Main.Version != "(devel)" {
result = info.Main.Version
result = strings.ToLower(info.Main.Version)
if !strings.HasPrefix(result, "v") {
result = "v" + result
}
return
}
var meta []string
// It's a dev version not built by goreleaser, add extra info
dirtyIdx := slices.IndexFunc(info.Settings, func(s debug.BuildSetting) bool {
return s.Key == "vcs.modified"
})
if dirtyIdx != -1 && info.Settings[dirtyIdx].Value == "true" {
result += "+dirty"
meta = append(meta, "dirty")
}

shaIdx := slices.IndexFunc(info.Settings, func(s debug.BuildSetting) bool {
return s.Key == "vcs.revision"
})
if shaIdx != -1 {
result = fmt.Sprintf("%s+rev.%s", result, info.Settings[shaIdx].Value)
meta = append(meta, "rev", info.Settings[shaIdx].Value)
}
if len(meta) != 0 {
result += "+" + strings.Join(meta, ".")
}
return
}
2 changes: 1 addition & 1 deletion plugin/pluginapi/v1/dataspec_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func decodeRootSpec(src *Spec) (dataspec.RootSpec, error) {
sp, err := decodeSpec(src)
if err != nil {
if sp == nil || err != nil {
return nil, err
}
rs, ok := sp.(dataspec.RootSpec)
Expand Down

0 comments on commit 67eee28

Please sign in to comment.