scripts/build/*: Fix golint issues Url => URL

$ gometalinter --vendor --disable-all --enable=golint ./... | grep -i URL
build/publish.go:18:5⚠️ var apiUrl should be apiURL (golint)
build/publish.go:184:2⚠️ struct field WhatsNewUrl should be WhatsNewURL (golint)
build/publish.go:185:2⚠️ struct field ReleaseNotesUrl should be ReleaseNotesURL (golint)
build/publish.go:191:2⚠️ struct field Url should be URL (golint)
build/release_publisher/externalrelease.go:17:53⚠️ method parameter baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/externalrelease.go:17:69⚠️ method parameter whatsNewUrl should be whatsNewURL (golint)
build/release_publisher/externalrelease.go:17:89⚠️ method parameter releaseNotesUrl should be releaseNotesURL (golint)
build/release_publisher/localrelease.go:20:45⚠️ method parameter baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/localrelease.go:20:61⚠️ method parameter whatsNewUrl should be whatsNewURL (golint)
build/release_publisher/localrelease.go:20:81⚠️ method parameter releaseNotesUrl should be releaseNotesURL (golint)
build/release_publisher/localrelease.go:45:41⚠️ method parameter baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/localrelease.go:51:84⚠️ func parameter baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/main.go:12:6⚠️ var whatsNewUrl should be whatsNewURL (golint)
build/release_publisher/main.go:13:6⚠️ var releaseNotesUrl should be releaseNotesURL (golint)
build/release_publisher/main.go:40:6⚠️ var baseUrl should be baseURL (golint)
build/release_publisher/main.go:94:6⚠️ func createBaseUrl should be createBaseURL (golint)
build/release_publisher/publisher.go:21:2⚠️ struct field baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/publisher.go:26:17⚠️ interface method parameter baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/publisher.go:26:33⚠️ interface method parameter whatsNewUrl should be whatsNewURL (golint)
build/release_publisher/publisher.go:26:53⚠️ interface method parameter releaseNotesUrl should be releaseNotesURL (golint)
build/release_publisher/publisher.go:29:31⚠️ method parameter whatsNewUrl should be whatsNewURL (golint)
build/release_publisher/publisher.go:29:51⚠️ method parameter releaseNotesUrl should be releaseNotesURL (golint)
build/release_publisher/publisher.go:91:24⚠️ method getUrl should be getURL (golint)
build/release_publisher/publisher.go:91:31⚠️ method parameter baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/publisher.go:190:15⚠️ func parameter baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/publisher.go:199:21⚠️ method apiUrl should be apiURL (golint)
build/release_publisher/publisher.go:257:2⚠️ struct field WhatsNewUrl should be WhatsNewURL (golint)
build/release_publisher/publisher.go:258:2⚠️ struct field ReleaseNotesUrl should be ReleaseNotesURL (golint)
build/release_publisher/publisher.go:264:2⚠️ struct field Url should be URL (golint)
build/release_publisher/publisher_test.go:10:3⚠️ struct field whatsNewUrl should be whatsNewURL (golint)
build/release_publisher/publisher_test.go:11:3⚠️ struct field relNotesUrl should be relNotesURL (golint)
build/release_publisher/publisher_test.go:17:3⚠️ struct field expectedUrl should be expectedURL (golint)
build/release_publisher/publisher_test.go:18:3⚠️ struct field baseArchiveUrl should be baseArchiveURL (golint)
build/release_publisher/publisher_test.go:109:2⚠️ var whatsNewUrl should be whatsNewURL (golint)
build/release_publisher/publisher_test.go:110:2⚠️ var relNotesUrl should be relNotesURL (golint)
This commit is contained in:
Mario Trangoni 2019-01-22 19:45:01 +01:00 committed by Leonard Gram
parent 674ab73806
commit d5f63d9988
6 changed files with 76 additions and 74 deletions

View File

@ -15,7 +15,7 @@ import (
"time" "time"
) )
var apiUrl = flag.String("apiUrl", "https://grafana.com/api", "api url") var apiURL = flag.String("apiUrl", "https://grafana.com/api", "api url")
var apiKey = flag.String("apiKey", "", "api key") var apiKey = flag.String("apiKey", "", "api key")
var version = "" var version = ""
var versionRe = regexp.MustCompile(`grafana-(.*)(\.|_)(arm64|armhfp|aarch64|armv7|darwin|linux|windows|x86_64)`) var versionRe = regexp.MustCompile(`grafana-(.*)(\.|_)(arm64|armhfp|aarch64|armv7|darwin|linux|windows|x86_64)`)
@ -56,8 +56,8 @@ func main() {
Stable: false, Stable: false,
Nightly: true, Nightly: true,
Beta: false, Beta: false,
WhatsNewUrl: "", WhatsNewURL: "",
ReleaseNotesUrl: "", ReleaseNotesURL: "",
Builds: builds, Builds: builds,
} }
@ -118,7 +118,7 @@ func mapPackage(path string, name string, shaBytes []byte) (build, error) {
return build{ return build{
Os: os, Os: os,
Arch: arch, Arch: arch,
Url: "https://s3-us-west-2.amazonaws.com/grafana-releases/master/" + name, URL: "https://s3-us-west-2.amazonaws.com/grafana-releases/master/" + name,
Sha256: string(shaBytes), Sha256: string(shaBytes),
}, nil }, nil
} }
@ -148,7 +148,7 @@ func packageWalker(path string, f os.FileInfo, err error) error {
func postRequest(url string, obj interface{}, desc string) { func postRequest(url string, obj interface{}, desc string) {
jsonBytes, _ := json.Marshal(obj) jsonBytes, _ := json.Marshal(obj)
req, _ := http.NewRequest(http.MethodPost, (*apiUrl)+url, bytes.NewReader(jsonBytes)) req, _ := http.NewRequest(http.MethodPost, (*apiURL)+url, bytes.NewReader(jsonBytes))
req.Header.Add("Authorization", "Bearer "+(*apiKey)) req.Header.Add("Authorization", "Bearer "+(*apiKey))
req.Header.Add("Content-Type", "application/json") req.Header.Add("Content-Type", "application/json")
@ -181,14 +181,14 @@ type release struct {
Stable bool `json:"stable"` Stable bool `json:"stable"`
Beta bool `json:"beta"` Beta bool `json:"beta"`
Nightly bool `json:"nightly"` Nightly bool `json:"nightly"`
WhatsNewUrl string `json:"whatsNewUrl"` WhatsNewURL string `json:"whatsNewUrl"`
ReleaseNotesUrl string `json:"releaseNotesUrl"` ReleaseNotesURL string `json:"releaseNotesUrl"`
Builds []build `json:"-"` Builds []build `json:"-"`
} }
type build struct { type build struct {
Os string `json:"os"` Os string `json:"os"`
Url string `json:"url"` URL string `json:"url"`
Sha256 string `json:"sha256"` Sha256 string `json:"sha256"`
Arch string `json:"arch"` Arch string `json:"arch"`
} }

View File

@ -14,7 +14,7 @@ type releaseFromExternalContent struct {
artifactConfigurations []buildArtifact artifactConfigurations []buildArtifact
} }
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:]
beta := strings.Contains(version, "beta") beta := strings.Contains(version, "beta")
var rt ReleaseType var rt ReleaseType
@ -28,11 +28,11 @@ func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl
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, rt))) 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, rt, sha256)) builds = append(builds, newBuild(baseArchiveURL, ba, version, rt, sha256))
} }
r := release{ r := release{
@ -41,8 +41,8 @@ func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl
Stable: rt.stable(), Stable: rt.stable(),
Beta: rt.beta(), Beta: rt.beta(),
Nightly: rt.nightly(), Nightly: rt.nightly(),
WhatsNewUrl: whatsNewUrl, WhatsNewURL: whatsNewURL,
ReleaseNotesUrl: releaseNotesUrl, ReleaseNotesURL: releaseNotesURL,
Builds: builds, Builds: builds,
} }
return &r, nil return &r, nil

View File

@ -2,7 +2,6 @@ package main
import ( import (
"fmt" "fmt"
"github.com/pkg/errors"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
@ -10,6 +9,8 @@ import (
"regexp" "regexp"
"strings" "strings"
"time" "time"
"github.com/pkg/errors"
) )
type releaseLocalSources struct { type releaseLocalSources struct {
@ -17,11 +18,11 @@ type releaseLocalSources struct {
artifactConfigurations []buildArtifact artifactConfigurations []buildArtifact
} }
func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error) { func (r releaseLocalSources) prepareRelease(baseArchiveURL, whatsNewURL string, releaseNotesURL string, nightly bool) (*release, error) {
if !nightly { if !nightly {
return nil, errors.New("Local releases only supported for nightly builds.") return nil, errors.New("Local releases only supported for nightly builds.")
} }
buildData := r.findBuilds(baseArchiveUrl) buildData := r.findBuilds(baseArchiveURL)
rel := release{ rel := release{
Version: buildData.version, Version: buildData.version,
@ -29,8 +30,8 @@ func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string,
Stable: false, Stable: false,
Beta: false, Beta: false,
Nightly: nightly, Nightly: nightly,
WhatsNewUrl: whatsNewUrl, WhatsNewURL: whatsNewURL,
ReleaseNotesUrl: releaseNotesUrl, ReleaseNotesURL: releaseNotesURL,
Builds: buildData.builds, Builds: buildData.builds,
} }
@ -42,13 +43,13 @@ type buildData struct {
builds []build builds []build
} }
func (r releaseLocalSources) findBuilds(baseArchiveUrl string) buildData { func (r releaseLocalSources) findBuilds(baseArchiveURL string) buildData {
data := buildData{} data := buildData{}
filepath.Walk(r.path, createBuildWalker(r.path, &data, r.artifactConfigurations, baseArchiveUrl)) filepath.Walk(r.path, createBuildWalker(r.path, &data, r.artifactConfigurations, baseArchiveURL))
return data return data
} }
func createBuildWalker(path string, data *buildData, archiveTypes []buildArtifact, baseArchiveUrl string) func(path string, f os.FileInfo, err error) error { func createBuildWalker(path string, data *buildData, archiveTypes []buildArtifact, baseArchiveURL string) func(path string, f os.FileInfo, err error) error {
return func(path string, f os.FileInfo, err error) error { return func(path string, f os.FileInfo, err error) error {
if err != nil { if err != nil {
log.Printf("error: %v", err) log.Printf("error: %v", err)
@ -73,7 +74,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, NIGHTLY), URL: archive.getURL(baseArchiveURL, version, NIGHTLY),
Sha256: string(shaBytes), Sha256: string(shaBytes),
Arch: archive.arch, Arch: archive.arch,
}) })

View File

@ -9,8 +9,8 @@ import (
func main() { func main() {
var version string var version string
var whatsNewUrl string var whatsNewURL string
var releaseNotesUrl string var releaseNotesURL string
var dryRun bool var dryRun bool
var enterprise bool var enterprise bool
var fromLocal bool var fromLocal bool
@ -18,8 +18,8 @@ func main() {
var apiKey string var apiKey string
flag.StringVar(&version, "version", "", "Grafana version (ex: --version v5.2.0-beta1)") flag.StringVar(&version, "version", "", "Grafana version (ex: --version v5.2.0-beta1)")
flag.StringVar(&whatsNewUrl, "wn", "", "What's new url (ex: --wn http://docs.grafana.org/guides/whats-new-in-v5-2/)") flag.StringVar(&whatsNewURL, "wn", "", "What's new url (ex: --wn http://docs.grafana.org/guides/whats-new-in-v5-2/)")
flag.StringVar(&releaseNotesUrl, "rn", "", "Grafana version (ex: --rn https://community.grafana.com/t/release-notes-v5-2-x/7894)") flag.StringVar(&releaseNotesURL, "rn", "", "Grafana version (ex: --rn https://community.grafana.com/t/release-notes-v5-2-x/7894)")
flag.StringVar(&apiKey, "apikey", "", "Grafana.com API key (ex: --apikey ABCDEF)") flag.StringVar(&apiKey, "apikey", "", "Grafana.com API key (ex: --apikey ABCDEF)")
flag.BoolVar(&dryRun, "dry-run", false, "--dry-run") flag.BoolVar(&dryRun, "dry-run", false, "--dry-run")
flag.BoolVar(&enterprise, "enterprise", false, "--enterprise") flag.BoolVar(&enterprise, "enterprise", false, "--enterprise")
@ -37,7 +37,7 @@ func main() {
if dryRun { if dryRun {
log.Println("Dry-run has been enabled.") log.Println("Dry-run has been enabled.")
} }
var baseUrl string var baseURL string
var builder releaseBuilder var builder releaseBuilder
var product string var product string
@ -46,7 +46,7 @@ func main() {
if enterprise { if enterprise {
product = "grafana-enterprise" product = "grafana-enterprise"
baseUrl = createBaseUrl(archiveProviderRoot, "enterprise", product, nightly) baseURL = createBaseURL(archiveProviderRoot, "enterprise", product, nightly)
var err error var err error
buildArtifacts, err = filterBuildArtifacts([]artifactFilter{ buildArtifacts, err = filterBuildArtifacts([]artifactFilter{
{os: "deb", arch: "amd64"}, {os: "deb", arch: "amd64"},
@ -61,7 +61,7 @@ func main() {
} else { } else {
product = "grafana" product = "grafana"
baseUrl = createBaseUrl(archiveProviderRoot, "oss", product, nightly) baseURL = createBaseURL(archiveProviderRoot, "oss", product, nightly)
} }
if fromLocal { if fromLocal {
@ -84,14 +84,14 @@ func main() {
product: product, product: product,
dryRun: dryRun, dryRun: dryRun,
enterprise: enterprise, enterprise: enterprise,
baseArchiveUrl: baseUrl, baseArchiveURL: baseURL,
builder: builder, builder: builder,
} }
if err := p.doRelease(whatsNewUrl, releaseNotesUrl, nightly); err != nil { if err := p.doRelease(whatsNewURL, releaseNotesURL, nightly); err != nil {
log.Fatalf("error: %v", err) log.Fatalf("error: %v", err)
} }
} }
func createBaseUrl(root string, bucketName string, product string, nightly bool) string { func createBaseURL(root string, bucketName string, product string, nightly bool) string {
var subPath string var subPath string
if nightly { if nightly {
subPath = "master" subPath = "master"

View File

@ -4,12 +4,13 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/pkg/errors"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"strings" "strings"
"time" "time"
"github.com/pkg/errors"
) )
type publisher struct { type publisher struct {
@ -18,16 +19,16 @@ type publisher struct {
product string product string
dryRun bool dryRun bool
enterprise bool enterprise bool
baseArchiveUrl string baseArchiveURL string
builder releaseBuilder builder releaseBuilder
} }
type releaseBuilder interface { type releaseBuilder interface {
prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error) prepareRelease(baseArchiveURL, whatsNewURL string, releaseNotesURL string, nightly bool) (*release, error)
} }
func (p *publisher) doRelease(whatsNewUrl string, releaseNotesUrl string, nightly bool) error { func (p *publisher) doRelease(whatsNewURL string, releaseNotesURL string, nightly bool) error {
currentRelease, err := p.builder.prepareRelease(p.baseArchiveUrl, whatsNewUrl, releaseNotesUrl, nightly) currentRelease, err := p.builder.prepareRelease(p.baseArchiveURL, whatsNewURL, releaseNotesURL, nightly)
if err != nil { if err != nil {
return err return err
} }
@ -88,7 +89,7 @@ type buildArtifact struct {
urlPostfix string urlPostfix string
} }
func (t buildArtifact) getUrl(baseArchiveUrl, version string, releaseType ReleaseType) string { func (t buildArtifact) getURL(baseArchiveURL, version string, releaseType ReleaseType) string {
prefix := "-" prefix := "-"
rhelReleaseExtra := "" rhelReleaseExtra := ""
@ -100,7 +101,7 @@ func (t buildArtifact) getUrl(baseArchiveUrl, version string, releaseType Releas
rhelReleaseExtra = "-1" rhelReleaseExtra = "-1"
} }
url := strings.Join([]string{baseArchiveUrl, prefix, version, rhelReleaseExtra, t.urlPostfix}, "") url := strings.Join([]string{baseArchiveURL, prefix, version, rhelReleaseExtra, t.urlPostfix}, "")
return url return url
} }
@ -187,16 +188,16 @@ func filterBuildArtifacts(filters []artifactFilter) ([]buildArtifact, error) {
return artifacts, nil return artifacts, nil
} }
func newBuild(baseArchiveUrl string, ba buildArtifact, version string, rt ReleaseType, 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, rt), URL: ba.getURL(baseArchiveURL, version, rt),
Sha256: sha256, Sha256: sha256,
Arch: ba.arch, Arch: ba.arch,
} }
} }
func (p *publisher) apiUrl(url string) string { func (p *publisher) apiURL(url string) string {
return fmt.Sprintf("%s/%s%s", p.apiUri, p.product, url) return fmt.Sprintf("%s/%s%s", p.apiUri, p.product, url)
} }
@ -207,12 +208,12 @@ func (p *publisher) postRequest(url string, obj interface{}, desc string) error
} }
if p.dryRun { if p.dryRun {
log.Println(fmt.Sprintf("POST to %s:", p.apiUrl(url))) log.Println(fmt.Sprintf("POST to %s:", p.apiURL(url)))
log.Println(string(jsonBytes)) log.Println(string(jsonBytes))
return nil return nil
} }
req, err := http.NewRequest(http.MethodPost, p.apiUrl(url), bytes.NewReader(jsonBytes)) req, err := http.NewRequest(http.MethodPost, p.apiURL(url), bytes.NewReader(jsonBytes))
if err != nil { if err != nil {
return err return err
} }
@ -254,14 +255,14 @@ type release struct {
Stable bool `json:"stable"` Stable bool `json:"stable"`
Beta bool `json:"beta"` Beta bool `json:"beta"`
Nightly bool `json:"nightly"` Nightly bool `json:"nightly"`
WhatsNewUrl string `json:"whatsNewUrl"` WhatsNewURL string `json:"whatsNewUrl"`
ReleaseNotesUrl string `json:"releaseNotesUrl"` ReleaseNotesURL string `json:"releaseNotesUrl"`
Builds []build `json:"-"` Builds []build `json:"-"`
} }
type build struct { type build struct {
Os string `json:"os"` Os string `json:"os"`
Url string `json:"url"` URL string `json:"url"`
Sha256 string `json:"sha256"` Sha256 string `json:"sha256"`
Arch string `json:"arch"` Arch string `json:"arch"`
} }

View File

@ -7,57 +7,57 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
cases := []struct { cases := []struct {
version string version string
expectedVersion string expectedVersion string
whatsNewUrl string whatsNewURL string
relNotesUrl string relNotesURL string
nightly bool nightly bool
expectedBeta bool expectedBeta bool
expectedStable bool expectedStable bool
expectedArch string expectedArch string
expectedOs string expectedOs string
expectedUrl string expectedURL string
baseArchiveUrl string baseArchiveURL string
buildArtifacts []buildArtifact buildArtifacts []buildArtifact
}{ }{
{ {
version: "v5.2.0-beta1", version: "v5.2.0-beta1",
expectedVersion: "5.2.0-beta1", expectedVersion: "5.2.0-beta1",
whatsNewUrl: "https://whatsnews.foo/", whatsNewURL: "https://whatsnews.foo/",
relNotesUrl: "https://relnotes.foo/", relNotesURL: "https://relnotes.foo/",
nightly: false, nightly: false,
expectedBeta: true, expectedBeta: true,
expectedStable: false, expectedStable: false,
expectedArch: "amd64", expectedArch: "amd64",
expectedOs: "linux", expectedOs: "linux",
expectedUrl: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.0-beta1.linux-amd64.tar.gz", expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.0-beta1.linux-amd64.tar.gz",
baseArchiveUrl: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"linux", "amd64", ".linux-amd64.tar.gz"}}, buildArtifacts: []buildArtifact{{"linux", "amd64", ".linux-amd64.tar.gz"}},
}, },
{ {
version: "v5.2.3", version: "v5.2.3",
expectedVersion: "5.2.3", expectedVersion: "5.2.3",
whatsNewUrl: "https://whatsnews.foo/", whatsNewURL: "https://whatsnews.foo/",
relNotesUrl: "https://relnotes.foo/", relNotesURL: "https://relnotes.foo/",
nightly: false, nightly: false,
expectedBeta: false, expectedBeta: false,
expectedStable: true, expectedStable: true,
expectedArch: "amd64", expectedArch: "amd64",
expectedOs: "rhel", expectedOs: "rhel",
expectedUrl: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.3-1.x86_64.rpm", expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.3-1.x86_64.rpm",
baseArchiveUrl: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm"}}, buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm"}},
}, },
{ {
version: "v5.4.0-pre1asdf", version: "v5.4.0-pre1asdf",
expectedVersion: "5.4.0-pre1asdf", expectedVersion: "5.4.0-pre1asdf",
whatsNewUrl: "https://whatsnews.foo/", whatsNewURL: "https://whatsnews.foo/",
relNotesUrl: "https://relnotes.foo/", relNotesURL: "https://relnotes.foo/",
nightly: true, nightly: true,
expectedBeta: false, expectedBeta: false,
expectedStable: false, expectedStable: false,
expectedArch: "amd64", expectedArch: "amd64",
expectedOs: "rhel", expectedOs: "rhel",
expectedUrl: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0-pre1asdf.x86_64.rpm", expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0-pre1asdf.x86_64.rpm",
baseArchiveUrl: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm"}}, buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm"}},
}, },
} }
@ -69,7 +69,7 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
artifactConfigurations: test.buildArtifacts, artifactConfigurations: test.buildArtifacts,
} }
rel, _ := builder.prepareRelease(test.baseArchiveUrl, test.whatsNewUrl, test.relNotesUrl, test.nightly) rel, _ := builder.prepareRelease(test.baseArchiveURL, test.whatsNewURL, test.relNotesURL, test.nightly)
if rel.Beta != test.expectedBeta || rel.Stable != test.expectedStable { if rel.Beta != test.expectedBeta || rel.Stable != test.expectedStable {
t.Errorf("%s should have been tagged as beta=%v, stable=%v.", test.version, test.expectedBeta, test.expectedStable) t.Errorf("%s should have been tagged as beta=%v, stable=%v.", test.version, test.expectedBeta, test.expectedStable)
@ -93,8 +93,8 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
t.Errorf("Expected os to be %v, but it was %v", test.expectedOs, build.Os) t.Errorf("Expected os to be %v, but it was %v", test.expectedOs, build.Os)
} }
if build.Url != test.expectedUrl { if build.URL != test.expectedURL {
t.Errorf("Expected url to be %v, but it was %v", test.expectedUrl, build.Url) t.Errorf("Expected url to be %v, but it was %v", test.expectedURL, build.URL)
} }
} }
} }
@ -106,8 +106,8 @@ func (mockHttpGetter) getContents(url string) (string, error) {
} }
func TestPreparingReleaseFromLocal(t *testing.T) { func TestPreparingReleaseFromLocal(t *testing.T) {
whatsNewUrl := "https://whatsnews.foo/" whatsNewURL := "https://whatsnews.foo/"
relNotesUrl := "https://relnotes.foo/" relNotesURL := "https://relnotes.foo/"
expectedVersion := "5.4.0-123pre1" expectedVersion := "5.4.0-123pre1"
expectedBuilds := 4 expectedBuilds := 4
@ -118,17 +118,17 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
artifactConfigurations: completeBuildArtifactConfigurations, artifactConfigurations: completeBuildArtifactConfigurations,
} }
relAll, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewUrl, relNotesUrl, true) relAll, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewURL, relNotesURL, true)
if relAll.Stable || !relAll.Nightly { if relAll.Stable || !relAll.Nightly {
t.Error("Expected a nightly release but wasn't.") t.Error("Expected a nightly release but wasn't.")
} }
if relAll.ReleaseNotesUrl != relNotesUrl { if relAll.ReleaseNotesURL != relNotesURL {
t.Errorf("expected releaseNotesUrl to be %s, but it was %s", relNotesUrl, relAll.ReleaseNotesUrl) t.Errorf("expected releaseNotesURL to be %s, but it was %s", relNotesURL, relAll.ReleaseNotesURL)
} }
if relAll.WhatsNewUrl != whatsNewUrl { if relAll.WhatsNewURL != whatsNewURL {
t.Errorf("expected whatsNewUrl to be %s, but it was %s", whatsNewUrl, relAll.WhatsNewUrl) t.Errorf("expected whatsNewURL to be %s, but it was %s", whatsNewURL, relAll.WhatsNewURL)
} }
if relAll.Beta { if relAll.Beta {
@ -155,7 +155,7 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
}}, }},
} }
relOne, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewUrl, relNotesUrl, true) relOne, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewURL, relNotesURL, true)
if len(relOne.Builds) != 1 { if len(relOne.Builds) != 1 {
t.Errorf("Expected 1 artifact, but was %v", len(relOne.Builds)) t.Errorf("Expected 1 artifact, but was %v", len(relOne.Builds))