Skip to content

Commit

Permalink
[YUNIKORN-2425] Use 'go mod edit' to replace internal module references
Browse files Browse the repository at this point in the history
Instead of manual file editing, use the go standard tooling to replace
references to yunikorn-core and yunikorn-scheduler-interface in go.mod files.
  • Loading branch information
craigcondit committed Feb 15, 2024
1 parent 98e831e commit ec01c09
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions tools/build-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,30 @@ 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):
print("updating dependency for core")
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
Expand Down

0 comments on commit ec01c09

Please sign in to comment.