From 3e7c6966b352247bd67155e5845b68281430d485 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Fri, 6 Oct 2023 09:18:44 +0900 Subject: [PATCH] fix: override path --- pkg/config/registry/package_info.go | 54 +++++++++++++++++------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/pkg/config/registry/package_info.go b/pkg/config/registry/package_info.go index 817ec562e..8580b80fa 100644 --- a/pkg/config/registry/package_info.go +++ b/pkg/config/registry/package_info.go @@ -96,6 +96,7 @@ type Override struct { Cargo *Cargo `json:"cargo,omitempty"` Files []*File `yaml:",omitempty" json:"files,omitempty"` URL string `yaml:",omitempty" json:"url,omitempty"` + Path string `yaml:",omitempty" json:"path,omitempty"` CompleteWindowsExt *bool `json:"complete_windows_ext,omitempty" yaml:"complete_windows_ext,omitempty"` WindowsExt string `json:"windows_ext,omitempty" yaml:"windows_ext,omitempty"` Replacements Replacements `yaml:",omitempty" json:"replacements,omitempty"` @@ -298,23 +299,6 @@ func (p *PackageInfo) OverrideByRuntime(rt *runtime.Runtime) { //nolint:cyclop,f p.Type = ov.Type } - if p.Replacements == nil { - p.Replacements = ov.Replacements - } else { - replacements := make(Replacements, len(p.Replacements)) - for k, v := range p.Replacements { - replacements[k] = v - } - for k, v := range ov.Replacements { - replacements[k] = v - } - p.Replacements = replacements - } - - if ov.Format != "" { - p.Format = ov.Format - } - if ov.Asset != nil { p.Asset = ov.Asset } @@ -327,27 +311,51 @@ func (p *PackageInfo) OverrideByRuntime(rt *runtime.Runtime) { //nolint:cyclop,f p.Cargo = ov.Cargo } - if ov.Files != nil { - p.Files = ov.Files - } - if ov.URL != "" { p.URL = ov.URL } - if ov.Checksum != nil { - p.Checksum = ov.Checksum + if ov.Path != "" { + p.Path = ov.Path + } + + if ov.Format != "" { + p.Format = ov.Format + } + + if ov.Files != nil { + p.Files = ov.Files + } + + if p.Replacements == nil { + p.Replacements = ov.Replacements + } else { + replacements := make(Replacements, len(p.Replacements)) + for k, v := range p.Replacements { + replacements[k] = v + } + for k, v := range ov.Replacements { + replacements[k] = v + } + p.Replacements = replacements } if ov.CompleteWindowsExt != nil { p.CompleteWindowsExt = ov.CompleteWindowsExt } + if ov.WindowsExt != "" { p.WindowsExt = ov.WindowsExt } + + if ov.Checksum != nil { + p.Checksum = ov.Checksum + } + if ov.Cosign != nil { p.Cosign = ov.Cosign } + if ov.SLSAProvenance != nil { p.SLSAProvenance = ov.SLSAProvenance }