Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c5c3e084
Commit
c5c3e084
authored
Nov 01, 2018
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: refactor releaser.
parent
e2d33824
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
54 deletions
+68
-54
scripts/build/release_publisher/externalrelease.go
+62
-0
scripts/build/release_publisher/publisher.go
+0
-53
scripts/build/release_publisher/publisher_test.go
+6
-1
No files found.
scripts/build/release_publisher/externalrelease.go
0 → 100644
View file @
c5c3e084
package
main
import
(
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
)
type
releaseFromExternalContent
struct
{
getter
urlGetter
rawVersion
string
}
func
(
re
releaseFromExternalContent
)
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
,
artifactConfigurations
[]
buildArtifact
)
(
*
release
,
error
)
{
version
:=
re
.
rawVersion
[
1
:
]
now
:=
time
.
Now
()
isBeta
:=
strings
.
Contains
(
version
,
"beta"
)
builds
:=
[]
build
{}
for
_
,
ba
:=
range
artifactConfigurations
{
sha256
,
err
:=
re
.
getter
.
getContents
(
fmt
.
Sprintf
(
"%s.sha256"
,
ba
.
getUrl
(
baseArchiveUrl
,
version
,
isBeta
)))
if
err
!=
nil
{
return
nil
,
err
}
builds
=
append
(
builds
,
newBuild
(
baseArchiveUrl
,
ba
,
version
,
isBeta
,
sha256
))
}
r
:=
release
{
Version
:
version
,
ReleaseDate
:
time
.
Date
(
now
.
Year
(),
now
.
Month
(),
now
.
Day
(),
0
,
0
,
0
,
0
,
time
.
Local
),
Stable
:
!
isBeta
,
Beta
:
isBeta
,
Nightly
:
false
,
WhatsNewUrl
:
whatsNewUrl
,
ReleaseNotesUrl
:
releaseNotesUrl
,
Builds
:
builds
,
}
return
&
r
,
nil
}
type
urlGetter
interface
{
getContents
(
url
string
)
(
string
,
error
)
}
type
getHttpContents
struct
{}
func
(
getHttpContents
)
getContents
(
url
string
)
(
string
,
error
)
{
response
,
err
:=
http
.
Get
(
url
)
if
err
!=
nil
{
return
""
,
err
}
defer
response
.
Body
.
Close
()
all
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
return
""
,
err
}
return
string
(
all
),
nil
}
scripts/build/release_publisher/publisher.go
View file @
c5c3e084
...
...
@@ -141,38 +141,6 @@ var buildArtifactConfigurations = []buildArtifact{
},
}
type
releaseFromExternalContent
struct
{
getter
urlGetter
rawVersion
string
}
func
(
re
releaseFromExternalContent
)
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
,
artifactConfigurations
[]
buildArtifact
)
(
*
release
,
error
)
{
version
:=
re
.
rawVersion
[
1
:
]
now
:=
time
.
Now
()
isBeta
:=
strings
.
Contains
(
version
,
"beta"
)
builds
:=
[]
build
{}
for
_
,
ba
:=
range
artifactConfigurations
{
sha256
,
err
:=
re
.
getter
.
getContents
(
fmt
.
Sprintf
(
"%s.sha256"
,
ba
.
getUrl
(
baseArchiveUrl
,
version
,
isBeta
)))
if
err
!=
nil
{
return
nil
,
err
}
builds
=
append
(
builds
,
newBuild
(
baseArchiveUrl
,
ba
,
version
,
isBeta
,
sha256
))
}
r
:=
release
{
Version
:
version
,
ReleaseDate
:
time
.
Date
(
now
.
Year
(),
now
.
Month
(),
now
.
Day
(),
0
,
0
,
0
,
0
,
time
.
Local
),
Stable
:
!
isBeta
,
Beta
:
isBeta
,
Nightly
:
false
,
WhatsNewUrl
:
whatsNewUrl
,
ReleaseNotesUrl
:
releaseNotesUrl
,
Builds
:
builds
,
}
return
&
r
,
nil
}
func
newBuild
(
baseArchiveUrl
string
,
ba
buildArtifact
,
version
string
,
isBeta
bool
,
sha256
string
)
build
{
return
build
{
Os
:
ba
.
os
,
...
...
@@ -251,24 +219,3 @@ type build struct {
Sha256
string
`json:"sha256"`
Arch
string
`json:"arch"`
}
type
urlGetter
interface
{
getContents
(
url
string
)
(
string
,
error
)
}
type
getHttpContents
struct
{}
func
(
getHttpContents
)
getContents
(
url
string
)
(
string
,
error
)
{
response
,
err
:=
http
.
Get
(
url
)
if
err
!=
nil
{
return
""
,
err
}
defer
response
.
Body
.
Close
()
all
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
return
""
,
err
}
return
string
(
all
),
nil
}
scripts/build/release_publisher/publisher_test.go
View file @
c5c3e084
...
...
@@ -2,7 +2,7 @@ package main
import
"testing"
func
Test
NewReleas
e
(
t
*
testing
.
T
)
{
func
Test
PreparingReleaseFromRemot
e
(
t
*
testing
.
T
)
{
versionIn
:=
"v5.2.0-beta1"
expectedVersion
:=
"5.2.0-beta1"
whatsNewUrl
:=
"https://whatsnews.foo/"
...
...
@@ -46,3 +46,8 @@ type mockHttpGetter struct{}
func
(
mockHttpGetter
)
getContents
(
url
string
)
(
string
,
error
)
{
return
url
,
nil
}
func
TestPreparingReleaseFromLocal
(
t
*
testing
.
T
)
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment