-
Notifications
You must be signed in to change notification settings - Fork 35
Add helper functions for Chronicle agent #669
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6610d35
Add helper functions for Chronicle agent
ianpittwood e1ba2a8
Update helm-docs and README.md
actions-user 8516918
Trigger CI
ianpittwood f04c679
Merge branch 'main' into chronicle/rstudio-library-helpers
ianpittwood 0275fc1
Remove excessive whitespace trim in helper
ianpittwood a3cef3d
Allow a namespace to be passed for the chronicle server lookup
ianpittwood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| {{/* | ||
| Attempts to determine an image tag for the chronicle-agent image by looking up a Chronicle server in the current | ||
| namespace. If no server is found, it will default to "latest". If a tag is specified in the passed config, it will be | ||
| used instead of the server tag. | ||
| Takes a dict: | ||
| - .chronicleAgent: the chronicle-agent config | ||
| - .chronicleAgent.image.registry: the registry to use for the image | ||
| - .chronicleAgent.image.repository: the repository to use for the image | ||
| - .chronicleAgent.image.tag: the tag to use for the image (optional) | ||
| - .chronicleAgent.serverNamespace: the namespace to search for the Chronicle server, defaults to the current release namespace | ||
| */}} | ||
| {{- define "rstudio-library.chronicle-agent.image" }} | ||
| {{- $registry := required "registry must be specified for the chronicle-agent config." .chronicleAgent.image.registry }} | ||
| {{- $repository := required "repository must be specified for the chronicle-agent config." .chronicleAgent.image.repository }} | ||
| {{- $version := "latest" }} | ||
| {{- if not .chronicleAgent.image.tag }} | ||
| {{- range $index, $service := (lookup "v1" "Service" (default .Release.Namespace .chronicleAgent.serverNamespace) "").items }} | ||
| {{- $name := get $service.metadata.labels "app.kubernetes.io/name" }} | ||
| {{- $component := get $service.metadata.labels "app.kubernetes.io/component" }} | ||
| {{- if and (contains "posit-chronicle" $name) (eq $component "server") }} | ||
| {{- $version = get $service.metadata.labels "app.kubernetes.io/version" }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- else }} | ||
| {{- $version = .chronicleAgent.image.tag }} | ||
| {{- end }} | ||
| {{ $registry }}/{{ $repository }}:{{ $version }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Attempts to determine the server address for the chronicle-agent image by looking up a Chronicle server in the current | ||
| namespace. If no server is found, it will default to "". If a serverAddress is specified in the passed config, | ||
| it will be used instead of the server address. | ||
| Takes a dict: | ||
| - .chronicleAgent: the chronicle-agent config | ||
| - .chronicleAgent.serverAddress: the server address to use for the image (optional) | ||
| - .chronicleAgent.serverNamespace: the namespace to search for the Chronicle server, defaults to the current release namespace | ||
| */}} | ||
| {{- define "rstudio-library.chronicle-agent.serverAddress" }} | ||
| {{- if .chronicleAgent.serverAddress }} | ||
| {{ .chronicleAgent.serverAddress}} | ||
| {{- else }} | ||
| {{- range $index, $service := (lookup "v1" "Service" (default .Release.Namespace .chronicleAgent.serverNamespace) "").items }} | ||
| {{- $name := get $service.metadata.labels "app.kubernetes.io/name "}} | ||
| {{- $component := get $service.metadata.labels "app.kubernetes.io/component "}} | ||
| {{- if and (contains "posit-chronicle" $name) (eq $component "server") }} | ||
| {{ $name }}.{{ $service.metadata.namespace }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.