Skip to content

Commit

Permalink
fix(makefile): add missing escape_dot function to properly handle sec…
Browse files Browse the repository at this point in the history
…ret key names with dots (#1228)

# Description

This PR adds the `escape_dot` function to the Makefile so that secret
keys containing dots (e.g., `tls.crt`) are correctly escaped when
forming Kubernetes JSONPath expressions. Previously, the lack of an
escape function caused the JSONPath to parse `tls.crt` as nested fields,
leading to empty certificate files.

## Related Issue
#601 
`[hubble] make get-certs not working`


## Checklist

- [X] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [X] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [X] I have correctly attributed the author(s) of the code.
- [X] I have tested the changes locally.
- [X] I have followed the project's style guidelines.
- [ ] I have updated the documentation, if necessary.
- [ ] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes
made.

## Additional Notes
 Changes: 
- Implement `escape_dot` using `$(subst .,\\.,$(1))` in the Makefile
- Update the `get-certs` target to call `escape_dot` when retrieving
secrets
- Fix empty cert issue caused by incorrect JSONPath queries
---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.

Signed-off-by: Yerlan Baiturinov <[email protected]>
Signed-off-by: Yerlan Baiturinov <[email protected]>
Co-authored-by: Yerlan Baiturinov <[email protected]>
  • Loading branch information
byte-msft and Yerlan Baiturinov authored Jan 16, 2025
1 parent a2c261f commit f980041
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ image-metadata-*.json
*results*.json
netperf-*.json
netperf-*.csv

.certs/
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ get-certs:
hubble config set tls true
hubble config set tls-server-name instance.hubble-relay.cilium.io

# Replaces every '.' in $(1) with '\.'
escape_dot = $(subst .,\.,$(1))

.PHONY: clean-certs
clean-certs:
rm -rf $(CERT_DIR)
Expand Down

0 comments on commit f980041

Please sign in to comment.