ScriptCollection 4.4.24__py3-none-any.whl → 4.4.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,11 +17,15 @@ class OCIImageManager:
17
17
 
18
18
  __sc:ScriptCollectionCore=None
19
19
  image_handler:list[AbstractImageHandler] = None
20
+ #image-names for which it was already logged that the fallback-registry is used. The lookup happens for every image of
21
+ #the repository and often several times per build, so without this the same hint would flood the log.
22
+ __images_with_reported_fallback_registry:set[str] = None
20
23
 
21
24
  def __init__(self,sc:ScriptCollectionCore):
22
25
  if sc is None:
23
26
  sc=ScriptCollectionCore()
24
27
  self.__sc=sc
28
+ self.__images_with_reported_fallback_registry=set()
25
29
  self.image_handler=[
26
30
  ImageHandlerDebian(),
27
31
  ImageHandlerDebianSlim(),
@@ -44,7 +48,18 @@ class OCIImageManager:
44
48
  return os.path.join(repository,".ScriptCollection","OCIImages","ImageDefinition.csv")
45
49
 
46
50
  @GeneralUtilities.check_arguments
47
- def get_global_docker_image_registries_file(self)->str:
51
+ def get_image_registries_file_in_container(self)->str:
52
+ """Returns the file inside a build-container to which the host mounts its image-registries-file (see
53
+ TFCPS_CodeUnit_BuildCodeUnits.__run_scriptcollection_executable_in_container). It is an own path (and not the
54
+ configuration-folder of the container-user) because the home-folder inside the container depends on the user the
55
+ image runs as, while this path is defined by the mount and is therefore identical for both sides."""
56
+ return "/Workspace/ScriptCollectionConfiguration/OCIImages/ImageRegistries.csv"
57
+
58
+ @GeneralUtilities.check_arguments
59
+ def get_image_registries_file_in_configuration_folder(self)->str:
60
+ """Returns the image-registries-file in the configuration-folder of the current user, and creates it if it does not exist yet.
61
+ This is the file of the machine on which a command was started, so it is also the file which is mounted into a build-container
62
+ (in contrast to get_global_docker_image_registries_file, which inside a container resolves to that mount instead)."""
48
63
  folder=os.path.join(self.__sc.get_global_cache_folder(),"OCIImages")
49
64
  GeneralUtilities.ensure_directory_exists(folder)
50
65
  result=os.path.join(folder,"ImageRegistries.csv")
@@ -52,6 +67,17 @@ class OCIImageManager:
52
67
  GeneralUtilities.ensure_file_exists(result)
53
68
  GeneralUtilities.write_lines_to_file(result,["ImageName;RegistryAddress"])
54
69
  return result
70
+
71
+ @GeneralUtilities.check_arguments
72
+ def get_global_docker_image_registries_file(self)->str:
73
+ """Returns the machine-wide file which maps an image-name to the custom registry-address the image should be taken from.
74
+ The file which the host mounted into a build-container has precedence over the file in the configuration-folder of the
75
+ current user: in a container that configuration-folder belongs to the container-user and therefore never contains the
76
+ configuration of the machine on which the build was started."""
77
+ mounted_file=self.get_image_registries_file_in_container()
78
+ if os.path.isfile(mounted_file):
79
+ return mounted_file
80
+ return self.get_image_registries_file_in_configuration_folder()
55
81
 
56
82
  @GeneralUtilities.check_arguments
57
83
  def get_used_images_in_repository(self,repository:str)->list[str]:
@@ -93,9 +119,21 @@ class OCIImageManager:
93
119
  repository_image_definition_file=self.get_repository_image_definition_file(repository)
94
120
  for line in [f.split(";") for f in GeneralUtilities.read_nonempty_lines_from_file(repository_image_definition_file)[1:]]:
95
121
  if image_name==line[0]:
122
+ self.__report_usage_of_fallback_registry(image_name,line[1])
96
123
  return line[1]
97
124
  raise ValueError(f"No registry defined for image \"{image_name}\".")
98
125
 
126
+ @GeneralUtilities.check_arguments
127
+ def __report_usage_of_fallback_registry(self,image_name:str,fallback_registry_address:str)->None:
128
+ """Logs that the image is taken from the upstream-registry defined in the repository because no custom registry is defined for it.
129
+ The fallback exists so that a freshly cloned product is buildable without further setup, but an upstream-registry is typically
130
+ rate-limited, so using it is worth a hint."""
131
+ if image_name in self.__images_with_reported_fallback_registry:
132
+ return
133
+ self.__images_with_reported_fallback_registry.add(image_name)
134
+ registries_file=self.get_global_docker_image_registries_file()
135
+ self.__sc.log.log(f"No custom registry is defined for image \"{image_name}\" in \"{registries_file}\", so the fallback-registry \"{fallback_registry_address}\" is used.",LogLevel.Warning)
136
+
99
137
  @GeneralUtilities.check_arguments
100
138
  def get_registry_address_for_image_with_default_tag(self,repository:str,image_name:str)->str:
101
139
  return f"{self.get_registry_address_for_image(repository,image_name)}:{self.get_tag_for_image(repository,image_name)}"
@@ -40,7 +40,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
40
40
  from .ProgramRunnerPopen import ProgramRunnerPopen
41
41
  from .SCLog import SCLog, LogLevel
42
42
 
43
- version = "4.4.24"
43
+ version = "4.4.27"
44
44
  __version__ = version
45
45
 
46
46
  class VSCodeWorkspaceShellTask:
@@ -3054,8 +3054,9 @@ chmod {permission} {link_file}
3054
3054
 
3055
3055
  # create debfile
3056
3056
  deb_filename = f"{toolname}.deb"
3057
- self.run_program_argsasarray("tar", ["czf", f"../{entireresult_content_folder_name}/control.tar.gz", "*"], packagecontent_control_folder)
3058
- self.run_program_argsasarray("tar", ["czf", f"../{entireresult_content_folder_name}/data.tar.gz", "*"], packagecontent_data_folder)
3057
+ # remark: the content of the folders is passed to tar as "." and not as "*" because the programs are started without a shell, so a wildcard would not be expanded and would be treated as a literal filename
3058
+ self.run_program_argsasarray("tar", ["czf", f"../{entireresult_content_folder_name}/control.tar.gz", "."], packagecontent_control_folder)
3059
+ self.run_program_argsasarray("tar", ["czf", f"../{entireresult_content_folder_name}/data.tar.gz", "."], packagecontent_data_folder)
3059
3060
  self.run_program_argsasarray("ar", ["r", deb_filename, "debian-binary", "control.tar.gz", "data.tar.gz"], packagecontent_entireresult_folder)
3060
3061
  result_file = os.path.join(packagecontent_entireresult_folder, deb_filename)
3061
3062
  shutil.copy(result_file, os.path.join(deb_output_folder, deb_filename))
@@ -402,6 +402,17 @@ class TFCPS_CodeUnit_BuildCodeUnits:
402
402
  if os.path.isdir(custom_scripts_folder_for_inside_the_container):
403
403
  mount_arguments += ["-v", f"{custom_scripts_folder_for_inside_the_container}:{self.tfcps_tools_general.get_folder_of_custom_scripts_in_container()}"]
404
404
 
405
+ #mount the machine-wide image-registries-file of this host (if it exists), so the build inside the container takes the images from the same
406
+ #custom registries as a build on the host. Without the mount the build in the container would find no mapping at all - the
407
+ #configuration-folder inside the container belongs to the container-user and is empty - and would therefore fall back to the
408
+ #upstream-registries defined in the repository, which are rate-limited. The mount is read-only because a build never changes the file.
409
+ #Only this file is mounted and not the whole configuration-folder, so nothing else of it (in particular not EnvironmentVariables.csv or
410
+ #RegistryCredentials.csv, which contain credentials) is exposed to the container.
411
+ oci_image_manager = self.tfcps_tools_general.oci_image_manager
412
+ image_registries_file: str = oci_image_manager.get_image_registries_file_in_configuration_folder()
413
+ if os.path.isfile(image_registries_file):
414
+ mount_arguments += ["-v", f"{image_registries_file}:{oci_image_manager.get_image_registries_file_in_container()}:ro"]
415
+
405
416
  #pass the environment-variables which are declared as required in <repository>/.ScriptCollection/ProductInformation.xml into the container
406
417
  #so they do not have to be specified explicitly on every call. Their values are resolved from the user-specific
407
418
  #configuration-file (see TFCPS_Tools_General.get_environment_variables_configuration_file), which only exists on the host.
@@ -1808,13 +1808,18 @@ class TFCPS_Tools_General:
1808
1808
  changed on purpose therefore needs this - it says "this is the new state" - and the changed lock-files belong to
1809
1809
  the commit of that change.
1810
1810
  No runtime is named, so the restore resolves the runtimes which the projects state and writes one lock-file per
1811
- project which covers all of them."""
1811
+ project which covers all of them.
1812
+ "--force" is required because a restore whose inputs did not change since the last restore is skipped entirely
1813
+ (no-op restore) and then writes no lock-file at all. "--force-evaluate" is required because without it an existing
1814
+ lock-file is taken as it is instead of being resolved again."""
1812
1815
  codeunit_name: str = os.path.basename(codeunit_folder)
1813
1816
  sln_file: str = os.path.join(codeunit_folder, f"{codeunit_name}.sln")
1814
1817
  if not os.path.isfile(sln_file):
1815
1818
  raise ValueError(f"The codeunit-folder \"{codeunit_folder}\" does not contain the solution \"{codeunit_name}.sln\", so it is no dotnet-codeunit whose lock-files could be updated.")
1816
1819
  self.__sc.log.log(f"Update the lock-files of codeunit \"{codeunit_name}\"...")
1817
- self.__sc.run_program_argsasarray("dotnet", ["restore", sln_file], codeunit_folder)
1820
+ GeneralUtilities.ensure_file_exists(os.path.join(codeunit_folder, codeunit_name,"packages.lock.json"))
1821
+ GeneralUtilities.ensure_file_exists(os.path.join(codeunit_folder, codeunit_name+"Tests","packages.lock.json"))
1822
+ self.__sc.run_program_argsasarray("dotnet", ["restore", sln_file, "--force", "--force-evaluate"], codeunit_folder)
1818
1823
 
1819
1824
  @GeneralUtilities.check_arguments
1820
1825
  def get_dependency_version_in_resources_folder(self, resources_folder:str, dependency_name: str) ->str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.4.24
3
+ Version: 4.4.27
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
@@ -12,12 +12,12 @@ ScriptCollection/ProgramRunnerSudo.py,sha256=ot9Ib-plQ8wejR9M2XXfnx6GR-va9k8SH1g
12
12
  ScriptCollection/RepositoryDiagramGenerator.py,sha256=K_u2NW_p4ozdWD50irJEkkcDVa70TcUJpZN63TeXSLw,7092
13
13
  ScriptCollection/RepositoryHistoryAnalyzer.py,sha256=rD8eC5lMUe5MHmCBHfYft_G-N9IbvtsFGkU7EMwPjrY,5779
14
14
  ScriptCollection/SCLog.py,sha256=Fjf8Pdi63cXHGMxL_aI6A0dwGm7QIfrv3czjvpSUlaM,4705
15
- ScriptCollection/ScriptCollectionCore.py,sha256=iR8KA1JDlAaQINn56k2v-mszY7ljoTNPLPEBYCQFjm4,276146
15
+ ScriptCollection/ScriptCollectionCore.py,sha256=iWcjDRi8gfu9nt-RTm-JtJggElq-_HDOStDYov6eH-A,276359
16
16
  ScriptCollection/TestKind.py,sha256=EBTLR8yBz5VmWA2NZIpDTbQNg6tkfv_kAsIzEJ--mCI,1756
17
17
  ScriptCollection/UnassignedVariablesCheck.py,sha256=8xNcp1D5HeOLO1a1NEerq2TsnpFhw7yzYPkaay-oisY,3804
18
18
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=WO2M28c2tUwsXFNa2L9zqMhdlyObWm3qpPE0LdIs7SE,2315
20
- ScriptCollection/OCIImages/OCIImageManager.py,sha256=iurHutAS-Rpr9EhHxoVx0wYlDyNKmuu1G2yoO4pFKjU,17160
20
+ ScriptCollection/OCIImages/OCIImageManager.py,sha256=Xfp8ZawYC04_isfeSLm97xW83OhQtdo7j1wyRvmDOqE,20302
21
21
  ScriptCollection/OCIImages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerDebian.py,sha256=rty9SnftreYWLIwvdUn4LhiHqCTevb_tWuYWoOnRJuo,732
23
23
  ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerDebianSlim.py,sha256=M-4qxKWBZRtKdYQ-uXgfrxRBoZTXEjgqCxFXyFxTyzc,736
@@ -37,7 +37,7 @@ ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=tub8_1QBu0nWAaGnBWp2nErOW-SO
37
37
  ScriptCollection/TFCPS/TFCPS_BuildCodeUnitsHook.py,sha256=67_DQwoH5bhxxSmwtuAeoW1NOCMiLMzOy48OqlJX-KY,1744
38
38
  ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=aCfGCbevCOV1IJ444dhvwJkGDKQNH3mqIucPAuSUq-o,40149
39
39
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Mj9t1SyRpkYZE74cLsGWYv4xB89gXL2ld-RX3xvvGdw,9835
40
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=EVC50YNlaiB16JwBnayIvtVbGpFY0kYRvQOGs23PgnA,47398
40
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=l8xfp7n-gDF_cwngox6gJkv5ShHP0oGSBzVXENj-3bM,48546
41
41
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=kpEmSnfzfgB4OjcCuS_X6jgW_ftcphxEnjjoLoAHTLY,6582
42
42
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=mRBcf7XuNWOSXbZYc3NuJow18AMZ30D6Z-BtyNYfNcM,2072
43
43
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=Krt5oyGNcRAN3szsgU7LoTh8yVTOdHW-Kq7R9MDDV-Q,7673
@@ -45,7 +45,7 @@ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=oYEhz5ZWMnbu97_CcYEqdDxakUF
45
45
  ScriptCollection/TFCPS/TFCPS_OCIImageSecretScan.py,sha256=rhw0glr4gZ5enG9faOD51xE4MMK1cIdNjUdaswiMsrY,14622
46
46
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=XLVsFTA1jvfDbZ7wYJgIdEByZhF_bYVbA5jkisuvK4k,2322
47
47
  ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=gQQbk7Va7c_0VL2pu_UYM-GPkbQxe0vvs2D_gJdZulI,21103
48
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=vfURo1uDtJVH45EwLd8APWix4FMCUEirXS941hFnG6g,159039
48
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=49gtLQO_V3T9SYiuIp9sqDxSZ4BSWhl8GD7BEV-Hils,159611
49
49
  ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py,sha256=6_63udxHnPlu_TMk_ftLZTnzriJO8MCxVCVAsweZqHs,37073
50
50
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  ScriptCollection/TFCPS/CPP/TFCPS_CodeUnitSpecific_CPP.py,sha256=4skj2I73VOo93HMXcBuWmdyuoE9zjqr2H_DtsYrcvNo,16375
@@ -71,8 +71,8 @@ ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=yyjWPMHQjPLkML
71
71
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  ScriptCollection/TFCPS/TypeScript/TFCPS_CodeUnitSpecific_TypeScript.py,sha256=5z990qyO5durX07xRWRwju1hl6wpjQAy2f-yRwJ-7s0,11856
73
73
  ScriptCollection/TFCPS/TypeScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- scriptcollection-4.4.24.dist-info/METADATA,sha256=zUUw_zEeCAQclVZguwET6TJ1R6A_1p5EkfzhDlNze2k,7690
75
- scriptcollection-4.4.24.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
- scriptcollection-4.4.24.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
77
- scriptcollection-4.4.24.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
- scriptcollection-4.4.24.dist-info/RECORD,,
74
+ scriptcollection-4.4.27.dist-info/METADATA,sha256=Cij77fI-TR6ZbCJ71yzztVtCEE1pH21SzhNglSkXdvQ,7690
75
+ scriptcollection-4.4.27.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
+ scriptcollection-4.4.27.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
77
+ scriptcollection-4.4.27.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
+ scriptcollection-4.4.27.dist-info/RECORD,,