Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deadcode and apply lint #46

Merged
merged 1 commit into from
Aug 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const (
EnvGithubActor = "GITHUB_ACTOR"
EnvSiteName = "SITE_NAME"
EnvHostName = "HOST_NAME"
EnvDepolyPath = "DEPLOY_PATH"
EnvMinimal = "MSG_MINIMAL"
)

Expand All @@ -32,7 +31,7 @@ type Webhook struct {
IconEmoji string `json:"icon_emoji,omitempty"`
Channel string `json:"channel,omitempty"`
UnfurlLinks bool `json:"unfurl_links"`
Attachments []Attachment `json:"attachments,omitmepty"`
Attachments []Attachment `json:"attachments,omitempty"`
}

type Attachment struct {
Expand All @@ -44,7 +43,6 @@ type Attachment struct {
AuthorIcon string `json:"author_icon,omitempty"`
Footer string `json:"footer,omitempty"`
Fields []Field `json:"fields,omitempty"`

}

type Field struct {
Expand All @@ -66,9 +64,9 @@ func main() {
}

minimal := os.Getenv(EnvMinimal)
fields := []Field{}
fields := []Field{}
if minimal == "true" {
mainFields:= []Field{
mainFields := []Field{
{
Title: os.Getenv(EnvSlackTitle),
Value: envOr(EnvSlackMessage, "EOM"),
Expand All @@ -77,12 +75,12 @@ func main() {
}
fields = append(mainFields, fields...)
} else {
mainFields:= []Field{
mainFields := []Field{
{
Title: "Ref",
Value: os.Getenv("GITHUB_REF"),
Short: true,
}, {
}, {
Title: "Event",
Value: os.Getenv("GITHUB_EVENT_NAME"),
Short: true,
Expand All @@ -103,7 +101,7 @@ func main() {

hostName := os.Getenv(EnvHostName)
if hostName != "" {
newfields:= []Field{
newfields := []Field{
{
Title: os.Getenv("SITE_TITLE"),
Value: os.Getenv(EnvSiteName),
Expand All @@ -125,13 +123,13 @@ func main() {
Channel: os.Getenv(EnvSlackChannel),
Attachments: []Attachment{
{
Fallback: envOr(EnvSlackMessage, "GITHUB_ACTION=" + os.Getenv("GITHUB_ACTION") + " \n GITHUB_ACTOR=" + os.Getenv("GITHUB_ACTOR") + " \n GITHUB_EVENT_NAME=" + os.Getenv("GITHUB_EVENT_NAME") + " \n GITHUB_REF=" + os.Getenv("GITHUB_REF") + " \n GITHUB_REPOSITORY=" + os.Getenv("GITHUB_REPOSITORY") + " \n GITHUB_WORKFLOW=" + os.Getenv("GITHUB_WORKFLOW")),
Fallback: envOr(EnvSlackMessage, "GITHUB_ACTION="+os.Getenv("GITHUB_ACTION")+" \n GITHUB_ACTOR="+os.Getenv("GITHUB_ACTOR")+" \n GITHUB_EVENT_NAME="+os.Getenv("GITHUB_EVENT_NAME")+" \n GITHUB_REF="+os.Getenv("GITHUB_REF")+" \n GITHUB_REPOSITORY="+os.Getenv("GITHUB_REPOSITORY")+" \n GITHUB_WORKFLOW="+os.Getenv("GITHUB_WORKFLOW")),
Color: envOr(EnvSlackColor, "good"),
AuthorName: envOr(EnvGithubActor, ""),
AuthorLink: "http://github.com/" + os.Getenv(EnvGithubActor),
AuthorIcon: "http://github.com/" + os.Getenv(EnvGithubActor) + ".png?size=32",
Footer: envOr(EnvSlackFooter, "<https://github.com/rtCamp/github-actions-library|Powered By rtCamp's GitHub Actions Library>"),
Fields: fields,
Footer: envOr(EnvSlackFooter, "<https://github.com/rtCamp/github-actions-library|Powered By rtCamp's GitHub Actions Library>"),
Fields: fields,
},
},
}
Expand Down