Skip to content

Commit 19df363

Browse files
Added support for changing config via API
closes #268, closes #698 Signed-off-by: Petu Eusebiu <[email protected]>
1 parent 74630ed commit 19df363

26 files changed

+1543
-887
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TESTDATA := $(TOP_LEVEL)/test/data
1919
OS ?= linux
2020
ARCH ?= amd64
2121
BENCH_OUTPUT ?= stdout
22-
EXTENSIONS ?= sync,search,scrub,metrics,ui_base,lint
22+
EXTENSIONS ?= sync,search,scrub,metrics,ui_base,lint,config
2323
comma:= ,
2424
hyphen:= -
2525
extended-name:=

examples/config-allextensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"level": "debug"
1212
},
1313
"extensions": {
14+
"sysconfig": {
15+
"enable": true
16+
},
1417
"metrics": {},
1518
"sync": {
1619
"credentialsFile": "./examples/sync-auth-filepath.json",

examples/config-anonymous-authz.json

+24-22
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,30 @@
88
"port": "8080",
99
"realm": "zot",
1010
"accessControl": {
11-
"**": {
12-
"anonymousPolicy": [
13-
"read",
14-
"create"
15-
]
16-
},
17-
"tmp/**": {
18-
"anonymousPolicy": [
19-
"read",
20-
"create",
21-
"update"
22-
]
23-
},
24-
"infra/**": {
25-
"anonymousPolicy": [
26-
"read"
27-
]
28-
},
29-
"repos2/repo": {
30-
"anonymousPolicy": [
31-
"read"
32-
]
11+
"repositories": {
12+
"**": {
13+
"anonymousPolicy": [
14+
"read",
15+
"create"
16+
]
17+
},
18+
"tmp/**": {
19+
"anonymousPolicy": [
20+
"read",
21+
"create",
22+
"update"
23+
]
24+
},
25+
"infra/**": {
26+
"anonymousPolicy": [
27+
"read"
28+
]
29+
},
30+
"repos2/repo": {
31+
"anonymousPolicy": [
32+
"read"
33+
]
34+
}
3335
}
3436
}
3537
},

examples/config-cfg-extension.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"distSpecVersion": "1.0.1-dev",
3+
"http": {
4+
"address": "127.0.0.1",
5+
"port": "8080",
6+
"readonly": false
7+
},
8+
"log": {
9+
"level": "debug"
10+
},
11+
"storage": {
12+
"rootdirectory": "/tmp/zot"
13+
},
14+
"extensions": {
15+
"sysconfig": {
16+
"enable": true
17+
}
18+
}
19+
}

examples/config-policy.json

+130-113
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,130 @@
1-
{
2-
"distSpecVersion": "1.0.1-dev",
3-
"storage": {
4-
"rootDirectory": "/tmp/zot"
5-
},
6-
"http": {
7-
"address": "127.0.0.1",
8-
"port": "8080",
9-
"realm": "zot",
10-
"auth": {
11-
"htpasswd": {
12-
"path": "test/data/htpasswd"
13-
},
14-
"failDelay": 1
15-
},
16-
"accessControl": {
17-
"**": {
18-
"anonymousPolicy": ["read"],
19-
"policies": [
20-
{
21-
"users": [
22-
"charlie"
23-
],
24-
"actions": [
25-
"read",
26-
"create",
27-
"update"
28-
]
29-
}
30-
],
31-
"defaultPolicy": [
32-
"read",
33-
"create"
34-
]
35-
},
36-
"tmp/**": {
37-
"defaultPolicy": [
38-
"read",
39-
"create",
40-
"update"
41-
]
42-
},
43-
"infra/**": {
44-
"policies": [
45-
{
46-
"users": [
47-
"alice",
48-
"bob"
49-
],
50-
"actions": [
51-
"create",
52-
"read",
53-
"update",
54-
"delete"
55-
]
56-
},
57-
{
58-
"users": [
59-
"mallory"
60-
],
61-
"actions": [
62-
"create",
63-
"read"
64-
]
65-
}
66-
],
67-
"defaultPolicy": [
68-
"read"
69-
]
70-
},
71-
"repos2/repo": {
72-
"policies": [
73-
{
74-
"users": [
75-
"charlie"
76-
],
77-
"actions": [
78-
"read",
79-
"create"
80-
]
81-
},
82-
{
83-
"users": [
84-
"mallory"
85-
],
86-
"actions": [
87-
"create",
88-
"read"
89-
]
90-
}
91-
],
92-
"defaultPolicy": [
93-
"read"
94-
]
95-
},
96-
"adminPolicy": {
97-
"users": [
98-
"admin"
99-
],
100-
"actions": [
101-
"read",
102-
"create",
103-
"update",
104-
"delete"
105-
]
106-
}
107-
}
108-
},
109-
"log": {
110-
"level": "debug",
111-
"output": "/tmp/zot.log"
112-
}
113-
}
1+
{
2+
"distspecversion": "1.0.1-dev",
3+
"extensions": {
4+
"sysconfig": {
5+
"enable": true
6+
}
7+
},
8+
"http": {
9+
"accesscontrol": {
10+
"adminpolicy": {
11+
"actions": [
12+
"read",
13+
"create",
14+
"update",
15+
"delete"
16+
],
17+
"users": [
18+
"admin"
19+
]
20+
},
21+
"repositories": {
22+
"**": {
23+
"defaultpolicy": [
24+
"read",
25+
"create"
26+
],
27+
"policies": [
28+
{
29+
"actions": [
30+
"read"
31+
],
32+
"users": [
33+
"meli",
34+
"sebi"
35+
]
36+
}
37+
]
38+
},
39+
"infra/**": {
40+
"defaultpolicy": [
41+
"read"
42+
],
43+
"policies": [
44+
{
45+
"actions": [
46+
"create",
47+
"read",
48+
"update",
49+
"delete"
50+
],
51+
"users": [
52+
"alice",
53+
"bob"
54+
]
55+
},
56+
{
57+
"actions": [
58+
"create",
59+
"read"
60+
],
61+
"users": [
62+
"mallory"
63+
]
64+
}
65+
]
66+
},
67+
"newrepo": {
68+
"policies": [
69+
{
70+
"actions": [
71+
"read"
72+
],
73+
"users": [
74+
"meli",
75+
"sebi"
76+
]
77+
}
78+
]
79+
},
80+
"repos2/repo": {
81+
"defaultpolicy": [
82+
"read"
83+
],
84+
"policies": [
85+
{
86+
"actions": [
87+
"read",
88+
"create"
89+
],
90+
"users": [
91+
"charlie"
92+
]
93+
},
94+
{
95+
"actions": [
96+
"create",
97+
"read"
98+
],
99+
"users": [
100+
"mallory"
101+
]
102+
}
103+
]
104+
},
105+
"tmp/**": {
106+
"defaultpolicy": [
107+
"read",
108+
"create",
109+
"update"
110+
]
111+
}
112+
}
113+
},
114+
"address": "127.0.0.1",
115+
"auth": {
116+
"faildelay": 1,
117+
"htpasswd": {
118+
"path": "/home/peusebiu/htpasswd"
119+
}
120+
},
121+
"port": "8080",
122+
"realm": "zot"
123+
},
124+
"log": {
125+
"level": "debug"
126+
},
127+
"storage": {
128+
"rootdirectory": "/tmp/zot"
129+
}
130+
}

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ require (
2323
github.com/gofrs/uuid v4.2.0+incompatible
2424
github.com/google/go-containerregistry v0.11.0
2525
github.com/google/uuid v1.3.0
26-
github.com/gorilla/handlers v1.5.1
2726
github.com/gorilla/mux v1.8.0
2827
github.com/json-iterator/go v1.1.12
2928
github.com/minio/sha256-simd v1.0.0
@@ -57,6 +56,7 @@ require (
5756
require github.com/open-policy-agent/opa v0.43.0 // indirect
5857

5958
require (
59+
github.com/go-openapi/runtime v0.24.1
6060
github.com/opencontainers/distribution-spec/specs-go v0.0.0-20220217185014-dd38b7ed8a99
6161
github.com/sigstore/cosign v1.10.1
6262
github.com/swaggo/http-swagger v1.3.3
@@ -163,7 +163,6 @@ require (
163163
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 // indirect
164164
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
165165
github.com/fatih/color v1.13.0 // indirect
166-
github.com/felixge/httpsnoop v1.0.2 // indirect
167166
github.com/fullstorydev/grpcurl v1.8.6 // indirect
168167
github.com/ghodss/yaml v1.0.0 // indirect
169168
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
@@ -177,7 +176,6 @@ require (
177176
github.com/go-openapi/jsonpointer v0.19.5 // indirect
178177
github.com/go-openapi/jsonreference v0.20.0 // indirect
179178
github.com/go-openapi/loads v0.21.1 // indirect
180-
github.com/go-openapi/runtime v0.24.1 // indirect
181179
github.com/go-openapi/spec v0.20.6 // indirect
182180
github.com/go-openapi/strfmt v0.21.3 // indirect
183181
github.com/go-openapi/swag v0.21.1 // indirect

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,6 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
922922
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
923923
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
924924
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
925-
github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o=
926925
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
927926
github.com/flynn/go-docopt v0.0.0-20140912013429-f6dd2ebbb31e/go.mod h1:HyVoz1Mz5Co8TFO8EupIdlcpwShBmY98dkT2xeHkvEI=
928927
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
@@ -1445,7 +1444,6 @@ github.com/goreleaser/nfpm v1.2.1/go.mod h1:TtWrABZozuLOttX2uDlYyECfQX7x5XYkVxhj
14451444
github.com/goreleaser/nfpm v1.3.0/go.mod h1:w0p7Kc9TAUgWMyrub63ex3M2Mgw88M4GZXoTq5UCb40=
14461445
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
14471446
github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
1448-
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
14491447
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
14501448
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
14511449
github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=

0 commit comments

Comments
 (0)