Skip to content

Commit

Permalink
Merge pull request #675 from haoming29/registry-api-p5
Browse files Browse the repository at this point in the history
Add support for custom registration fields for registry
  • Loading branch information
turetske authored Jan 31, 2024
2 parents d28dd4e + 50cda8c commit 5aabf49
Show file tree
Hide file tree
Showing 14 changed files with 605 additions and 52 deletions.
51 changes: 51 additions & 0 deletions docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,57 @@ type: object
default: none
components: ["registry"]
---
name: Registry.CustomRegistrationFields
description: >-
An array of objects specifying **additional** fields when registering namespaces.
The schema of the object is as follows:
```
- name: department
type: enum
required: true
options:
- name: Math
id: math
- name: Computer Science
id: cs
optionsUrl: https://example.com/options
validationUrl: https://example.com/validate
description: The department of the organization that holds this namespace
```
Note the following requirements:
- "name" must be snake case with underline connecting words, i.e. site_name.
- "type" must be one of "string", "int", "bool", "datetime" (Unix time in seconds), or "enum".
- "options" must be a non-empty yaml array for field with type "enum". "optionsUrl" will be ignored if "options" is set.
example:
```yaml
options:
- name: "Option A"
id: "optionA"
```
- "optionsUrl" is alternative to options with a URL return an JSON array of options in the following format:
```json
[
{
"name":"Option A",
"id":"optionA"
}
]
```
- "validationUrl" is an optional, user-provided validation endpoint
that listens to a POST request with JSON body of {"field": "<field value>"}
and responds with a 200 code and JSON of {"valid": bool, "message": ""}. If it's non-empty,
for all create and update of namespace registration, this URL will be called
to validate the custom field. If "valid" == "false", the "message" will be returned by Pelican
- "description" will show up in the web UI as helper text to help user understand the field
type: object
default: none
components: ["nsregistry"]
---
name: Registry.InstitutionsUrl
description: >-
A url to get a list of available institutions for users to register their namespaces to.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ require (
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sync v0.3.0
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/text v0.14.0
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.11.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
5 changes: 5 additions & 0 deletions launchers/registry_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func RegistryServe(ctx context.Context, engine *gin.Engine, egrp *errgroup.Group
return errors.Wrap(err, "Unable to initialize the namespace registry database")
}

err = registry.InitCustomRegistrationFields()
if err != nil {
return err
}

if config.GetPreferredPrefix() == "OSDF" {
metrics.SetComponentHealthStatus(metrics.DirectorRegistry_Topology, metrics.StatusWarning, "Start requesting from topology, status unknown")
log.Info("Populating registry with namespaces from OSG topology service...")
Expand Down
1 change: 1 addition & 0 deletions param/parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions param/parameters_struct.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5aabf49

Please sign in to comment.