Skip to content

Commit 05e8051

Browse files
feat: jh registry registrator get and update (#29)
* registry add, update and config commands * updated add update help section * registry list cmd in one line, changed add and update to config add and update * updated print messages for add and update registry * added registry permission list, set and delete commands * separate commands for admin user and group list and public user and group list * updated helptext * jh registry registrator config * removed unwanted files * resolved conflucts * formatting
1 parent bb00e3a commit 05e8051

2 files changed

Lines changed: 91 additions & 4 deletions

File tree

CLAUDE.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The application follows a command-line interface pattern using the Cobra library
1313
- **main.go**: Core CLI structure with command definitions and configuration management
1414
- **auth.go**: OAuth2 device flow authentication with JWT token handling
1515
- **datasets.go**: Dataset operations (list, download, upload, status) with REST API integration
16-
- **registries.go**: Registry operations (list, config, add, update) with REST API integration
16+
- **registries.go**: Registry operations (list, config, add, update, registrator) with REST API integration
1717
- **packages.go**: Package operations (search, dependency) with REST API primary path (`/packages/info`), GraphQL fallback, and documentation API (`/docs/{registry}/{package}/stable/pkg.json`)
1818
- **projects.go**: Project management using GraphQL API with user filtering
1919
- **user.go**: User information retrieval using GraphQL API and REST API for listing users
@@ -45,12 +45,16 @@ The application follows a command-line interface pattern using the Cobra library
4545
- `jh dataset`: Dataset operations (list, download, upload, status)
4646
- `jh registry`: Registry operations (list, config — all via REST API)
4747
- `jh registry config`: Show registry JSON config by name; subcommands add/update accept JSON via stdin or `--file`
48+
- `jh registry permission`: Registry permission management (list, set, remove)
49+
- `jh registry registrator`: Show registrator config by name; subcommand update accepts JSON via stdin or `--file`
4850
- `jh package`: Package search and dependency (REST primary via `/packages/info`, GraphQL fallback; dependency data from `/docs/{registry}/{package}/stable/pkg.json`)
4951
- `jh project`: Project management (list with GraphQL, supports user filtering)
50-
- `jh user`: User information (info with GraphQL)
51-
- `jh admin`: Administrative commands (user management, token management, credential management, landing page)
52+
- `jh user`: User information (info, list via GraphQL `public_users`)
53+
- `jh group`: Group information (list via GraphQL)
54+
- `jh admin`: Administrative commands (user management, token management, group management, credential management, landing page)
5255
- `jh admin user`: User management (list all users with REST API, supports verbose mode)
5356
- `jh admin token`: Token management (list all tokens with REST API, supports verbose mode)
57+
- `jh admin group`: Group management (list all groups via REST API)
5458
- `jh admin credential`: Registry credential management (list, add, update, delete via REST API)
5559
- `jh admin credential list`: List all registry credentials (tokens, SSH keys, GitHub Apps); supports verbose mode
5660
- `jh admin credential add`: Add a credential — subcommands: `token`, `ssh`, `github-app`; accepts JSON argument or stdin
@@ -143,6 +147,24 @@ go run . registry config add --file registry.json
143147

144148
# Update an existing registry (same JSON schema, same flags)
145149
go run . registry config update --file registry.json
150+
151+
# Show registrator config for a registry
152+
go run . registry registrator MyRegistry
153+
154+
# Update registrator config (JSON via stdin or --file)
155+
echo '{
156+
"enabled": true,
157+
"email": "pkg@example.com",
158+
"authorization": true,
159+
"ssl_verify": true,
160+
"registry_fork_url": null,
161+
"registry_deps": ["General"]
162+
}' | go run . registry registrator update MyRegistry
163+
go run . registry registrator update MyRegistry --file registrator.json
164+
165+
# Get, edit, push back
166+
go run . registry registrator MyRegistry > registrator.json
167+
go run . registry registrator update MyRegistry --file registrator.json
146168
```
147169

148170
### Test project and user operations
@@ -444,6 +466,10 @@ jh run setup
444466
- Registry add/update commands (`jh registry config add` / `jh registry config update`) use REST API endpoint `/api/v1/registry/config/registry/{name}` (POST); the backend creates or updates based on whether the registry already exists
445467
- Both commands accept the full registry JSON payload via `--file <path>` or stdin; the payload `name` field identifies the registry
446468
- Registry add/update always poll `/api/v1/registry/config/registry/{name}/savestatus` every 3 seconds up to a 2-minute timeout
469+
- Registry registrator command (`jh registry registrator <name>`) uses REST API endpoint `/api/v1/registry/config/registrator/{name}` (GET) and prints the full JSON response
470+
- Registry registrator update command (`jh registry registrator update <name>`) uses REST API endpoint `/api/v1/registry/config/registrator/{name}` (POST); the registry name comes from the positional argument (`RegistratorInfo` has no `name` field)
471+
- Registrator update validates that `"email"` is non-empty when `"enabled"` is true
472+
- GET returns 404 "Registry not found" when no registrator has been configured for that registry yet
447473
- Bundle provider type automatically sets `license_detect: false` in the payload
448474
- Admin token list command (`jh admin token list`) uses REST API endpoint `/app/token/activelist` which requires appropriate permissions
449475
- Token list output is concise by default (Subject, Created By, and Expired status only); use `--verbose` flag for detailed information (signature, creation date, expiration date with estimate indicator)
@@ -498,6 +524,12 @@ jh run setup
498524
- `submitRegistry` POSTs to `/api/v1/registry/config/registry/{name}` with retry on 500s, then calls `pollRegistrySaveStatus()`
499525
- `pollRegistrySaveStatus` GETs `/api/v1/registry/config/registry/{name}/savestatus` every 3 seconds up to a 2-minute deadline
500526

527+
**`jh registry registrator <name>` / `jh registry registrator update`:**
528+
529+
- `getRegistrator` uses `apiGet` to GET `/api/v1/registry/config/registrator/{name}` and pretty-prints the JSON response
530+
- `setRegistrator(server, name, filePath)` reads `RegistratorInfo` JSON from `--file` or stdin, validates `"email"` is set when `"enabled"` is true, then POSTs to `/api/v1/registry/config/registrator/{name}`
531+
- No polling — the POST response is the final result
532+
501533
### Julia Credentials Management (`run.go`)
502534

503535
The Julia credentials system consists of three main functions:

main.go

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,57 @@ Exactly one of --user or --group must be provided.`,
12191219
},
12201220
}
12211221

