Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13.7 AS builder
FROM golang:1.19 AS builder
WORKDIR /go/src/github.com/evnsio/decision/
COPY ./ .
ENV GOOS=linux
Expand Down
41 changes: 20 additions & 21 deletions cmd/decision/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ package main
import (
"encoding/json"
"fmt"
"github.com/evnsio/decision/pkg/git"
"io"
"io/ioutil"
"net/http"
"os"
"strings"

"github.com/namsral/flag"

"github.com/evnsio/decision/pkg/decision"
"github.com/evnsio/decision/pkg/github"

"github.com/slack-go/slack"
)

Expand All @@ -29,7 +27,7 @@ func handleSlash(w http.ResponseWriter, r *http.Request) {
return
}

r.Body = ioutil.NopCloser(io.TeeReader(r.Body, &verifier))
r.Body = io.NopCloser(io.TeeReader(r.Body, &verifier))
s, err := slack.SlashCommandParse(r)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down Expand Up @@ -108,12 +106,13 @@ func parseFlags() {
flag.BoolVar(&decision.CommitAsPRs, "commit-as-prs", false, "Commit decisions as Pull Requests")
flag.StringVar(&decision.Token, "slack-token", "", "Your Slack API token starting xoxb-...")
flag.StringVar(&signingSecret, "slack-signing-secret", "", "Your Slack signing secret")
flag.StringVar(&github.Token, "github-token", "", "Your GitHub access token")
flag.StringVar(&github.SourceOwner, "source-owner", "", "The owner / organisation of the repo where decisions will be committed")
flag.StringVar(&github.SourceRepo, "source-repo", "", "The repo where decisions will be committed")
flag.StringVar(&github.CommitBranch, "branch", "master", "The branch where decisions will be committed")
flag.StringVar(&github.AuthorName, "commit-author", "", "The author name to use for commits")
flag.StringVar(&github.AuthorEmail, "commit-email", "", "The author email to use for commits")
flag.StringVar(&git.ProviderType, "provider", "github", "Your git provider, github or gitlab")
flag.StringVar(&git.Token, "provider-token", "", "Your access token for your Git provider")
flag.StringVar(&git.SourceOwner, "source-owner", "", "The owner / organisation of the repo where decisions will be committed")
flag.StringVar(&git.SourceRepo, "source-repo", "", "The repo where decisions will be committed")
flag.StringVar(&git.CommitHeadBranch, "branch", "main", "The branch where decisions will be committed")
flag.StringVar(&git.AuthorName, "commit-author", "", "The author name to use for commits")
flag.StringVar(&git.AuthorEmail, "commit-email", "", "The author email to use for commits")
flag.Parse()

if decision.Token == "" {
Expand All @@ -135,39 +134,39 @@ func parseFlags() {
fmt.Printf("Slack Signing Secret: %v\n", redact(signingSecret))
}

if github.Token == "" {
fmt.Fprintln(os.Stderr, "missing required argument -github-token")
if git.Token == "" {
fmt.Fprintln(os.Stderr, "missing required argument -provider-token")
os.Exit(2)
} else {
fmt.Printf("Github Token: %v\n", redact(github.Token))
fmt.Printf("Github Token: %v\n", redact(git.Token))
}

if github.SourceOwner == "" {
if git.SourceOwner == "" {
fmt.Fprintln(os.Stderr, "missing required argument -source-owner")
os.Exit(2)
} else {
fmt.Printf("Source Owner: %v\n", redact(github.SourceOwner))
fmt.Printf("Source Owner: %v\n", redact(git.SourceOwner))
}

if github.SourceRepo == "" {
if git.SourceRepo == "" {
fmt.Fprintln(os.Stderr, "missing required argument -source-repo")
os.Exit(2)
} else {
fmt.Printf("Source Repo: %v\n", redact(github.SourceRepo))
fmt.Printf("Source Repo: %v\n", redact(git.SourceRepo))
}

if github.AuthorName == "" {
if git.AuthorName == "" {
fmt.Fprintln(os.Stderr, "missing required argument -commit-author")
os.Exit(2)
} else {
fmt.Printf("Commit Author: %v\n", redact(github.AuthorName))
fmt.Printf("Commit Author: %v\n", redact(git.AuthorName))
}

if github.AuthorEmail == "" {
if git.AuthorEmail == "" {
fmt.Fprintln(os.Stderr, "missing required argument -commit-email")
os.Exit(2)
} else {
fmt.Printf("Commit Email: %v\n", redact(github.AuthorEmail))
fmt.Printf("Commit Email: %v\n", redact(git.AuthorEmail))
}
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.13
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/gosimple/slug v1.9.0
github.com/namsral/flag v1.7.4-pre
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/slack-go/slack v0.6.4
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
github.com/xanzy/go-gitlab v0.73.1 // indirect
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c
)
Loading