diff --git a/go_modules b/go_modules
index 86b8a70..2428f97 100755
--- a/go_modules
+++ b/go_modules
@@ -182,7 +182,7 @@ def extract(filename, outdir):
os.chdir(cwd)
-def cmd_go_mod(cmd, moddir):
+def cmd_go_mod(cmd, moddir, env):
"""Execute go mod subcommand using subprocess.run().
Capture both stderr and stdout as text.
Log as info or error in this function body.
@@ -191,9 +191,9 @@ def cmd_go_mod(cmd, moddir):
log.info(f"go mod {cmd}")
# subprocess.run() returns CompletedProcess cp
if sys.version_info >= (3, 7):
- cp = run(["go", "mod", cmd], cwd=moddir, capture_output=True, text=True)
+ cp = run(["go", "mod", cmd], cwd=moddir, capture_output=True, text=True, env=env)
else:
- cp = run(["go", "mod", cmd], cwd=moddir)
+ cp = run(["go", "mod", cmd], cwd=moddir, env=env)
if cp.returncode:
log.error(cp.stderr.strip())
return cp
@@ -220,6 +220,10 @@ def main():
parser.add_argument("--basename")
parser.add_argument("--vendorname", default=DEFAULT_VENDOR_STEM)
parser.add_argument("--subdir")
+ parser.add_argument("--GOPRIVATE", default=None)
+ parser.add_argument("--GODEBUG", default="x509ignoreCN=0")
+ parser.add_argument("--GOCACHE", default="/tmp/GOCACHE")
+ parser.add_argument("--GOPATH", default="/tmp/GOPATH")
args = parser.parse_args()
outdir = args.outdir
@@ -268,9 +272,16 @@ def main():
# (also downloads but use separate steps for visibility in OBS environment)
# - go mod verify
# (validates checksums)
+
+ env=os.environ
+ if args.GOPRIVATE is not None:
+ env["GOPRIVATE"]=args.GOPRIVATE
+ env["GODEBUG"]=args.GODEBUG
+ env["GOCACHE"]=args.GOCACHE
+ env["GOPATH"]=args.GOPATH
# return value cp is type subprocess.CompletedProcess
- cp = cmd_go_mod("download", go_mod_dir)
+ cp = cmd_go_mod("download", go_mod_dir, env)
if cp.returncode:
if "invalid version" in cp.stderr:
log.warning(
@@ -283,12 +294,12 @@ def main():
log.error("go mod download failed")
exit(1)
- cp = cmd_go_mod("vendor", go_mod_dir)
+ cp = cmd_go_mod("vendor", go_mod_dir, env)
if cp.returncode:
log.error("go mod vendor failed")
exit(1)
- cp = cmd_go_mod("verify", go_mod_dir)
+ cp = cmd_go_mod("verify", go_mod_dir, env)
if cp.returncode:
log.error("go mod verify failed")
exit(1)
diff --git a/go_modules.service b/go_modules.service
index f2edd20..db82476 100644
--- a/go_modules.service
+++ b/go_modules.service
@@ -19,4 +19,16 @@
Specify the name for the generated vendor tarball. Default: vendor
+
+ Comma-separated list of glob patterns
+
+
+ Enable various debugging facilities. default="x509ignoreCN=0"
+
+
+ The directory where the go command will store cached information for reuse in future builds. default="/tmp/GOCACHE"
+
+
+ The Go path is used to resolve import statements. default="/tmp/GOPATH"
+