Commit 2d361eea by Leonard Gram

builds: introduces enum for relase type.

parent e2007733
...@@ -17,14 +17,18 @@ type releaseFromExternalContent struct { ...@@ -17,14 +17,18 @@ type releaseFromExternalContent struct {
func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error) { func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error) {
version := re.rawVersion[1:] version := re.rawVersion[1:]
isBeta := strings.Contains(version, "beta") isBeta := strings.Contains(version, "beta")
var rt ReleaseType
if isBeta {
rt = BETA
}
builds := []build{} builds := []build{}
for _, ba := range re.artifactConfigurations { 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 { if err != nil {
return nil, err return nil, err
} }
builds = append(builds, newBuild(baseArchiveUrl, ba, version, isBeta, sha256)) builds = append(builds, newBuild(baseArchiveUrl, ba, version, rt, sha256))
} }
r := release{ r := release{
......
...@@ -70,7 +70,7 @@ func createBuildWalker(path string, data *buildData, archiveTypes []buildArtifac ...@@ -70,7 +70,7 @@ func createBuildWalker(path string, data *buildData, archiveTypes []buildArtifac
data.version = version data.version = version
data.builds = append(data.builds, build{ data.builds = append(data.builds, build{
Os: archive.os, Os: archive.os,
Url: archive.getUrl(baseArchiveUrl, version, false), Url: archive.getUrl(baseArchiveUrl, version, NIGHTLY),
Sha256: string(shaBytes), Sha256: string(shaBytes),
Arch: archive.arch, Arch: archive.arch,
}) })
......
...@@ -61,13 +61,21 @@ func (p *publisher) postRelease(r *release) error { ...@@ -61,13 +61,21 @@ func (p *publisher) postRelease(r *release) error {
return nil return nil
} }
type ReleaseType int
const (
STABLE ReleaseType = iota + 1
BETA
NIGHTLY
)
type buildArtifact struct { type buildArtifact struct {
os string os string
arch string arch string
urlPostfix string urlPostfix string
} }
func (t buildArtifact) getUrl(baseArchiveUrl, version string, isBeta bool) string { func (t buildArtifact) getUrl(baseArchiveUrl, version string, rt ReleaseType) string {
prefix := "-" prefix := "-"
rhelReleaseExtra := "" rhelReleaseExtra := ""
...@@ -75,7 +83,7 @@ func (t buildArtifact) getUrl(baseArchiveUrl, version string, isBeta bool) strin ...@@ -75,7 +83,7 @@ func (t buildArtifact) getUrl(baseArchiveUrl, version string, isBeta bool) strin
prefix = "_" prefix = "_"
} }
if !isBeta && t.os == "rhel" { if rt == BETA && t.os == "rhel" {
rhelReleaseExtra = "-1" rhelReleaseExtra = "-1"
} }
...@@ -141,10 +149,10 @@ var buildArtifactConfigurations = []buildArtifact{ ...@@ -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{ return build{
Os: ba.os, Os: ba.os,
Url: ba.getUrl(baseArchiveUrl, version, isBeta), Url: ba.getUrl(baseArchiveUrl, version, rt),
Sha256: sha256, Sha256: sha256,
Arch: ba.arch, 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