1
+ Include %IPM .Common
2
+
1
3
Class %IPM .Repo .Oras .PublishService Extends (%IPM .Repo .Oras .PackageService , %IPM .Repo .IPublishService )
2
4
{
3
5
@@ -6,7 +8,7 @@ Method PublishModule(pModule As %IPM.Repo.Remote.ModuleInfo) As %Status
6
8
Set status = $$$OK
7
9
Try {
8
10
Set repo = pModule .Name
9
- Set tag = pModule .VersionString
11
+ Set tag = $$$Semver2Tag( pModule .VersionString )
10
12
11
13
#; Use a temp directory
12
14
Set tDir = $$$FileTempDir
@@ -85,7 +87,7 @@ ClassMethod Push(registry As %String, package As %String, namespace As %String,
85
87
{
86
88
#; Remove the tag from the package name if it exists and add it to tags
87
89
Set repo = $piece (package , " :" , 1 )
88
- Set tag = $piece (package , " :" , 2 )
90
+ Set tag = $$$Semver2Tag( $ piece (package , " :" , 2 ) )
89
91
If tag '= " " { Set tags = tags _ " ," _ tag }
90
92
If tags = " " {
91
93
$$$ThrowStatus($$$ERROR($$$GeneralError," Must specify version." ))
@@ -108,31 +110,31 @@ ClassMethod PushPy(registry As %String, package As %String, namespace As %String
108
110
import iris
109
111
import os , sys
110
112
import json
113
+ import re
111
114
112
115
# Get all files in the directory and fully specify path
113
- files = os .listdir (directoryPath )
114
- result = map (lambda x : directoryPath + x , files )
115
- file _paths = list (result )
116
-
116
+ file _paths = [os .path .join (directoryPath , f ) for f in os .listdir (directoryPath )]
117
117
client = iris .cls (" %IPM.Repo.Oras.PackageService" ).GetClient (registry , username , password , token , tokenAuthMethod )
118
+ regex = re .compile (r " ^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$" )
118
119
119
120
# Push once for each tag
120
121
for tag in tags .split (" ," ):
121
- if tag == " " :
122
- continue
122
+ if not regex . search ( tag ) :
123
+ raise ValueError ( f " Invalid OCI tag: {tag} " )
123
124
124
125
# Annotations are manifest .xml and other metadata
125
126
manifest _annotations = json .loads (metadata )
126
127
128
+ # TODO write a context manager for stdout /stderr redirection
127
129
# Suppress console output
128
130
sys .stdout = open (os .devnull , " w" )
129
131
130
- target = iris .cls (" %IPM.Repo.Oras.PackageService" ).GetAPITarget (registry , package , namespace ) + " :" + tag
131
-
132
132
try :
133
+ target = iris .cls (" %IPM.Repo.Oras.PackageService" ).GetAPITarget (registry , package , namespace ) + " :" + tag
133
134
res = client .push (files =file _paths , target =target , disable _path _validation =True , manifest _annotations =manifest _annotations )
134
135
except Exception as e :
135
- print (" Error: " , repr (e ))
136
+ print (" Error: " , repr (e ), file =sys .stderr )
137
+ sys .stdout = sys .__stdout __
136
138
raise e
137
139
138
140
# Reenable console output
0 commit comments