Skip to content

Commit

Permalink
update to avoid hard coding of the artifactType
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella Liu <isabellaliu77@gmail.com>
  • Loading branch information
IsabellaDev committed Oct 17, 2020
1 parent e4b9ab3 commit d3d5d74
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"net/http"
"regexp"
"strconv"
"strings"
"time"

"github.com/konveyor/move2kube-api/internal/application"
Expand Down Expand Up @@ -182,18 +181,11 @@ func generateTargetArtifacts(w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"]
plan := r.FormValue("plan")

helmTargetArtifactTypeValue := "Helm"
yamlsTargetArtifactTypeValue := "Yamls"
knativeTargetArtifactTypeValue := "Knative"

re := regexp.MustCompile(`artifacttype:\\s.*`)
artifactTypematch := re.FindString(plan)
artifactType := yamlsTargetArtifactTypeValue
if strings.HasSuffix(artifactTypematch, knativeTargetArtifactTypeValue) {
artifactType = knativeTargetArtifactTypeValue
} else if strings.HasSuffix(artifactTypematch, helmTargetArtifactTypeValue) {
artifactType = helmTargetArtifactTypeValue
}
match := []rune(artifactTypematch)
artifactType := string(match[16:len(match)])

t := time.Now()
artifactName := name + "_" + artifactType + "_" + strconv.FormatInt(t.Unix(), 10)
log.Infof("Artifact Name:%s", artifactName)
Expand Down

0 comments on commit d3d5d74

Please sign in to comment.