Skip to content

Commit 50d3569

Browse files
authored
Merge pull request #122 from trydirect/dev
Dev
2 parents 6b3fa3f + b565c45 commit 50d3569

25 files changed

+1314
-68
lines changed

Cargo.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ serde_yaml = "0.9"
6565
lapin = { version = "2.3.1", features = ["serde_json"] }
6666
futures-lite = "2.2.0"
6767
clap = { version = "4.4.8", features = ["derive"] }
68+
clap_complete = "4"
69+
dialoguer = { version = "0.11", features = ["fuzzy-select"] }
6870
indicatif = "0.17"
6971
brotli = "3.4.0"
7072
serde_path_to_error = "0.1.14"

migrations/20251222160220_casbin_agent_rules.up.sql

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,29 @@
22

33
-- Create agent role group (inherits from group_anonymous for health checks)
44
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
5-
VALUES ('g', 'agent', 'group_anonymous', '', '', '', '');
5+
VALUES ('g', 'agent', 'group_anonymous', '', '', '', '')
6+
ON CONFLICT DO NOTHING;
67

78
-- Agent registration (anonymous, users, and admin can register agents)
89
-- This allows agents to bootstrap themselves during deployment
910
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
10-
VALUES ('p', 'group_anonymous', '/api/v1/agent/register', 'POST', '', '', '');
11+
VALUES ('p', 'group_anonymous', '/api/v1/agent/register', 'POST', '', '', '')
12+
ON CONFLICT DO NOTHING;
1113

1214
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
13-
VALUES ('p', 'group_user', '/api/v1/agent/register', 'POST', '', '', '');
15+
VALUES ('p', 'group_user', '/api/v1/agent/register', 'POST', '', '', '')
16+
ON CONFLICT DO NOTHING;
1417

1518
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
16-
VALUES ('p', 'group_admin', '/api/v1/agent/register', 'POST', '', '', '');
19+
VALUES ('p', 'group_admin', '/api/v1/agent/register', 'POST', '', '', '')
20+
ON CONFLICT DO NOTHING;
1721

1822
-- Agent long-poll for commands (only agents can do this)
1923
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
20-
VALUES ('p', 'agent', '/api/v1/agent/commands/wait/:deployment_hash', 'GET', '', '', '');
24+
VALUES ('p', 'agent', '/api/v1/agent/commands/wait/:deployment_hash', 'GET', '', '', '')
25+
ON CONFLICT DO NOTHING;
2126

2227
-- Agent report command results (only agents can do this)
2328
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
24-
VALUES ('p', 'agent', '/api/v1/agent/commands/report', 'POST', '', '', '');
29+
VALUES ('p', 'agent', '/api/v1/agent/commands/report', 'POST', '', '', '')
30+
ON CONFLICT DO NOTHING;

migrations/20251222163632_casbin_command_rules.up.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ VALUES
77
('p', 'group_user', '/api/v1/commands', 'POST', '', '', ''), -- Create command
88
('p', 'group_user', '/api/v1/commands/:deployment_hash', 'GET', '', '', ''), -- List commands for deployment
99
('p', 'group_user', '/api/v1/commands/:deployment_hash/:command_id', 'GET', '', '', ''), -- Get specific command
10-
('p', 'group_user', '/api/v1/commands/:deployment_hash/:command_id/cancel', 'POST', '', '', ''); -- Cancel command
10+
('p', 'group_user', '/api/v1/commands/:deployment_hash/:command_id/cancel', 'POST', '', '', '') -- Cancel command
11+
ON CONFLICT DO NOTHING;
1112

1213
-- Admin permissions: inherit all user permissions + full access
1314
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
1415
VALUES
1516
('p', 'group_admin', '/api/v1/commands', 'POST', '', '', ''),
1617
('p', 'group_admin', '/api/v1/commands/:deployment_hash', 'GET', '', '', ''),
1718
('p', 'group_admin', '/api/v1/commands/:deployment_hash/:command_id', 'GET', '', '', ''),
18-
('p', 'group_admin', '/api/v1/commands/:deployment_hash/:command_id/cancel', 'POST', '', '', '');
19+
('p', 'group_admin', '/api/v1/commands/:deployment_hash/:command_id/cancel', 'POST', '', '', '')
20+
ON CONFLICT DO NOTHING;
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
-- Casbin rules for Marketplace endpoints
22

33
-- Public read rules
4-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_anonymous', '/api/templates', 'GET', '', '', '');
5-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_anonymous', '/api/templates/:slug', 'GET', '', '', '');
4+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_anonymous', '/api/templates', 'GET', '', '', '') ON CONFLICT DO NOTHING;
5+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_anonymous', '/api/templates/:slug', 'GET', '', '', '') ON CONFLICT DO NOTHING;
66

77
-- Creator rules
8-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates', 'POST', '', '', '');
9-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates/:id', 'PUT', '', '', '');
10-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates/:id/submit', 'POST', '', '', '');
11-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates/mine', 'GET', '', '', '');
8+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates', 'POST', '', '', '') ON CONFLICT DO NOTHING;
9+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates/:id', 'PUT', '', '', '') ON CONFLICT DO NOTHING;
10+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates/:id/submit', 'POST', '', '', '') ON CONFLICT DO NOTHING;
11+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/templates/mine', 'GET', '', '', '') ON CONFLICT DO NOTHING;
1212

