This is an automated email from the ASF dual-hosted git repository.

wilfreds pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-release.git


The following commit(s) were added to refs/heads/master by this push:
     new d707f57  [YUNIKORN-2425] Use 'go mod edit' to replace module path 
(#170)
d707f57 is described below

commit d707f573d87eb863388de39f02fdb57f0daaf15e
Author: Craig Condit <[email protected]>
AuthorDate: Tue Feb 20 14:50:22 2024 +1100

    [YUNIKORN-2425] Use 'go mod edit' to replace module path (#170)
    
    Instead of manual file editing, use the go standard tooling to replace
    references to yunikorn-core and yunikorn-scheduler-interface in go.mod 
files.
    
    Closes: #170
    
    Signed-off-by: Wilfred Spiegelenburg <[email protected]>
---
 tools/build-release.py | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/tools/build-release.py b/tools/build-release.py
index fba52aa..8331855 100755
--- a/tools/build-release.py
+++ b/tools/build-release.py
@@ -210,12 +210,15 @@ def update_dep_ref_k8shim(local_repo_path):
     mod_file = os.path.join(local_repo_path, "go.mod")
     if not os.path.isfile(mod_file):
         fail("k8shim go.mod does not exist")
-    with open(mod_file, "a") as file_object:
-        file_object.write("\n")
-        file_object.write("replace github.com/apache/yunikorn-core => ../core 
\n")
-        file_object.write(
-            "replace github.com/apache/yunikorn-scheduler-interface => 
../scheduler-interface \n")
-
+    path = os.getcwd()
+    os.chdir(local_repo_path)
+    command = ['go', 'mod', 'edit']
+    command.extend(['-replace', 'github.com/apache/yunikorn-core=../core'])
+    command.extend(['-replace', 
'github.com/apache/yunikorn-scheduler-interface=../scheduler-interface'])
+    retcode = subprocess.call(command)
+    if retcode:
+        fail("failed to update k8shim go.mod references")
+    os.chdir(path)
 
 # core depends on scheduler-interface
 def update_dep_ref_core(local_repo_path):
@@ -223,10 +226,14 @@ def update_dep_ref_core(local_repo_path):
     mod_file = os.path.join(local_repo_path, "go.mod")
     if not os.path.isfile(mod_file):
         fail("core go.mod does not exist")
-    with open(mod_file, "a") as file_object:
-        file_object.write("\n")
-        file_object.write(
-            "replace github.com/apache/yunikorn-scheduler-interface => 
../scheduler-interface \n")
+    path = os.getcwd()
+    os.chdir(local_repo_path)
+    command = ['go', 'mod', 'edit']
+    command.extend(['-replace', 
'github.com/apache/yunikorn-scheduler-interface=../scheduler-interface'])
+    retcode = subprocess.call(command)
+    if retcode:
+        fail("failed to update core go.mod references")
+    os.chdir(path)
 
 
 # update go mod in the repos


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to