Skip to content

Commit

Permalink
update to remove any hardcoding, and remove possible whitespaces
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 18, 2020
1 parent d3d5d74 commit 5c42e08
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/http"
"regexp"
"strconv"
"strings"
"time"

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

re := regexp.MustCompile(`artifacttype:\\s.*`)
re := regexp.MustCompile(`artifactType:\s.*`)
artifactTypematch := re.FindString(plan)
match := []rune(artifactTypematch)
artifactType := string(match[16:len(match)])
var artifactType string
if artifactTypematch == "" {
artifactType = ""
} else {
match := []rune(artifactTypematch)
name := string(match[len("artifactType:"):len(match)])
artifactType = strings.Replace(name, " ", "", -1)
}

t := time.Now()
artifactName := name + "_" + artifactType + "_" + strconv.FormatInt(t.Unix(), 10)
Expand Down

0 comments on commit 5c42e08

Please sign in to comment.