Skip to content

Commit

Permalink
fix: override path (#2303)
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke authored Oct 6, 2023
1 parent c3b59ba commit ab511e9
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions pkg/config/registry/package_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit ab511e9

Please sign in to comment.