scripts/build/*: Fix some golint issues
See, $ gometalinter --vendor --disable-all --enable=golint ./... build/release_publisher/externalrelease.go:55:6⚠️ type getHttpContents should be getHTTPContents (golint) build/release_publisher/publisher.go:18:2⚠️ struct field apiUri should be apiURI (golint) build/release_publisher/publisher.go:66:6⚠️ exported type ReleaseType should have comment or be unexported (golint) build/release_publisher/publisher.go:69:2⚠️ exported const STABLE should have comment (or a comment on this block) or be unexported (golint) build/release_publisher/publisher.go:185:16⚠️ should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (golint) build/release_publisher/publisher_test.go:102:6⚠️ type mockHttpGetter should be mockHTTPGetter (golint)
This commit is contained in:
committed by
Leonard Gram
parent
d5f63d9988
commit
4b68055c16
@@ -17,7 +17,7 @@ type releaseFromExternalContent struct {
|
||||
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
|
||||
var rt releaseType
|
||||
if beta {
|
||||
rt = BETA
|
||||
} else if nightly {
|
||||
@@ -52,9 +52,9 @@ type urlGetter interface {
|
||||
getContents(url string) (string, error)
|
||||
}
|
||||
|
||||
type getHttpContents struct{}
|
||||
type getHTTPContents struct{}
|
||||
|
||||
func (getHttpContents) getContents(url string) (string, error) {
|
||||
func (getHTTPContents) getContents(url string) (string, error) {
|
||||
response, err := http.Get(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -20,7 +20,7 @@ type releaseLocalSources struct {
|
||||
|
||||
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.")
|
||||
return nil, errors.New("Local releases only supported for nightly builds")
|
||||
}
|
||||
buildData := r.findBuilds(baseArchiveURL)
|
||||
|
||||
@@ -91,5 +91,5 @@ func grabVersion(name string, suffix string) (string, error) {
|
||||
return string(match[2]), nil
|
||||
}
|
||||
|
||||
return "", errors.New("No version found.")
|
||||
return "", errors.New("No version found")
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func main() {
|
||||
}
|
||||
} else {
|
||||
builder = releaseFromExternalContent{
|
||||
getter: getHttpContents{},
|
||||
getter: getHTTPContents{},
|
||||
rawVersion: version,
|
||||
artifactConfigurations: buildArtifacts,
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func main() {
|
||||
|
||||
p := publisher{
|
||||
apiKey: apiKey,
|
||||
apiUri: "https://grafana.com/api",
|
||||
apiURI: "https://grafana.com/api",
|
||||
product: product,
|
||||
dryRun: dryRun,
|
||||
enterprise: enterprise,
|
||||
|
||||
@@ -9,13 +9,11 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type publisher struct {
|
||||
apiKey string
|
||||
apiUri string
|
||||
apiURI string
|
||||
product string
|
||||
dryRun bool
|
||||
enterprise bool
|
||||
@@ -63,23 +61,26 @@ func (p *publisher) postRelease(r *release) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type ReleaseType int
|
||||
type releaseType int
|
||||
|
||||
const (
|
||||
STABLE ReleaseType = iota + 1
|
||||
// STABLE is a release type constant
|
||||
STABLE releaseType = iota + 1
|
||||
// BETA is a release type constant
|
||||
BETA
|
||||
// NIGHTLY is a release type constant
|
||||
NIGHTLY
|
||||
)
|
||||
|
||||
func (rt ReleaseType) beta() bool {
|
||||
func (rt releaseType) beta() bool {
|
||||
return rt == BETA
|
||||
}
|
||||
|
||||
func (rt ReleaseType) stable() bool {
|
||||
func (rt releaseType) stable() bool {
|
||||
return rt == STABLE
|
||||
}
|
||||
|
||||
func (rt ReleaseType) nightly() bool {
|
||||
func (rt releaseType) nightly() bool {
|
||||
return rt == NIGHTLY
|
||||
}
|
||||
|
||||
@@ -89,7 +90,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 := ""
|
||||
|
||||
@@ -182,13 +183,13 @@ func filterBuildArtifacts(filters []artifactFilter) ([]buildArtifact, error) {
|
||||
}
|
||||
|
||||
if !matched {
|
||||
return nil, errors.New(fmt.Sprintf("No buildArtifact for os=%v, arch=%v", f.os, f.arch))
|
||||
return nil, fmt.Errorf("No buildArtifact for os=%v, arch=%v", f.os, f.arch)
|
||||
}
|
||||
}
|
||||
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),
|
||||
@@ -198,7 +199,7 @@ func newBuild(baseArchiveURL string, ba buildArtifact, version string, rt Releas
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (p *publisher) postRequest(url string, obj interface{}, desc string) error {
|
||||
|
||||
@@ -64,7 +64,7 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
|
||||
|
||||
for _, test := range cases {
|
||||
builder := releaseFromExternalContent{
|
||||
getter: mockHttpGetter{},
|
||||
getter: mockHTTPGetter{},
|
||||
rawVersion: test.version,
|
||||
artifactConfigurations: test.buildArtifacts,
|
||||
}
|
||||
@@ -99,9 +99,9 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type mockHttpGetter struct{}
|
||||
type mockHTTPGetter struct{}
|
||||
|
||||
func (mockHttpGetter) getContents(url string) (string, error) {
|
||||
func (mockHTTPGetter) getContents(url string) (string, error) {
|
||||
return url, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user