Skip to content

Commit

Permalink
Merge branch 'intersystems-community:master' into permit-docker-repub…
Browse files Browse the repository at this point in the history
…lish
  • Loading branch information
isc-tleavitt authored Mar 21, 2024
2 parents 359dd1a + 052591b commit cf17345
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/trigger-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ on:
jobs:
trigger-zpm-deployment:
name: Trigger zpm-registry-deployment via REST API
runs-on: ubuntu-latest

runs-on: ubuntu-22.04
steps:
- name: REST POST call
run: |-
Expand Down
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# intersystems zpm-registry
[![Quality Gate Status](https://community.objectscriptquality.com/api/project_badges/measure?project=intersystems_iris_community%2Fzpm-registry&metric=alert_status)](https://community.objectscriptquality.com/dashboard?id=intersystems_iris_community%2Fzpm-registry)
[![Quality Gate Status](https://community.objectscriptquality.com/api/project_badges/measure?project=intersystems_iris_community%2Fzpm-registry&metric=alert_status)](https://community.objectscriptquality.com/dashboard?id=intersystems_iris_community%2Fzpm-registry)

ZPM Registry is a a server part of ObjectScript Package Manager.

Expand All @@ -13,26 +13,59 @@ You can use ZPM Registry project to build your own private registry to have the
ZPM Registry works only on IRIS and IRIS For Health, community and Enterprise versions.

# Installation
## Usual Installation
Import classes from cls and run Installer from Root

## ZPM Installation
`install zpm-registry`

## Docker Installation
Build docker container

## ZPM Installation
`install zpm-registry`
## Usual Installation
Import classes from cls and run Installer from Root

# Usage
ZPM Registry exposes REST API, which perfoms listing, publising and deployment services. You can examine the REST in the source class [Registry.cls](https://github.com/intersystems-community/zpm-registry/blob/master/src/cls/ZPM/Registry.cls) or via Swagger

Note, when you publish the repo via API you need to provide the GIthub URL of the repo, which will contain module.xml.
Note, when you publish the repo via API you need to provide the Github URL of the repo, which will contain module.xml.
And published package will remember the repository and will not allow to publish/update package with the same name but with another repository.


## Working With Your Registry From ZPM Client
You can setup ZPM client to work with your registry with the following command:
```
ZPM:USER>repo -n registry -r -url https://registry.yourdomain.com
zpm:USER>repo -n registry -r -url https://registry.yourdomain.com
```

## Settings
To configure the registry, utilize the zpm-registry.yaml file located within the IRIS installation folder. Retrieve the IRIS directory in which the file should reside using the following command: `write ##class(%SYSTEM.Util).InstallDirectory()`.


## Proxy-Registry
Starting from version 1.1.2, zpm-registry includes the Proxy feature.
This allows the IPM client to use only your private registry and install packages from your private registry, all the while retaining the capability to install packages from an external registry (Uplink).

External registries that your local registry can access are called Uplinks. You can define one or more external registries. You can also list which packages from the Uplink registry should be available.

These settings are set in the `zpm-registry.yaml` file.

Settings file example:
```
uplinks:
pm:
url: https://pm.community.intersystems.com/
allow_packages: dsw,zpm*,?u*
```

For more information, see https://community.intersystems.com/post/new-zpm-registry-feature-%E2%80%93-proxy-registry


## Delete packages
Starting from version 0.7, IPM introduces support for the "unpublish" command, which facilitates the removal of a package that was previously published.
In order for this command to be executed, it is necessary to explicitly allow the removal of packages on the side of the registry. To do this, add the line "delete-enabled: true" to the settings file `zpm-registry.yaml`

Settings file example:
```
delete-enabled: true
```


Expand Down
2 changes: 1 addition & 1 deletion module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Name>zpm-registry</Name>
<ExternalName>ZPM Registry</ExternalName>
<Description>Registry server for ZPM</Description>
<Version>1.2.5</Version>
<Version>1.2.7</Version>
<Packaging>module</Packaging>
<Dependencies>
<ModuleReference>
Expand Down
29 changes: 29 additions & 0 deletions src/cls/ZPM/Analytics/AbstractEventProcessor.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// To execute your code immediately after the event occurs,
/// you need to create a subclass of this class and override the Process() method in it.
Class ZPM.Analytics.AbstractEventProcessor [ Abstract ]
{

Parameter SubClasses As CONFIGVALUE;

/// Override this method to run your code when event occurs
ClassMethod Process(event as ZPM.Analytics.Event) As %Status [ Abstract ]
{
Return $$$OK
}

/// Do not change or override this method
ClassMethod getSubClasses() As %String [ CodeMode = objectgenerator ]
{
Set list = ""

Set rs = ##class(%Dictionary.ClassDefinitionQuery).SubclassOfFunc("ZPM.Analytics.AbstractEventProcessor")
While (rs.%Next()) {
Set list = list _ $listbuild( rs.%GetData(1) )
}

Do $system.OBJ.UpdateConfigParam("ZPM.Analytics.AbstractEventProcessor","SubClasses",$listtostring(list,","))
Do %code.WriteLine(" return $PARAMETER(""ZPM.Analytics.AbstractEventProcessor"",""SubClasses"") ")
Return $$$OK
}

}
23 changes: 18 additions & 5 deletions src/cls/ZPM/Analytics/Event.cls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Class ZPM.Analytics.Event Extends (%Persistent, %JSON.Adaptor)

Parameter DSTIME = "AUTO";

/// Server date and time, saving the data
/// Server date and time, saving the data
Property TS As %PosixTime(%JSONINCLUDE = "none") [ SqlComputeCode = {set {*}=##class(%Library.PosixTime).CurrentTimeStamp()}, SqlComputed, SqlComputeOnChange = %%INSERT ];

/// Event type: download, install, uninstall
Expand Down Expand Up @@ -40,6 +40,22 @@ Property Region As %String(%JSONINCLUDE = "none");

Property City As %String(%JSONINCLUDE = "none");

ClassMethod ExecuteEventProcessors(event As ZPM.Analytics.Event) As %Status
{
Set subclasses = $PARAMETER("ZPM.Analytics.AbstractEventProcessor","SubClasses")
Set list = $ListFromString(subclasses,",")
For i=1:1:$listlength(list){
Try {
$$$ThrowOnError($Classmethod($listget(list,i), "Process", event))
} Catch ex {
If (ex.Name '= "<CLASS DOES NOT EXIST>") {
Throw ex
}
}
}
return $$$OK
}

ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObject) As %Status
{
Try {
Expand All @@ -48,10 +64,7 @@ ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObj
Set event.IP = ip
Do event.%JSONImport(json)
$$$ThrowOnError(event.%Save())
If ##class(%Dictionary.CompiledClass).%ExistsId("ZPM.Analytics.IP") {
Do ##class(ZPM.Analytics.IP).SetGeo(event, ip)
}
$$$ThrowOnError(event.%Save())
$$$ThrowOnError(..ExecuteEventProcessors(event))
Return $$$OK
} Catch ex {
Do ex.Log()
Expand Down

0 comments on commit cf17345

Please sign in to comment.