Docker building and various fixes around the code.

This commit is contained in:
2019-10-16 21:05:54 +05:00
parent 9893315796
commit db34a064f5
7 changed files with 103 additions and 34 deletions

View File

@@ -35,7 +35,7 @@ type (
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
Color int `json:"color"`
Color int64 `json:"color"`
Footer EmbedFooterObject `json:"footer"`
Author EmbedAuthorObject `json:"author"`
Fields []EmbedFieldObject `json:"fields"`

View File

@@ -1,8 +0,0 @@
package message
// stdlib
// local
// other
//"github.com/drone/drone-template-lib/template"

View File

@@ -40,7 +40,7 @@ func Process() error {
// If message was set - format it.
if len(env.Data.Plugin.Message) > 0 {
text, err := template.RenderTrim(env.Data.Plugin.Message, env.Data)
text, err := template.RenderTrim(env.Data.Plugin.Message, env.Data.Drone)
if err != nil {
return err
}

View File

@@ -13,7 +13,7 @@ const (
// DroneIconURL default drone logo url
droneIconURL = "https://c1.staticflickr.com/5/4236/34957940160_435d83114f_z.jpg"
// DroneDesc default drone description
droneDesc = "Powered by DiscoDrone Plugin"
droneDesc = "Powered by DiscorDrone Plugin"
)
func createEmbed() EmbedObject {
@@ -54,25 +54,28 @@ func createEmbed() EmbedObject {
embed.Description = description
// Compose color.
var color int
var color int64
if env.Data.Plugin.Color != "" {
env.Data.Plugin.Color = strings.Replace(env.Data.Plugin.Color, "#", "", -1)
if s, err := strconv.ParseInt(env.Data.Plugin.Color, 16, 32); err == nil {
color = int(s)
s, err := strconv.ParseInt(env.Data.Plugin.Color, 16, 32)
if err == nil {
color = s
}
} else {
switch env.Data.Drone.Build.Status {
case "success":
// green
color = 0x1ac600
case "failure", "error", "killed":
// red
color = 0xff3232
default:
// yellow
color = 0xffd930
}
}
switch env.Data.Drone.Build.Status {
case "success":
// green
color = 0x1ac600
case "failure", "error", "killed":
// red
color = 0xff3232
default:
// yellow
color = 0xffd930
}
embed.Color = color
return embed