Commit 2d361eea by Leonard Gram

builds: introduces enum for relase type.

parent e2007733
......@@ -17,14 +17,18 @@ type releaseFromExternalContent struct {
func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error) {
version := re.rawVersion[1:]
isBeta := strings.Contains(version, "beta")
var rt ReleaseType
if isBeta {
rt = BETA
}
builds := []build{}
for _, ba := range re.artifactConfigurations {
sha256, err := re.getter.getContents(fmt.Sprintf("%s.sha256", ba.getUrl(baseArchiveUrl, version, isBeta)))
sha256, err := re.getter.getContents(fmt.Sprintf("%s.sha256", ba.getUrl(baseArchiveUrl, version, rt)))
if err != nil {
return nil, err
}
builds = append(builds, newBuild(baseArchiveUrl, ba, version, isBeta, sha256))
builds = append(builds, newBuild(baseArchiveUrl, ba, version, rt, sha256))
}
r := release{
......
......@@ -70,7 +70,7 @@ func createBuildWalker(path string, data *buildData, archiveTypes []buildArtifac
data.version = version
data.builds = append(data.builds, build{
Os: archive.os,
Url: archive.getUrl(baseArchiveUrl, version, false),
Url: archive.getUrl(baseArchiveUrl, version, NIGHTLY),
Sha256: string(shaBytes),
Arch: archive.arch,
})
......
......@@ -61,13 +61,21 @@ func (p *publisher) postRelease(r *release) error {
return nil
}
type ReleaseType int
const (
STABLE ReleaseType = iota + 1
BETA
NIGHTLY
)
type buildArtifact struct {
os string
arch string
urlPostfix string
}
func (t buildArtifact) getUrl(baseArchiveUrl, version string, isBeta bool) string {
func (t buildArtifact) getUrl(baseArchiveUrl, version string, rt ReleaseType) string {
prefix := "-"
rhelReleaseExtra := ""
......@@ -75,7 +83,7 @@ func (t buildArtifact) getUrl(baseArchiveUrl, version string, isBeta bool) strin
prefix = "_"
}
if !isBeta && t.os == "rhel" {
if rt == BETA && t.os == "rhel" {
rhelReleaseExtra = "-1"
}
......@@ -141,10 +149,10 @@ var buildArtifactConfigurations = []buildArtifact{
},
}
func newBuild(baseArchiveUrl string, ba buildArtifact, version string, isBeta bool, sha256 string) build {
func newBuild(baseArchiveUrl string, ba buildArtifact, version string, rt ReleaseType, sha256 string) build {
return build{
Os: ba.os,
Url: ba.getUrl(baseArchiveUrl, version, isBeta),
Url: ba.getUrl(baseArchiveUrl, version, rt),
Sha256: sha256,
Arch: ba.arch,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment