From 0ea6123b6e9d417b3f03bb237fb5b881561fdead Mon Sep 17 00:00:00 2001 From: Skip Grube Date: Thu, 23 Feb 2023 13:57:21 -0500 Subject: [PATCH] More cleanup from feedback - Removed extra lines - Externalized Lookaside struct{} -Skip Grube --- pkg/modes/git.go | 19 +++++++++---------- pkg/srpmproc/process.go | 2 -- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/modes/git.go b/pkg/modes/git.go index 79d3aef..855afdc 100644 --- a/pkg/modes/git.go +++ b/pkg/modes/git.go @@ -49,6 +49,15 @@ type remoteTarget struct { when time.Time } +// Struct to define the possible template values ( {{.Value}} in CDN URL strings: +type Lookaside struct { + Name string + Branch string + Hash string + Hashtype string + Filename string +} + type remoteTargetSlice []remoteTarget func (p remoteTargetSlice) Len() int { @@ -487,16 +496,6 @@ func (g *GitMode) ImportName(pd *data.ProcessData, md *data.ModeData) string { // Given a cdnUrl string as input, return same string, but with substituted // template values ( {{.Name}} , {{.Hash}}, {{.Filename}}, etc. ) func ProcessUrl(cdnUrl string, name string, branch string, hash string, hashtype string, filename string) (string, bool) { - - // These 5 {{ .Value }} items are possible in our templated string: - type Lookaside struct { - Name string - Branch string - Hash string - Hashtype string - Filename string - } - tmpUrl := Lookaside{name, branch, hash, hashtype, filename} // If we run into trouble with our template parsing, we'll just return the cdnUrl, exactly as we found it diff --git a/pkg/srpmproc/process.go b/pkg/srpmproc/process.go index 2827134..1383572 100644 --- a/pkg/srpmproc/process.go +++ b/pkg/srpmproc/process.go @@ -121,7 +121,6 @@ func gitlabify(str string) string { // List of distros and their lookaside patterns // If we find one of these passed as --cdn (ex: "--cdn fedora"), then we override, and assign this URL to be our --cdn-url func StaticLookasides() []LookasidePath { - centos := LookasidePath{ Distro: "centos", Url: "https://git.centos.org/sources/{{.Name}}/{{.Branch}}/{{.Hash}}", @@ -163,7 +162,6 @@ func FindDistro(cdn string) (string, bool) { } func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) { - // Build the logger to use for the data import var writer io.Writer = os.Stdout if req.LogWriter != nil {