Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #211

Merged
merged 3 commits into from
Jun 22, 2024
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
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