1313
-- Admin moderation rules
14-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/admin/templates', 'GET', '', '', '');
15-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/admin/templates/:id/approve', 'POST', '', '', '');
16-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/admin/templates/:id/reject', 'POST', '', '', '');
14+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/admin/templates', 'GET', '', '', '') ON CONFLICT DO NOTHING;
15+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/admin/templates/:id/approve', 'POST', '', '', '') ON CONFLICT DO NOTHING;
16+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/admin/templates/:id/reject', 'POST', '', '', '') ON CONFLICT DO NOTHING;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
-- Casbin rule for admin marketplace plans endpoint
22
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
3-
VALUES ('p', 'group_admin', '/admin/marketplace/plans', 'GET', '', '', '');
3+
VALUES ('p', 'group_admin', '/admin/marketplace/plans', 'GET', '', '', '')
4+
ON CONFLICT DO NOTHING;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Casbin rules for Categories endpoint
22
-- Categories are publicly readable for marketplace UI population
33

4-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_anonymous', '/api/categories', 'GET', '', '', '');
5-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/categories', 'GET', '', '', '');
6-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/categories', 'GET', '', '', '');
4+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_anonymous', '/api/categories', 'GET', '', '', '') ON CONFLICT DO NOTHING;
5+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_user', '/api/categories', 'GET', '', '', '') ON CONFLICT DO NOTHING;
6+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/categories', 'GET', '', '', '') ON CONFLICT DO NOTHING;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Allow admin service accounts (e.g., root) to call marketplace creator endpoints
22
-- Admins previously lacked creator privileges which caused 403 responses
3-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates', 'POST', '', '', '');
4-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates/:id', 'PUT', '', '', '');
5-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates/:id/submit', 'POST', '', '', '');
6-
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates/mine', 'GET', '', '', '');
3+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates', 'POST', '', '', '') ON CONFLICT DO NOTHING;
4+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates/:id', 'PUT', '', '', '') ON CONFLICT DO NOTHING;
5+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates/:id/submit', 'POST', '', '', '') ON CONFLICT DO NOTHING;
6+
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5) VALUES ('p', 'group_admin', '/api/templates/mine', 'GET', '', '', '') ON CONFLICT DO NOTHING;
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
2-
VALUES ('p', 'group_user', '/dockerhub/namespaces', 'GET', '', '', '');
2+
VALUES ('p', 'group_user', '/dockerhub/namespaces', 'GET', '', '', '')
3+
ON CONFLICT DO NOTHING;
34

45
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
5-
VALUES ('p', 'group_admin', '/dockerhub/namespaces', 'GET', '', '', '');
6+
VALUES ('p', 'group_admin', '/dockerhub/namespaces', 'GET', '', '', '')
7+
ON CONFLICT DO NOTHING;
68

79
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
8-
VALUES ('p', 'group_user', '/dockerhub/:namespace/repositories', 'GET', '', '', '');
10+
VALUES ('p', 'group_user', '/dockerhub/:namespace/repositories', 'GET', '', '', '')
11+
ON CONFLICT DO NOTHING;
912

1013
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
11-
VALUES ('p', 'group_admin', '/dockerhub/:namespace/repositories', 'GET', '', '', '');
14+
VALUES ('p', 'group_admin', '/dockerhub/:namespace/repositories', 'GET', '', '', '')
15+
ON CONFLICT DO NOTHING;
1216

1317
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
14-
VALUES ('p', 'group_user', '/dockerhub/:namespace/repositories/:repository/tags', 'GET', '', '', '');
18+
VALUES ('p', 'group_user', '/dockerhub/:namespace/repositories/:repository/tags', 'GET', '', '', '')
19+
ON CONFLICT DO NOTHING;
1520

1621
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
17-
VALUES ('p', 'group_admin', '/dockerhub/:namespace/repositories/:repository/tags', 'GET', '', '', '');
22+
VALUES ('p', 'group_admin', '/dockerhub/:namespace/repositories/:repository/tags', 'GET', '', '', '')
23+
ON CONFLICT DO NOTHING;
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
2-
VALUES ('p', 'group_user', '/api/v1/deployments/:deployment_hash/capabilities', 'GET', '', '', '');
2+
VALUES ('p', 'group_user', '/api/v1/deployments/:deployment_hash/capabilities', 'GET', '', '', '')
3+
ON CONFLICT DO NOTHING;
34

45
INSERT INTO public.casbin_rule (ptype, v0, v1, v2, v3, v4, v5)
5-
VALUES ('p', 'group_admin', '/api/v1/deployments/:deployment_hash/capabilities', 'GET', '', '', '');
6+
VALUES ('p', 'group_admin', '/api/v1/deployments/:deployment_hash/capabilities', 'GET', '', '', '')
7+
ON CONFLICT DO NOTHING;

0 commit comments

Comments
 (0)