Skip to content

Commit

Permalink
Rewrite of ListRegistries
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Jan 22, 2024
1 parent f23ca46 commit 604b2e7
Show file tree
Hide file tree
Showing 46 changed files with 320 additions and 192 deletions.
11 changes: 11 additions & 0 deletions APLSource/Client/DefineRegistry.aplc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
:Else
ns.uriy
:EndIf
'"uri": invalid data type'Assert' '=10ns.uri
:If {1='^http[s]?://'⎕S 0⎕C }ns.uri
:AndIf 1<+/ns.uri=':'
ns.(uri port){((1),':',(2))(3)}':'()ns.uri
ns.port⊃⊃(//)⎕VFI ns.port
:EndIf
'Invalid variables'Assert/(' '~¨ns.⎕NL 2)varsList
¨ns.{'_',,'','ns.',}¨'id' 'uri' 'priority' use private fields for reserved properties
¨ns.{,'','ns.',}¨varsList~'id' 'uri' 'priority' use property setters for validation on rest
Expand Down Expand Up @@ -145,6 +151,11 @@
rget
r_id
set value
'"id": invalid depth'Assert 1=value.NewValue
'"id": invalid data type'Assert' '=10value.NewValue
_idvalue.NewValue
:EndProperty

:Property proxy
Expand Down
6 changes: 3 additions & 3 deletions APLSource/Client/EstablishRumbaClients.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
∆PermanentConnections⎕NS''
:EndIf
regsListRegistries''
regs(0<regs[;4])regs
regs(IsHTTP¨regs[;1])regs
regs(0<regs[;RegistryIndices.priority])regs
regs(IsHTTP¨regs[;RegistryIndices.url])regs
'No registries found'Assert 0<regs
:Trap 345
Connect2Client¨¨CompileUrlPlusPort/¨regs[;1 3]
Connect2Client¨¨CompileUrlPlusPort/¨regs[;RegistryIndices.(url port)]
:Else
qdmx⎕DMX
⎕DL 0.2
Expand Down
17 changes: 15 additions & 2 deletions APLSource/Client/EstablishStuffInTatinVars.aplf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{r}{makeHomeRelative}EstablishStuffInTatinVars(ref cfg folder);deps;ref2;res;msg;make;check;f
{r}{makeHomeRelative}EstablishStuffInTatinVars(ref cfg folder);deps;ref2;res;msg;make;check;f;body
We establish some fns (Niladic for impersonating "constants") in TatinVars for convinience
r
makeHomeRelative{0<⎕NC : 0}'makeHomeRelative'
Expand All @@ -19,7 +19,20 @@
:Else
ffolder
:EndIf
resref2.⎕FX'r←HOME' '⍝ Returns the folder the package was loaded from or an empty vector if that cannot be established anymore'('r←''',f,'''')':If ~⎕nexists r' 'r←''''' ':EndIf'
body''
body,'r←HOME;⎕IO;⎕ML;dir;name;extension'
body,'⍝ Returns folder package was loaded from or current directory or an empty vector if both are not valid'
body,'⎕IO←1 ⋄ ⎕ML←1'
body,('r←''',f,''' ⍝ Original source')
body,':If ~⎕nexists r'
body,'(dir name extension)←⎕NPARTS r'
body,'r←(⊃1 ⎕NPARTS''''),(2⊃⎕NPARTS ¯1↓dir),''/'',name,extension ⍝ Try current dir'
body,':AndIf ~⎕nexists r'
body,'r←(⊃1 ⎕NPARTS''''),name,extension'
body,':AndIf ~⎕nexists r'
body,'r←'''''
body,':EndIf'
resref2.⎕FX body
Assert/'HOME'make res
ref2 check'HOME'
resref2.⎕FX'r←ASSETS'('r←''',cfg.assets,'''')
Expand Down
4 changes: 2 additions & 2 deletions APLSource/Client/FindDependencies.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
:If '[]'¯2¯1target
:If '[*]'target
registries1 ListRegistries''
target(registries[;4]>0)registries All Registries with a priority greater than 0
targettarget[;1]
target(registries[;RegistryIndices.priority]>0)registries
targettarget[;RegistryIndices.url]
:ElseIf '[]'¯2¯1target
targetReplaceRegistryAlias target
:EndIf
Expand Down
4 changes: 2 additions & 2 deletions APLSource/Client/GetRegistriesForBuildList.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Returns the URLs for all registries with a priority of greater than 0 (because we do not scan priority=0), ordered by priority.
The Registries are then pinged in order to find out whether they are up and running. Those which are not are remembered on ∆TREE.ignore
buffListRegistries''
buff(buff[;4]>0)buff
r¨{0 80 443: ({-'/'=¯1}),':',(),'/'}/¨buff[;1 3]
buff(buff[;RegistryIndices.priority]>0)buff
r¨{0 80 443: ({-'/'=¯1}),':',(),'/'}/¨buff[;RegistryIndices.(url port)]
r~∆TREE.ignore
rr
Done
33 changes: 16 additions & 17 deletions APLSource/Client/ListRegistries.aplf
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
r{appendPort}ListRegistries type;data
r{appendPort}ListRegistries type;data;RI
List all registries defined in the Client's config file.\\
Returns a matrix with these columns:
* [;1] URL
* [;2] Alias
* [;3] Priority\\
* [;4] API-key (optionally)
* [;1] Alias
* [;2] URL
* [;3] ID
* [;4] Port
* [;5] Priority
* [;6] NoCaching
* [;7] Proxy
* [;8] API-key (optionally)\\
"type" must be either 0 or 1 or empty:\\
* 1 means all data is listed
* Everything else means just the alias, the uri and the priority are listed\\
* Everything else means the API key is not listed\\
If ⍺ is 1 (default is 0) then the second column carries the uri plus the port
in case the port is neither 80 nor 443.
appendPort{0<⎕NC : 0}'appendPort'
r(0,(2+3×1type))''
RIRegistryIndices
r(0,((-1type)+RI.AllIndices))''
'"type" (⍵) must be a Boolean or empty'Assert(type)0 1 ''
:If 0<dataMyUserSettings.registries
:If 1type
rdata.(alias uri port priority api_key)
rr[r[;4];]
:Else
rdata.(uri alias port priority)
rr[r[;4];]
:EndIf
r(-1type)1data.(alias uri id port priority noCaching proxy api_key)
rr[r[;RI.priority];]
:EndIf
:If 0<r
:AndIf appendPort
r[;1]BindProtocolWithPort¨r[;1 3]
:If appendPort0<r
r[;RI.url]BindProtocolWithPort¨r[;RI.(url port)]
:EndIf
9 changes: 5 additions & 4 deletions APLSource/Client/ListVersions.aplf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mat{dateFlag}ListVersions url;client;request;res;url_;registries;registry;buff;flag;port;packageID
mat{dateFlag}ListVersions url;client;request;res;url_;registries;registry;buff;flag;port;packageID;RI
Lists all versions of a package.
`url` is one of:
* An (optional) registry followed by "group" and "name" of a package
Expand All @@ -16,14 +16,15 @@
By default the publishing date is not included, but you my change this by passing a 1 as ⍺.
In that case an additional column is added to the result.
dateFlag{0<⎕NC : 0}'dateFlag'
RIRegistryIndices
:If flag'[*]'3url Special syntax!
:OrIf (~IsHTTP url)('['1url)({1+/'/\'}url)(~':'url)('.'1url)
packageID(flag×3)url
mat(0,(2+dateFlag))
registriesListRegistries 0
:If 0<registries(0<registries[;4])registries Ignore those with a priority of 0
:AndIf 0<registries({()=}registries[;1])registries
:For registry port :In registries[;1 3]
:If 0<registries(0<registries[;RI.priority])registries Ignore those with a priority of 0
:AndIf 0<registries({()=}registries[;RI.url])registries
:For registry port :In registries[;RI.(url port)]
:If IsHTTP registry
url_registry CompileUrlPlusPort port
:Else
Expand Down
28 changes: 28 additions & 0 deletions APLSource/Client/RegistryIndices.aplc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
:Class RegistryIndices
Holds indices useful to index the array returned by `ListRegistries`

:Field Public Shared ReadOnly alias1
:Field Public Shared ReadOnly url2
:Field Public Shared ReadOnly id3
:Field Public Shared ReadOnly port4
:Field Public Shared ReadOnly priority5
:Field Public Shared ReadOnly noCaching6
:Field Public Shared ReadOnly proxy7
:Field Public Shared ReadOnly apiKey8

rAllIndices
:Access Public Shared
ralias,url,id,port,priority,noCaching,proxy,apiKey

rAllNames
:Access Public Shared
r'Alias' 'URL' 'ID' 'Port' 'Priority' 'No-Caching' 'Proxy' 'API-key'

rIndicesAndNames
:Access Public Shared
rAllIndices AllNames

:EndClass
2 changes: 1 addition & 1 deletion APLSource/Client/UserSettings.aplc
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
:Access Public Instance
r
'There is no such registry yet'Assert 0<_registries
:If 0<registry.⎕NC'id' Old stuff might lack ID (introduced with 0.74.0)
:If 0>registry.⎕NC'id' Old stuff might lack ID (introduced with 0.74.0)
ind_registries.idregistry.id
:Else
ind_registries.uriregistry.uri
Expand Down
15 changes: 15 additions & 0 deletions APLSource/Registry/Base64_Encode.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
r{loop}Base64_Encode data
Base64-encodes "data". Tries to do it in one go but falls back to a loop if that causes a WS FULL
`loop` defaults to 0, meaning that we first try to encode the data in one go but fall back to a loop in case of a WS FULL.
You may specify a 1 as left argument in order to enforce the loop
loop{0<⎕NC : 0}'loop'
:If 0=loop
:Trap 1 WS FULL
r1 Base64_ data
:Else
∆Loop
:EndTrap
:Return
:EndIf
-------------------------------
∆Loop:
12 changes: 9 additions & 3 deletions APLSource/Registry/History.apla
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
(
'* 0.103.3 ⋄ 2024-01-18'
' * In the user command script the function `IsScripted` traps 16 rather than 0.'
' * Bug fix: UpdateClient had a problem with `Run.aplf` '
'* 0.104.0 ⋄ 2024-01-22'
' * The results of both `]ListRegistries` and its API counterpart have changed. '
' * `TatinVars.HOME` is now much more flexible now, addressing Dyalog stand-alone applications'
' * Bug fixes'
' * `UpdateClient` had a problem with `Run.aplf`'
' * `UserSettings.ReplaceRegistry` did not correcly identify an `id`'
' * `DefineRegistry` did not allow changing the `id`'
' * `DefineRegistry`''s constructor did not handle a port number as in `''https://localhost:9090''`'
' * `Client.ListRegistries` did not return the `id` - delivers now a changed and complete result'
'* 0.103.2 ⋄ 2024-01-16'
' * New version of FilesAndDirs integrated'
' * ]UserSettings now accepts a flag -home that prints the folder hosting the user settings file'
Expand Down
2 changes: 1 addition & 1 deletion APLSource/Registry/Version.aplf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rVersion
See also `History`
r'Tatin' '0.103.3+1740' '2024-01-17'
r'Tatin' '0.104.0+1754' '2024-01-22'
5 changes: 3 additions & 2 deletions APLSource/Server/Handle_PUT_And_POST.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
:EndIf
:If G.Credentials AcceptCredential apiKey groupName
:If 0='email'Reg.GetGroupData G.RegistryPath groupName
:AndIf 0 G.INI.Get 'CONFIG:EnforceEmailAddress'
responserequest RespondWithHTML 400 'No email address defined' 'You cannot publish without defining an email address for your group.'
:AndIf 0 G.INI.Get'CONFIG:EnforceEmailAddress'
responserequest Respond 400
response.Content'You cannot publish without defining an email address for your group.'
:Else
:If Reg.IsValidPackageID_Complete request.RequestTarget
responseSavePackage request
Expand Down
60 changes: 35 additions & 25 deletions APLSource/Tatin.dyalog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:Namespace Tatin
The ]Tatin user commands for managing packages.\\
* 0.77.0 - 2024-01-16
* 0.77.1 - 2024-01-21

⎕IO1 ⎕ML1

Expand Down Expand Up @@ -1039,17 +1039,26 @@
qdmx.EM ⎕SIGNAL ErrNo
:EndSelect
:Else
:If firstFlag
:AndIf 'Server: The package has already been published'{()}qdmx.EM
:AndIf 'Any'⎕SE.Tatin.GetDeletePolicy url_
packageID2⎕NPARTS source
:AndIf TC.C.YesOrNo packageID,' already published on ',url_,'; overwrite?'
firstFlag0
(rc msg)⎕SE.Tatin.DeletePackage url,packageID
:If 200=rc
∆Again
:If 'Server: The package has already been published'{()}qdmx.EM
:If 'Any'⎕SE.Tatin.GetDeletePolicy url_
:If firstFlag
packageID2⎕NPARTS source
:If TC.C.YesOrNo packageID,' already published on ',url_,'; overwrite?'
firstFlag0
(rc msg)⎕SE.Tatin.DeletePackage url,packageID
:If 200=rc
∆Again
:Else
'Delete attempt failed with status ',(rc),'; publishing therefore not possible'
:Return
:EndIf
:EndIf
:Else
'Deleting already published package failed with status ',(rc),'; publishing therefore not possible'
:Return
:EndIf
:Else
'Delete attempt failed with status ',(rc),'; publishing therefore not possible'
'Server does not allow overwriting an already published package; publishing therefore not possible'
:Return
:EndIf
:EndIf
Expand Down Expand Up @@ -1126,13 +1135,14 @@
:EndIf

rListRegistries Arg;type
rListRegistries Arg;type;captions
type0
:If 0Arg.Switch'full'
typeArg.Switch'full'
:EndIf
rTC.ListRegistries type
r((,[0.5]'URI' 'Alias' 'Port' 'Priority',(1type)/'API-key'),[1]' ')r
captionsTC.RegistryIndices.AllNames
r((,[0.5](-1type)captions),[1]' ')r
r[2;](¨r)¨'-'

Expand Down Expand Up @@ -1184,7 +1194,7 @@
:Trap ErrNo
:If '[?]'{()}arg
'No package specified'Assert 0<{/'?]'}arg
buff{[;1 2]}TC.ListRegistries 0
buff{[;,2]}1 TC.ListRegistries 0
ind'Please select a Registry:'TC.C.Select⎕FMT buff
:If 0=ind
r'Cancelled by user'
Expand Down Expand Up @@ -1603,10 +1613,10 @@
:If 0registry No argument specified? We ping all we know about!
r0 2
:If 0<registriesGetListOfRegistriesForSelection 0
:AndIf 0<registries(TC.Reg.IsHTTP¨registries[;1])registries
:AndIf 0<registriesregistries[{}registries[;1];] Because the same URL might turn up multiple times with different credentials/alias
:AndIf 0<registries(TC.Reg.IsHTTP¨registries[;2])registries
:AndIf 0<registriesregistries[{}registries[;2];] Because the same URL might turn up multiple times with different credentials/alias
'Questioning ',(registries),' Tatin Registr',((1+1=registries)'ies' 'y'),'...'
r{,[1.5]⎕TSYNC{TC.Ping }¨&}registries[;1]
r{,[1.5]⎕TSYNC{TC.Ping }¨&}registries[;2]
:EndIf
:ElseIf (,'?'),registry
:If 0=registries1 SelectRegistry 0
Expand Down Expand Up @@ -1759,7 +1769,7 @@
r,'Returns information regarding the licenses tolerated by a managed Tatin Registry'
r,'' ' ]Tatin.ListLicenses <url> -verbose'
:Case ⎕C'ListRegistries'
r,'List URL, alias, priority and port of all Registries as defined in the user settings.'
r,'List Alias, URL, ID, port and priority all Registries as defined in the user settings.'
r,'' ' ]Tatin.ListRegistries -full'
:Case ⎕C'ListDeprecated'
r,'List all deprecated major versions'
Expand Down Expand Up @@ -1923,17 +1933,17 @@
r,''
r,'-verbose If specified not only the names of the licenses are returned but also their URLs.'
:Case ⎕C'ListRegistries'
r,'Lists URL, alias, priority, port and the no-caching flag of all Registries as defined'
r,'Lists alias, URL, ID, port, priority and the no-caching flag of all Registries as defined'
r,'in the user settings.'
r,'The result is ordered by priority: the one with the highest priority is listed first etc.'
r,''
r,'Notes:'
r,' * Registries with a priority of 0 will not participate in a scan of Registries'
r,' * In case a Registry does not respond when questioned by ]ListRegistries the user is'
r,' given three options: Retry, skip and cancel operation'
r,' given three options: Retry, skip and cancel the whole operation'
r,''
r,'-full By default all data but the API keys are listed. Specify -full if you want the'
r,' API keys to be listed as well.'
r,'-full By default all data but the API keys are listed. Specify -full if you want the'
r,' API keys to be listed as well.'
:Case ⎕C'ListDeprecated'
r,'Lists all deprecated major versions'
r,''
Expand Down Expand Up @@ -2499,8 +2509,8 @@

rGetListOfRegistriesForSelection type
:If 0<rTC.ListRegistries type
r[;2]{0=:'' '[',,']'}¨r[;2]
r[;1]r[;1]{0 80 443: (¯1),':',(),'/'}¨r[;3]
r[;1]{0=:'' '[',,']'}¨r[;1]
r[;2]r[;2]{0 80 443: (¯1),':',(),'/'}¨r[;4]
:EndIf

Expand All @@ -2509,7 +2519,7 @@
:If 1=listGetListOfRegistriesForSelection type
registry1list[1;]
:Else
:If row'Select Tatin Registry'all TC.C.Select⎕FMT list[;2 1]
:If row'Select Tatin Registry'all TC.C.Select⎕FMT list[;1 2]
registry
:Else
:If all
Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Cleanup.aplf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Cleanup;F;folder;configFolder;rc;msg;res
##.Client.⎕EX'∆PrintToSession'
##.Admin.⎕EX¨'∆DIRS' '∆FILES'
##.Admin.⎕EX¨'∆DIRS' '∆FILES' 'RI'
⎕SE._Tatin.Client.⎕EX'∆PrintToSession'
F##.FilesAndDirs
folder(7390),'/TatinTests/'
Expand Down
1 change: 1 addition & 0 deletions APLSource/TestCases/Initial.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#.⎕EX'_tatin'
r1

RI##.Client.RegistryIndices
Managed Registry:
∆TEMP_SERVER_FOLDERF.GetTempSubDir'Tatin-Test-Server'
(∆TEMP_SERVER_FOLDER,'/')⎕NCOPY1#.Tatin.CiderConfig.HOME,'/TestServer/*'
Expand Down
Loading

0 comments on commit 604b2e7

Please sign in to comment.