Skip to content

Commit

Permalink
refactor: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Jul 22, 2024
1 parent 33a24b0 commit ccf3088
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: 2
release:
github:
owner: ekristen
Expand Down Expand Up @@ -52,12 +51,13 @@ signs:
cmd: cosign
signature: "${artifact}.sig"
certificate: "${artifact}.pem"
args: ["sign-blob", "--yes", "--oidc-provider=github", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}"]
args:
["sign-blob", "--yes", "--oidc-provider=github", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}"]
artifacts: all
checksum:
name_template: "checksums.txt"
snapshot:
name_template: '{{ trimprefix .Summary "v" }}'
# We are skipping changelog because we are using semantic release
changelog:
disable: true
skip: true
25 changes: 3 additions & 22 deletions pkg/asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,6 @@ const (
SBOM
)

func ScoreAll(assets []IAsset, opts *ScoreOptions) {
for _, asset := range assets {
asset.Score(opts)
}
}

func Best(assets []IAsset, aType Type) *Asset {
var best *Asset

for _, asset := range assets {
if best == nil || asset.GetScore() > best.score && asset.GetType() == aType {
best = asset.GetAsset()
}
}

return best
}

// ----------------------------------------------------------------------------

type IAsset interface {
GetName() string
GetDisplayName() string
Expand Down Expand Up @@ -112,6 +92,7 @@ type Asset struct {
Arch string
Version string

Extension string
DownloadPath string
Hash string
TempDir string
Expand Down Expand Up @@ -200,8 +181,8 @@ func (a *Asset) Score(opts *ScoreOptions) int {
var scoringKeys []string
var scoringValues = make(map[string]int)

for _, os := range opts.OS {
scoringValues[strings.ToLower(os)] = 10
for _, os1 := range opts.OS {
scoringValues[strings.ToLower(os1)] = 10
}
for _, arch := range opts.Arch {
scoringValues[strings.ToLower(arch)] = 5
Expand Down
1 change: 1 addition & 0 deletions pkg/source/github_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (a *GitHubAsset) Download(ctx context.Context) error {

assetFile := filepath.Join(downloadsDir, filename)
a.DownloadPath = assetFile
a.Extension = filepath.Ext(a.DownloadPath)

assetFileHash := assetFile + ".sha256"

Expand Down
1 change: 1 addition & 0 deletions pkg/source/gitlab_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (a *GitLabAsset) Download(ctx context.Context) error {

assetFile := filepath.Join(downloadsDir, filename)
a.DownloadPath = assetFile
a.Extension = filepath.Ext(a.DownloadPath)

assetFileHash := assetFile + ".sha256"
stats, err := os.Stat(assetFileHash)
Expand Down
1 change: 1 addition & 0 deletions pkg/source/hashicorp_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (a *HashicorpAsset) Download(ctx context.Context) error {

assetFile := filepath.Join(downloadsDir, filename)
a.DownloadPath = assetFile
a.Extension = filepath.Ext(a.DownloadPath)

assetFileHash := assetFile + ".sha256"
stats, err := os.Stat(assetFileHash)
Expand Down
1 change: 1 addition & 0 deletions pkg/source/homebrew_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (a *HomebrewAsset) Download(ctx context.Context) error {

assetFile := filepath.Join(downloadsDir, filename)
a.DownloadPath = assetFile
a.Extension = filepath.Ext(a.DownloadPath)

assetFileHash := assetFile + ".sha256"
stats, err := os.Stat(assetFileHash)
Expand Down

0 comments on commit ccf3088

Please sign in to comment.