Skip to content

Commit

Permalink
action: fixed golang-migrate format (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored May 30, 2023
1 parent 6892c0c commit 411756a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ func Input(act *githubactions.Action) (atlascloud.ReportDirInput, error) {
if err != nil {
return atlascloud.ReportDirInput{}, err
}
dirFormat := atlascloud.DirFormat(strings.ToUpper(act.GetInput("dir-format")))
if dirFormat == "" {
dirFormat = atlascloud.DirFormatAtlas
fi := act.GetInput("dir-format")
dirFmt, err := dirFormat(fi)
if err != nil {
return atlascloud.ReportDirInput{}, err
}
return atlascloud.ReportDirInput{
Repo: fmt.Sprintf("%s/%s", org, repo),
Expand All @@ -90,7 +91,7 @@ func Input(act *githubactions.Action) (atlascloud.ReportDirInput, error) {
Path: act.GetInput("dir"),
Url: ev.HeadCommit.URL,
Driver: drv,
DirFormat: dirFormat,
DirFormat: dirFmt,
ArchiveFormat: atlascloud.ArchiveFormatB64Tar,
}, nil
}
Expand All @@ -110,6 +111,19 @@ func driver(s string) (atlascloud.Driver, error) {
}
}

func dirFormat(s string) (atlascloud.DirFormat, error) {
switch s := strings.ToLower(s); s {
case "atlas", "":
return atlascloud.DirFormatAtlas, nil
case "flyway":
return atlascloud.DirFormatFlyway, nil
case "golang-migrate":
return atlascloud.DirFormatGolangMigrate, nil
default:
return "", fmt.Errorf("unknown dir-format %q", s)
}
}

func client(act *githubactions.Action) *atlascloud.Client {
isPublic := strings.ToLower(act.GetInput("cloud-public")) == "true"
token := act.GetInput("cloud-token")
Expand Down

0 comments on commit 411756a

Please sign in to comment.