How to set docker registry through a swagger API call
Summary
I was wondering if there is an API to set the registry (that is on the Administration panel) through a swagger call?
/cc @maysunfaisal
Relevant information
The plugin and devfile registry can be set only with the environment variables of the Che server. Or you can specify direct url in devfile
components:
- alias: exec-plugin
type: chePlugin
reference: https://raw.githubusercontent.com.../plugin/1.0.1/meta.yaml
@skabashnyuk Devfile is fine, I was more interested in knowing if there is an API to add docker registries in the admin panel?

@skabashnyuk Any updates?
@ssh24 you can set docker registry over api like this
// {testURL: {username: 'testName', password: 'testPassword'}} converted to base64
let dockerCredentials = 'eyJ0ZXN0VVJMIjp7InVzZXJuYW1lIjoidGVzdE5hbWUiLCJwYXNzd29yZCI6InRlc3RQYXNzd29yZCJ9fQ==';
curl 'https://host/api/preferences' -H 'Accept: application/json, text/plain, */*' -H 'Referer: https://ddd/dashboard/' -H 'Origin: https://ddd' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36' -H 'Authorization: Bearer token' -H 'Sec-Fetch-Mode: cors' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"codenvy:created":"1525510317282","temporary":"false","git.contribute.activate.projectSelection":"false","dockerCredentials":"eyJ3ZXJ3ZXJ3ZSI6eyJ1c2VybmFtZSI6IndlcndlciIsInBhc3N3b3JkIjoid2Vyd2VyIn19"}' --compressed
hovere it was used only in deprecated Docker infrastructure AFAIK.
@skabashnyuk Yes that api is not working for me. After I set it, I am unable to use it. Would you know the underlyings of encoding the credentials?
I encoded my credentials in this format http://$USER:$PASS@$REGISTRY
Does Che do it differently?
@ssh24 did you try it on che6?
@skabashnyuk I am on Che 7.2.0
How to set docker registry through a swagger API call
You can set it but it's not used anymore in Che7. I'm sorry for that UX, this is is outdated functionality that we forgot to remove.
I was wrong. It is actually used. https://github.com/eclipse/che/blob/master/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/ImagePullSecretProvisioner.java
@skabashnyuk It still didn't work. Where is the docker registry url field in https://github.com/eclipse/che/blob/master/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/ImagePullSecretProvisioner.java#L114
For example API call
curl 'https://che.openshift.io/api/preferences' -H 'Sec-Fetch-Site: same-origin' --data-binary '{"codenvy:created":"1525510317282","temporary":"false","git.contribute.activate.projectSelection":"false","dockerCredentials":"eyJodHRwOi8vZG9ja2VycmVnc2l0b3J5LmNvbSI6eyJ1c2VybmFtZSI6ImFkZmFzZCIsInBhc3N3b3JkIjoiYXNmc2RmZnNkIn0sIndlcndlcndlIjp7InVzZXJuYW1lIjoid2Vyd2VyIiwicGFzc3dvcmQiOiJ3ZXJ3ZXIifX0="}' --compressed
where dockerCredentials is base64 string
{"http://dockerregsitory.com":{"username":"adfasd","password":"asfsdffsd"},"werwerwe":{"username":"werwer","password":"werwer"}}
See https://github.com/eclipse/che/blob/master/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/ImagePullSecretProvisioner.java#L110
@skabashnyuk Thank you. I got it to work now.
@skabashnyuk The above works for OCP3 but in OKD4 did it change? Reopening the issue for now. When I tried the above https://github.com/eclipse/che/issues/14897#issuecomment-545076305 it did set the registry but I was unable to use the registry in my workspace.
@ssh24 can you create a separate issue for that with concrete details? Thx.
Ok, no worries. I found out the issue was in OKD4 the default registry address is different i.e image-registry.openshift-image-registry.svc:5000