1222+
var registryRegistratorCmd = &cobra.Command{
1223+
Use: "registrator <name>",
1224+
Short: "Show the registrator configuration for a registry",
1225+
Example: " jh registry registrator MyRegistry\n jh registry registrator MyRegistry -s nightly.juliahub.dev",
1226+
Args: cobra.ExactArgs(1),
1227+
Run: func(cmd *cobra.Command, args []string) {
1228+
server, err := getServerFromFlagOrConfig(cmd)
1229+
if err != nil {
1230+
fmt.Printf("Failed to get server config: %v\n", err)
1231+
os.Exit(1)
1232+
}
1233+
if err := getRegistrator(server, args[0]); err != nil {
1234+
fmt.Printf("Failed to get registrator config: %v\n", err)
1235+
os.Exit(1)
1236+
}
1237+
},
1238+
}
1239+
1240+
var registryRegistratorUpdateCmd = &cobra.Command{
1241+
Use: "update <registry>",
1242+
Short: "Update the registrator configuration for a registry",
1243+
Long: `Update the registrator configuration for a Julia package registry.
1244+
1245+
Reads the registrator configuration from a JSON file (--file) or stdin.
1246+
1247+
REGISTRATOR JSON SCHEMA
1248+
1249+
{
1250+
"enabled": true, // enable/disable registrator
1251+
"email": "<email>", // required when enabled
1252+
"authorization": true, // allow only package authors to register
1253+
"ssl_verify": true, // verify SSL certificates
1254+
"registry_fork_url": "<url>", // URL to a forked registry with write access (optional, null to unset)
1255+
"registry_deps": ["<registry>", ...] // registries whose packages may be dependencies
1256+
}`,
1257+
Example: " jh registry registrator update MyRegistry --file registrator.json\n jh registry registrator MyRegistry | jh registry registrator update MyRegistry",
1258+
Args: cobra.ExactArgs(1),
1259+
Run: func(cmd *cobra.Command, args []string) {
1260+
server, err := getServerFromFlagOrConfig(cmd)
1261+
if err != nil {
1262+
fmt.Printf("Failed to get server config: %v\n", err)
1263+
os.Exit(1)
1264+
}
1265+
filePath, _ := cmd.Flags().GetString("file")
1266+
if err := setRegistrator(server, args[0], filePath); err != nil {
1267+
fmt.Printf("Failed to update registrator config: %v\n", err)
1268+
os.Exit(1)
1269+
}
1270+
},
1271+
}
1272+
12221273
var projectCmd = &cobra.Command{
12231274
Use: "project",
12241275
Short: "Project management commands",
@@ -2297,7 +2348,11 @@ func init() {
22972348
registryPermissionRemoveCmd.Flags().String("user", "", "Username to remove permission for")
22982349
registryPermissionRemoveCmd.Flags().String("group", "", "Group name to remove permission for")
22992350
registryPermissionCmd.AddCommand(registryPermissionListCmd, registryPermissionSetCmd, registryPermissionRemoveCmd)
2300-
registryCmd.AddCommand(registryListCmd, registryConfigCmd, registryPermissionCmd)
2351+
registryRegistratorCmd.Flags().StringP("server", "s", "", "JuliaHub server")
2352+
registryRegistratorUpdateCmd.Flags().StringP("server", "s", "", "JuliaHub server")
2353+
registryRegistratorUpdateCmd.Flags().StringP("file", "f", "", "Path to JSON config file (reads from stdin if omitted)")
2354+
registryRegistratorCmd.AddCommand(registryRegistratorUpdateCmd)
2355+
registryCmd.AddCommand(registryListCmd, registryConfigCmd, registryPermissionCmd, registryRegistratorCmd)
23012356
projectCmd.AddCommand(projectListCmd)
23022357
userListGQLCmd.Flags().StringP("server", "s", "juliahub.com", "JuliaHub server")
23032358
userCmd.AddCommand(userInfoCmd, userListGQLCmd)

0 commit comments

Comments
 (0)