Skip to content
Merged
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
4 changes: 2 additions & 2 deletions charts/rstudio-library/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: rstudio-library
description: Helm library helpers for use by official RStudio charts
type: library
version: 0.1.31
appVersion: 0.1.31
version: 0.1.32
appVersion: 0.1.32

icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
home: https://www.rstudio.com
Expand Down
5 changes: 5 additions & 0 deletions charts/rstudio-library/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.1.32

- Add `rstudio-library.chronicle-agent.image` and `rstudio-library.chronicle-agent.serverAddress` helper functions for
Chronicle server deployment auto-discovery.

## 0.1.31

- Add helm unit test scaffold.
Expand Down
2 changes: 1 addition & 1 deletion charts/rstudio-library/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rstudio-library

![Version: 0.1.31](https://img.shields.io/badge/Version-0.1.31-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.31](https://img.shields.io/badge/AppVersion-0.1.31-informational?style=flat-square)
![Version: 0.1.32](https://img.shields.io/badge/Version-0.1.32-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.32](https://img.shields.io/badge/AppVersion-0.1.32-informational?style=flat-square)

#### _Helm library helpers for use by official RStudio charts_

Expand Down
51 changes: 51 additions & 0 deletions charts/rstudio-library/templates/_chronicle-agent.tpl
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 }}