From 0c050372cc95f231f68164ff2d8164d085ea3ccc Mon Sep 17 00:00:00 2001 From: Grégoire Duchêne Date: Mon, 9 Sep 2019 21:18:59 +0100 Subject: Add a version for GCP Cloud Run --- lib/lib.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/lib.go (limited to 'lib/lib.go') diff --git a/lib/lib.go b/lib/lib.go new file mode 100644 index 0000000..b066e69 --- /dev/null +++ b/lib/lib.go @@ -0,0 +1,26 @@ +// Copyright (c) 2019, Grégoire Duchêne +// +// Use of this source code is governed by the ISC license that can be +// found in the LICENSE file. + +package lib + +import ( + "fmt" + "os" + "strings" +) + +func GetBody(pkg string) string { + dest := strings.TrimRight(os.Getenv("DEST"), "/") + "/" + getRepo(pkg) + return fmt.Sprintf(` + +go-import-redirect +`, pkg, os.Getenv("VCS"), dest) +} + +func getRepo(pkg string) string { + prefix := strings.TrimRight(os.Getenv("PREFIX"), "/") + path := strings.TrimLeft(strings.TrimPrefix(pkg, prefix), "/") + return strings.Split(path, "/")[0] +} -- cgit v1.2.3-70-g09d2