More cleanup from feedback

- Removed extra lines
- Externalized Lookaside struct{}

-Skip Grube
This commit is contained in:
Skip Grube 2023-02-23 13:57:21 -05:00
parent 2cc3bcc3a3
commit 0ea6123b6e
No known key found for this signature in database
GPG Key ID: D391F8393BEA6D9C
2 changed files with 9 additions and 12 deletions

View File

@ -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

View File

@ -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 {