Skip to content

feat: added support for changing config via API #729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TESTDATA := $(TOP_LEVEL)/test/data
OS ?= linux
ARCH ?= amd64
BENCH_OUTPUT ?= stdout
EXTENSIONS ?= sync,search,scrub,metrics,lint
EXTENSIONS ?= sync,search,scrub,metrics,lint,config
comma:= ,
hyphen:= -
extended-name:=
Expand Down Expand Up @@ -86,7 +86,7 @@ privileged-test: check-skopeo $(TESTDATA) $(NOTATION)
go test -failfast -tags needprivileges,$(EXTENSIONS),containers_image_openpgp -v -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile=coverage-dev-needprivileges.txt -covermode=atomic ./pkg/storage/... ./pkg/cli/... -run ^TestElevatedPrivileges

$(TESTDATA): check-skopeo
$(shell mkdir -p ${TESTDATA}; cd ${TESTDATA}; mkdir -p noidentity; ../scripts/gen_certs.sh; cd ${TESTDATA}/noidentity; ../../scripts/gen_nameless_certs.sh; cd ${TOP_LEVEL}; skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:7 oci:${TESTDATA}/zot-test:0.0.1;skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:8 oci:${TESTDATA}/zot-cve-test:0.0.1)
$(shell mkdir -p ${TESTDATA}; cd ${TESTDATA}; touch htpasswd; mkdir -p noidentity; ../scripts/gen_certs.sh; cd ${TESTDATA}/noidentity; ../../scripts/gen_nameless_certs.sh; cd ${TOP_LEVEL}; skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:7 oci:${TESTDATA}/zot-test:0.0.1;skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:8 oci:${TESTDATA}/zot-cve-test:0.0.1)
$(shell chmod -R a=rwx ${TESTDATA})

.PHONY: run-bench
Expand Down Expand Up @@ -198,7 +198,7 @@ run: binary test
verify-config: _verify-config verify-config-warnings verify-config-commited

.PHONY: _verify-config
_verify-config: binary
_verify-config: binary $(TESTDATA)
rm -f output.txt
$(foreach file, $(wildcard examples/config-*), ./bin/zot-$(OS)-$(ARCH) verify $(file) 2>&1 | tee -a output.txt || exit 1;)

Expand Down
23 changes: 22 additions & 1 deletion examples/config-allextensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@
},
"http": {
"address": "127.0.0.1",
"port": "8080"
"port": "8080",
"auth": {
"htpasswd": {
"path": "test/data/htpasswd"
}
},
"accesscontrol": {
"adminpolicy": {
"actions": [
"read",
"create",
"update",
"delete"
],
"users": [
"admin"
]
}
}
},
"log": {
"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
36 changes: 36 additions & 0 deletions examples/config-cfg-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"distspecversion": "1.0.1-dev",
"extensions": {
"sysconfig": {
"enable": true
}
},
"http": {
"accesscontrol": {
"adminpolicy": {
"actions": [
"read",
"create",
"update",
"delete"
],
"users": [
"admin"
]
}
},
"address": "127.0.0.1",
"auth": {
"htpasswd": {
"path": "test/data/htpasswd"
}
},
"port": "5000"
},
"log": {
"level": "debug"
},
"storage": {
"rootdirectory": "/tmp/zot"
}
}
228 changes: 115 additions & 113 deletions examples/config-policy.json
Original file line number Diff line number Diff line change
@@ -1,113 +1,115 @@
{
"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",
"storage": {
"rootDirectory": "/tmp/zot"
},
"http": {
"address": "127.0.0.1",
"port": "8080",
"realm": "zot",
"auth": {
"htpasswd": {
"path": "test/data/htpasswd"
},
"failDelay": 1
},
"accessControl": {
"repositories": {
"**": {
"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"
}
}
4 changes: 2 additions & 2 deletions examples/config-tls.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"port": "8080",
"realm": "zot",
"tls": {
"cert": "../../test/data/server.cert",
"key": "../../test/data/server.key"
"cert": "test/data/server.cert",
"key": "test/data/server.key"
}
},
"log": {
Expand Down
Loading