Skip to content

Commit

Permalink
Added support for changing config via API
Browse files Browse the repository at this point in the history
closes #268, closes #698

Signed-off-by: Petu Eusebiu <[email protected]>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Aug 19, 2022
1 parent 74630ed commit 19df363
Show file tree
Hide file tree
Showing 26 changed files with 1,543 additions and 887 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TESTDATA := $(TOP_LEVEL)/test/data
OS ?= linux
ARCH ?= amd64
BENCH_OUTPUT ?= stdout
EXTENSIONS ?= sync,search,scrub,metrics,ui_base,lint
EXTENSIONS ?= sync,search,scrub,metrics,ui_base,lint,config
comma:= ,
hyphen:= -
extended-name:=
Expand Down
3 changes: 3 additions & 0 deletions examples/config-allextensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"level": "debug"
},
"extensions": {
"sysconfig": {
"enable": true
},
"metrics": {},
"sync": {
"credentialsFile": "./examples/sync-auth-filepath.json",
Expand Down
46 changes: 24 additions & 22 deletions examples/config-anonymous-authz.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@
"port": "8080",
"realm": "zot",
"accessControl": {
"**": {
"anonymousPolicy": [
"read",
"create"
]
},
"tmp/**": {
"anonymousPolicy": [
"read",
"create",
"update"
]
},
"infra/**": {
"anonymousPolicy": [
"read"
]
},
"repos2/repo": {
"anonymousPolicy": [
"read"
]
"repositories": {
"**": {
"anonymousPolicy": [
"read",
"create"
]
},
"tmp/**": {
"anonymousPolicy": [
"read",
"create",
"update"
]
},
"infra/**": {
"anonymousPolicy": [
"read"
]
},
"repos2/repo": {
"anonymousPolicy": [
"read"
]
}
}
}
},
Expand Down
19 changes: 19 additions & 0 deletions examples/config-cfg-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"distSpecVersion": "1.0.1-dev",
"http": {
"address": "127.0.0.1",
"port": "8080",
"readonly": false
},
"log": {
"level": "debug"
},
"storage": {
"rootdirectory": "/tmp/zot"
},
"extensions": {
"sysconfig": {
"enable": true
}
}
}
243 changes: 130 additions & 113 deletions examples/config-policy.json
Original file line number Diff line number Diff line change
@@ -1,113 +1,130 @@
{
"distSpecVersion": "1.0.1-dev",
"storage": {
"rootDirectory": "/tmp/zot"
},
"http": {
"address": "127.0.0.1",
"port": "8080",
"realm": "zot",
"auth": {
"htpasswd": {
"path": "test/data/htpasswd"
},
"failDelay": 1
},
"accessControl": {
"**": {
"anonymousPolicy": ["read"],
"policies": [
{
"users": [
"charlie"
],
"actions": [
"read",
"create",
"update"
]
}
],
"defaultPolicy": [
"read",
"create"
]
},
"tmp/**": {
"defaultPolicy": [
"read",
"create",
"update"
]
},
"infra/**": {
"policies": [
{
"users": [
"alice",
"bob"
],
"actions": [
"create",
"read",
"update",
"delete"
]
},
{
"users": [
"mallory"
],
"actions": [
"create",
"read"
]
}
],
"defaultPolicy": [
"read"
]
},
"repos2/repo": {
"policies": [
{
"users": [
"charlie"
],
"actions": [
"read",
"create"
]
},
{
"users": [
"mallory"
],
"actions": [
"create",
"read"
]
}
],
"defaultPolicy": [
"read"
]
},
"adminPolicy": {
"users": [
"admin"
],
"actions": [
"read",
"create",
"update",
"delete"
]
}
}
},
"log": {
"level": "debug",
"output": "/tmp/zot.log"
}
}
{
"distspecversion": "1.0.1-dev",
"extensions": {
"sysconfig": {
"enable": true
}
},
"http": {
"accesscontrol": {
"adminpolicy": {
"actions": [
"read",
"create",
"update",
"delete"
],
"users": [
"admin"
]
},
"repositories": {
"**": {
"defaultpolicy": [
"read",
"create"
],
"policies": [
{
"actions": [
"read"
],
"users": [
"meli",
"sebi"
]
}
]
},
"infra/**": {
"defaultpolicy": [
"read"
],
"policies": [
{
"actions": [
"create",
"read",
"update",
"delete"
],
"users": [
"alice",
"bob"
]
},
{
"actions": [
"create",
"read"
],
"users": [
"mallory"
]
}
]
},
"newrepo": {
"policies": [
{
"actions": [
"read"
],
"users": [
"meli",
"sebi"
]
}
]
},
"repos2/repo": {
"defaultpolicy": [
"read"
],
"policies": [
{
"actions": [
"read",
"create"
],
"users": [
"charlie"
]
},
{
"actions": [
"create",
"read"
],
"users": [
"mallory"
]
}
]
},
"tmp/**": {
"defaultpolicy": [
"read",
"create",
"update"
]
}
}
},
"address": "127.0.0.1",
"auth": {
"faildelay": 1,
"htpasswd": {
"path": "/home/peusebiu/htpasswd"
}
},
"port": "8080",
"realm": "zot"
},
"log": {
"level": "debug"
},
"storage": {
"rootdirectory": "/tmp/zot"
}
}
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ require (
github.com/gofrs/uuid v4.2.0+incompatible
github.com/google/go-containerregistry v0.11.0
github.com/google/uuid v1.3.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/json-iterator/go v1.1.12
github.com/minio/sha256-simd v1.0.0
Expand Down Expand Up @@ -57,6 +56,7 @@ require (
require github.com/open-policy-agent/opa v0.43.0 // indirect

require (
github.com/go-openapi/runtime v0.24.1
github.com/opencontainers/distribution-spec/specs-go v0.0.0-20220217185014-dd38b7ed8a99
github.com/sigstore/cosign v1.10.1
github.com/swaggo/http-swagger v1.3.3
Expand Down Expand Up @@ -163,7 +163,6 @@ require (
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fullstorydev/grpcurl v1.8.6 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
Expand All @@ -177,7 +176,6 @@ require (
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.1 // indirect
github.com/go-openapi/runtime v0.24.1 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,6 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o=
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/flynn/go-docopt v0.0.0-20140912013429-f6dd2ebbb31e/go.mod h1:HyVoz1Mz5Co8TFO8EupIdlcpwShBmY98dkT2xeHkvEI=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
Expand Down Expand Up @@ -1445,7 +1444,6 @@ github.com/goreleaser/nfpm v1.2.1/go.mod h1:TtWrABZozuLOttX2uDlYyECfQX7x5XYkVxhj
github.com/goreleaser/nfpm v1.3.0/go.mod h1:w0p7Kc9TAUgWMyrub63ex3M2Mgw88M4GZXoTq5UCb40=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
Expand Down
Loading

0 comments on commit 19df363

Please sign in to comment.