feat: initial copy of v0.1.0
This commit is contained in:
parent
4cc801a7f3
commit
7d4cbb6b08
538 changed files with 63361 additions and 55213 deletions
39
generator/cmd/publish/shasums.go
Normal file
39
generator/cmd/publish/shasums.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package publish
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"path"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (p *Provider) GetShaSums() (ShaSums, error) {
|
||||
return GetShaSumContents(p.DistPath, p.RepoName, p.Version)
|
||||
}
|
||||
|
||||
type ShaSums []ShaSum
|
||||
type ShaSum struct {
|
||||
Sum string
|
||||
Path string
|
||||
}
|
||||
|
||||
func GetShaSumContents(distPath, repoName, version string) (ShaSums, error) {
|
||||
shaSumFileName := repoName + "_" + version + "_SHA256SUMS"
|
||||
shaSumPath := path.Join(distPath, shaSumFileName)
|
||||
|
||||
shaSumLine, err := ReadFile(shaSumPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
regEx := regexp.MustCompile(`([0-9a-fA-F]+)\s+(.+)`)
|
||||
shaSums := ShaSums{}
|
||||
for _, line := range shaSumLine {
|
||||
matches := regEx.FindAllStringSubmatch(line, -1)
|
||||
if len(matches) < 1 {
|
||||
slog.Warn("unable to parse SHA sum line", "line", line)
|
||||
continue
|
||||
}
|
||||
shaSums = append(shaSums, ShaSum{Sum: matches[0][1], Path: matches[0][2]})
|
||||
}
|
||||
return shaSums, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue