mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
674ab73806
commit
d5f63d9988
@ -15,7 +15,7 @@ import (
|
||||
"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 version = ""
|
||||
var versionRe = regexp.MustCompile(`grafana-(.*)(\.|_)(arm64|armhfp|aarch64|armv7|darwin|linux|windows|x86_64)`)
|
||||
@ -56,8 +56,8 @@ func main() {
|
||||
Stable: false,
|
||||
Nightly: true,
|
||||
Beta: false,
|
||||
WhatsNewUrl: "",
|
||||
ReleaseNotesUrl: "",
|
||||
WhatsNewURL: "",
|
||||
ReleaseNotesURL: "",
|
||||
Builds: builds,
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ func mapPackage(path string, name string, shaBytes []byte) (build, error) {
|
||||
return build{
|
||||
Os: os,
|
||||
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),
|
||||
}, nil
|
||||
}
|
||||
@ -148,7 +148,7 @@ func packageWalker(path string, f os.FileInfo, err error) error {
|
||||
|
||||
func postRequest(url string, obj interface{}, desc string) {
|
||||
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("Content-Type", "application/json")
|
||||
|
||||
@ -181,14 +181,14 @@ type release struct {
|
||||
Stable bool `json:"stable"`
|
||||
Beta bool `json:"beta"`
|
||||
Nightly bool `json:"nightly"`
|
||||
WhatsNewUrl string `json:"whatsNewUrl"`
|
||||
ReleaseNotesUrl string `json:"releaseNotesUrl"`
|
||||
WhatsNewURL string `json:"whatsNewUrl"`
|
||||
ReleaseNotesURL string `json:"releaseNotesUrl"`
|
||||
Builds []build `json:"-"`
|
||||
}
|
||||
|
||||
type build struct {
|
||||
Os string `json:"os"`
|
||||
Url string `json:"url"`
|
||||
URL string `json:"url"`
|
||||
Sha256 string `json:"sha256"`
|
||||
Arch string `json:"arch"`
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ type releaseFromExternalContent struct {
|
||||
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:]
|
||||
beta := strings.Contains(version, "beta")
|
||||
var rt ReleaseType
|
||||
@ -28,11 +28,11 @@ func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl
|
||||
|
||||
builds := []build{}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
builds = append(builds, newBuild(baseArchiveUrl, ba, version, rt, sha256))
|
||||
builds = append(builds, newBuild(baseArchiveURL, ba, version, rt, sha256))
|
||||
}
|
||||
|
||||
r := release{
|
||||
@ -41,8 +41,8 @@ func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl
|
||||
Stable: rt.stable(),
|
||||
Beta: rt.beta(),
|
||||
Nightly: rt.nightly(),
|
||||
WhatsNewUrl: whatsNewUrl,
|
||||
ReleaseNotesUrl: releaseNotesUrl,
|
||||
WhatsNewURL: whatsNewURL,
|
||||
ReleaseNotesURL: releaseNotesURL,
|
||||
Builds: builds,
|
||||
}
|
||||
return &r, nil
|
||||
|
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
@ -10,6 +9,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type releaseLocalSources struct {
|
||||
@ -17,11 +18,11 @@ type releaseLocalSources struct {
|
||||
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 {
|
||||
return nil, errors.New("Local releases only supported for nightly builds.")
|
||||
}
|
||||
buildData := r.findBuilds(baseArchiveUrl)
|
||||
buildData := r.findBuilds(baseArchiveURL)
|
||||
|
||||
rel := release{
|
||||
Version: buildData.version,
|
||||
@ -29,8 +30,8 @@ func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string,
|
||||
Stable: false,
|
||||
Beta: false,
|
||||
Nightly: nightly,
|
||||
WhatsNewUrl: whatsNewUrl,
|
||||
ReleaseNotesUrl: releaseNotesUrl,
|
||||
WhatsNewURL: whatsNewURL,
|
||||
ReleaseNotesURL: releaseNotesURL,
|
||||
Builds: buildData.builds,
|
||||
}
|
||||
|
||||
@ -42,13 +43,13 @@ type buildData struct {
|
||||
builds []build
|
||||
}
|
||||
|
||||
func (r releaseLocalSources) findBuilds(baseArchiveUrl string) buildData {
|
||||
func (r releaseLocalSources) findBuilds(baseArchiveURL string) 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
|
||||
}
|
||||
|
||||
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 {
|
||||
if err != nil {
|
||||
log.Printf("error: %v", err)
|
||||
@ -73,7 +74,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, NIGHTLY),
|
||||
URL: archive.getURL(baseArchiveURL, version, NIGHTLY),
|
||||
Sha256: string(shaBytes),
|
||||
Arch: archive.arch,
|
||||
})
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
|
||||
func main() {
|
||||
var version string
|
||||
var whatsNewUrl string
|
||||
var releaseNotesUrl string
|
||||
var whatsNewURL string
|
||||
var releaseNotesURL string
|
||||
var dryRun bool
|
||||
var enterprise bool
|
||||
var fromLocal bool
|
||||
@ -18,8 +18,8 @@ func main() {
|
||||
var apiKey string
|
||||
|
||||
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(&releaseNotesUrl, "rn", "", "Grafana version (ex: --rn https://community.grafana.com/t/release-notes-v5-2-x/7894)")
|
||||
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(&apiKey, "apikey", "", "Grafana.com API key (ex: --apikey ABCDEF)")
|
||||
flag.BoolVar(&dryRun, "dry-run", false, "--dry-run")
|
||||
flag.BoolVar(&enterprise, "enterprise", false, "--enterprise")
|
||||
@ -37,7 +37,7 @@ func main() {
|
||||
if dryRun {
|
||||
log.Println("Dry-run has been enabled.")
|
||||
}
|
||||
var baseUrl string
|
||||
var baseURL string
|
||||
var builder releaseBuilder
|
||||
var product string
|
||||
|
||||
@ -46,7 +46,7 @@ func main() {
|
||||
|
||||
if enterprise {
|
||||
product = "grafana-enterprise"
|
||||
baseUrl = createBaseUrl(archiveProviderRoot, "enterprise", product, nightly)
|
||||
baseURL = createBaseURL(archiveProviderRoot, "enterprise", product, nightly)
|
||||
var err error
|
||||
buildArtifacts, err = filterBuildArtifacts([]artifactFilter{
|
||||
{os: "deb", arch: "amd64"},
|
||||
@ -61,7 +61,7 @@ func main() {
|
||||
|
||||
} else {
|
||||
product = "grafana"
|
||||
baseUrl = createBaseUrl(archiveProviderRoot, "oss", product, nightly)
|
||||
baseURL = createBaseURL(archiveProviderRoot, "oss", product, nightly)
|
||||
}
|
||||
|
||||
if fromLocal {
|
||||
@ -84,14 +84,14 @@ func main() {
|
||||
product: product,
|
||||
dryRun: dryRun,
|
||||
enterprise: enterprise,
|
||||
baseArchiveUrl: baseUrl,
|
||||
baseArchiveURL: baseURL,
|
||||
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)
|
||||
}
|
||||
}
|
||||
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
|
||||
if nightly {
|
||||
subPath = "master"
|
||||
|
@ -4,12 +4,13 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type publisher struct {
|
||||
@ -18,16 +19,16 @@ type publisher struct {
|
||||
product string
|
||||
dryRun bool
|
||||
enterprise bool
|
||||
baseArchiveUrl string
|
||||
baseArchiveURL string
|
||||
builder releaseBuilder
|
||||
}
|
||||
|
||||
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 {
|
||||
currentRelease, err := p.builder.prepareRelease(p.baseArchiveUrl, whatsNewUrl, releaseNotesUrl, nightly)
|
||||
func (p *publisher) doRelease(whatsNewURL string, releaseNotesURL string, nightly bool) error {
|
||||
currentRelease, err := p.builder.prepareRelease(p.baseArchiveURL, whatsNewURL, releaseNotesURL, nightly)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -88,7 +89,7 @@ type buildArtifact struct {
|
||||
urlPostfix string
|
||||
}
|
||||
|
||||
func (t buildArtifact) getUrl(baseArchiveUrl, version string, releaseType ReleaseType) string {
|
||||
func (t buildArtifact) getURL(baseArchiveURL, version string, releaseType ReleaseType) string {
|
||||
prefix := "-"
|
||||
rhelReleaseExtra := ""
|
||||
|
||||
@ -100,7 +101,7 @@ func (t buildArtifact) getUrl(baseArchiveUrl, version string, releaseType Releas
|
||||
rhelReleaseExtra = "-1"
|
||||
}
|
||||
|
||||
url := strings.Join([]string{baseArchiveUrl, prefix, version, rhelReleaseExtra, t.urlPostfix}, "")
|
||||
url := strings.Join([]string{baseArchiveURL, prefix, version, rhelReleaseExtra, t.urlPostfix}, "")
|
||||
return url
|
||||
}
|
||||
|
||||
@ -187,16 +188,16 @@ func filterBuildArtifacts(filters []artifactFilter) ([]buildArtifact, error) {
|
||||
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{
|
||||
Os: ba.os,
|
||||
Url: ba.getUrl(baseArchiveUrl, version, rt),
|
||||
URL: ba.getURL(baseArchiveURL, version, rt),
|
||||
Sha256: sha256,
|
||||
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)
|
||||
}
|
||||
|
||||
@ -207,12 +208,12 @@ func (p *publisher) postRequest(url string, obj interface{}, desc string) error
|
||||
}
|
||||
|
||||
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))
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@ -254,14 +255,14 @@ type release struct {
|
||||
Stable bool `json:"stable"`
|
||||
Beta bool `json:"beta"`
|
||||
Nightly bool `json:"nightly"`
|
||||
WhatsNewUrl string `json:"whatsNewUrl"`
|
||||
ReleaseNotesUrl string `json:"releaseNotesUrl"`
|
||||
WhatsNewURL string `json:"whatsNewUrl"`
|
||||
ReleaseNotesURL string `json:"releaseNotesUrl"`
|
||||
Builds []build `json:"-"`
|
||||
}
|
||||
|
||||
type build struct {
|
||||
Os string `json:"os"`
|
||||
Url string `json:"url"`
|
||||
URL string `json:"url"`
|
||||
Sha256 string `json:"sha256"`
|
||||
Arch string `json:"arch"`
|
||||
}
|
||||
|
@ -7,57 +7,57 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
|
||||
cases := []struct {
|
||||
version string
|
||||
expectedVersion string
|
||||
whatsNewUrl string
|
||||
relNotesUrl string
|
||||
whatsNewURL string
|
||||
relNotesURL string
|
||||
nightly bool
|
||||
expectedBeta bool
|
||||
expectedStable bool
|
||||
expectedArch string
|
||||
expectedOs string
|
||||
expectedUrl string
|
||||
baseArchiveUrl string
|
||||
expectedURL string
|
||||
baseArchiveURL string
|
||||
buildArtifacts []buildArtifact
|
||||
}{
|
||||
{
|
||||
version: "v5.2.0-beta1",
|
||||
expectedVersion: "5.2.0-beta1",
|
||||
whatsNewUrl: "https://whatsnews.foo/",
|
||||
relNotesUrl: "https://relnotes.foo/",
|
||||
whatsNewURL: "https://whatsnews.foo/",
|
||||
relNotesURL: "https://relnotes.foo/",
|
||||
nightly: false,
|
||||
expectedBeta: true,
|
||||
expectedStable: false,
|
||||
expectedArch: "amd64",
|
||||
expectedOs: "linux",
|
||||
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",
|
||||
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",
|
||||
buildArtifacts: []buildArtifact{{"linux", "amd64", ".linux-amd64.tar.gz"}},
|
||||
},
|
||||
{
|
||||
version: "v5.2.3",
|
||||
expectedVersion: "5.2.3",
|
||||
whatsNewUrl: "https://whatsnews.foo/",
|
||||
relNotesUrl: "https://relnotes.foo/",
|
||||
whatsNewURL: "https://whatsnews.foo/",
|
||||
relNotesURL: "https://relnotes.foo/",
|
||||
nightly: false,
|
||||
expectedBeta: false,
|
||||
expectedStable: true,
|
||||
expectedArch: "amd64",
|
||||
expectedOs: "rhel",
|
||||
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",
|
||||
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",
|
||||
buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm"}},
|
||||
},
|
||||
{
|
||||
version: "v5.4.0-pre1asdf",
|
||||
expectedVersion: "5.4.0-pre1asdf",
|
||||
whatsNewUrl: "https://whatsnews.foo/",
|
||||
relNotesUrl: "https://relnotes.foo/",
|
||||
whatsNewURL: "https://whatsnews.foo/",
|
||||
relNotesURL: "https://relnotes.foo/",
|
||||
nightly: true,
|
||||
expectedBeta: false,
|
||||
expectedStable: false,
|
||||
expectedArch: "amd64",
|
||||
expectedOs: "rhel",
|
||||
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",
|
||||
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",
|
||||
buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm"}},
|
||||
},
|
||||
}
|
||||
@ -69,7 +69,7 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
if build.Url != test.expectedUrl {
|
||||
t.Errorf("Expected url to be %v, but it was %v", test.expectedUrl, build.Url)
|
||||
if build.URL != test.expectedURL {
|
||||
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) {
|
||||
whatsNewUrl := "https://whatsnews.foo/"
|
||||
relNotesUrl := "https://relnotes.foo/"
|
||||
whatsNewURL := "https://whatsnews.foo/"
|
||||
relNotesURL := "https://relnotes.foo/"
|
||||
expectedVersion := "5.4.0-123pre1"
|
||||
expectedBuilds := 4
|
||||
|
||||
@ -118,17 +118,17 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
|
||||
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 {
|
||||
t.Error("Expected a nightly release but wasn't.")
|
||||
}
|
||||
|
||||
if relAll.ReleaseNotesUrl != relNotesUrl {
|
||||
t.Errorf("expected releaseNotesUrl to be %s, but it was %s", relNotesUrl, relAll.ReleaseNotesUrl)
|
||||
if relAll.ReleaseNotesURL != relNotesURL {
|
||||
t.Errorf("expected releaseNotesURL to be %s, but it was %s", relNotesURL, relAll.ReleaseNotesURL)
|
||||
}
|
||||
if relAll.WhatsNewUrl != whatsNewUrl {
|
||||
t.Errorf("expected whatsNewUrl to be %s, but it was %s", whatsNewUrl, relAll.WhatsNewUrl)
|
||||
if relAll.WhatsNewURL != whatsNewURL {
|
||||
t.Errorf("expected whatsNewURL to be %s, but it was %s", whatsNewURL, relAll.WhatsNewURL)
|
||||
}
|
||||
|
||||
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 {
|
||||
t.Errorf("Expected 1 artifact, but was %v", len(relOne.Builds))
|
||||
|
Loading…
Reference in New Issue
Block a user