feat: implement config cache-proxy command#54
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
cd0ef36 to
5e3688a
Compare
| l.Logger.Infof("cluster-config config map data: %v", cm.Data) | ||
| allowCache = cm.Data["allow-cache-proxy"] | ||
| if allowCache == "true" { | ||
| httpProxy = cm.Data["http-proxy"] | ||
| noProxy = cm.Data["no-proxy"] | ||
| } else { | ||
| httpProxy = "" | ||
| noProxy = "" | ||
| } |
There was a problem hiding this comment.
Should this piece of code in else branch?
There was a problem hiding this comment.
Otherwise setting default*Proxy has no effect. They are reassigned by reading http-proxy and no-proxy from cm.Data.
There was a problem hiding this comment.
have felt this same while writing the logic, but kept the logic same as per the current bash implementation here
There was a problem hiding this comment.
The below if-else is relative to the link you mentioned.
https://github.com/konflux-ci/build-definitions/blob/a91adc4f10bf5dc684fe32b373fd718253945cd4/task/init/0.3/init.yaml#L44-L61 is relative to the commented lines I think. Code from line 44 to 61 has this logic:
- if configmap is present, http_proxy and no_proxy are assigned according to the config data.
- if configmap is not present, use the defaults.
There was a problem hiding this comment.
Got your point now, thanks for catching it.
Addressed it on the latest commit 787fee7
tkdchen
left a comment
There was a problem hiding this comment.
Maybe we can also wrap kubectl (it's included in task-runner) command instead of calling kubenetes APIs, which is similar with other nested commands. Invoking kubectl could also help us having less effort on maintaining dependencies updates.
@tkdchen even if we use cli, for reading/unmarshalling of kubectl cmd outputs, we need to depend on the kubernetes pkgs like |
mmorhun
left a comment
There was a problem hiding this comment.
This might be out of scope of this PR, but it anyway blocks it.
The main problem is that we accessing k8s cluster directly from within CLI making it tightly bound and dependent on k8s environment, making it impossible to run without a cluster, say locally or in another than Tekton CI. (Obviously, there are workarounds, but we need a proper solution).
My suggestion is to create a abstraction layer, say ConfigReader that would detect the environment (easiest is to use env var) and then read k8s resources if run within k8s cluster or access config in different source (say ini or env file) otherwise.
eddf14f to
8d1f0fd
Compare
mmorhun
left a comment
There was a problem hiding this comment.
I think we need ConfigReader interface with a factory (NewConfigReader) that constructs required implementation (K8sConfigReader or EnvFileConfigReader) based on an env var (if not set, k8s is the default). Then config command(s) can use it.
fa990a8 to
d53204e
Compare
d53204e to
cc6af4b
Compare
This PR implements the
konflux-build-cli config cache-proxy --enable <true/false>cmd, to be used during build-definitionsinittask replacement using golang CLI.