Skip to content

Commit

Permalink
Allow selecting the rclone command (#11)
Browse files Browse the repository at this point in the history
So far, the chart is restricted to [rclone
copy](https://rclone.org/commands/rclone_copy). This PR allows the
command to be set (e.g. to invoke [rclone
copyurl](https://rclone.org/commands/rclone_copyurl)).

`copy` is retained as the default command to avoid introducing a
breaking change.
  • Loading branch information
JakobEdding authored Aug 30, 2024
1 parent be09925 commit e4b778b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
8 changes: 8 additions & 0 deletions charts/rclone-copy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ Create chart name and version as used by the chart label.
{{- define "rclone-copy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "rclone-copy.getSourceOrUrl" -}}
{{- if .Values.sync.url -}}
{{ .Values.sync.url -}}
{{- else -}}
{{ .Values.sync.source.name }}:{{ .Values.sync.source.path -}}
{{- end -}}
{{- end -}}
11 changes: 5 additions & 6 deletions charts/rclone-copy/templates/rclone-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ spec:
- name: rclone-container
image: rclone/rclone:{{ .Values.imageRelease }}
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}

command:
- /bin/sh
args:
- -c
# copy as workaround for rclone.conf read only (see https://github.com/rclone/rclone/issues/3655)
- >-
cp /root/.config/rclone/rclone_ro.conf /root/.config/rclone/rclone.conf &&
rclone copy -v {{ .Values.arguments | join " " }} --include-from /root/include-pattern.conf "{{ .Values.sync.source.name }}:{{ .Values.sync.source.path }}" "{{ .Values.sync.dest.name }}:{{ .Values.sync.dest.path }}"
rclone {{ .Values.command }} -v {{ .Values.arguments | join " " }} --include-from /root/include-pattern.conf "{{ include "rclone-copy.getSourceOrUrl" . }}" "{{ .Values.sync.dest.name }}:{{ .Values.sync.dest.path }}"
volumeMounts:
- name: config
# This is the default path where the rclone implementation assumes the config is located
Expand All @@ -76,7 +76,7 @@ spec:
- name: include-config
mountPath: "/root/include-pattern.conf"
subPath: "include-pattern.conf"

resources:
{{ toYaml .Values.resources | indent 14 }}

Expand All @@ -97,7 +97,7 @@ spec:
key: "{{ $value.key }}"
{{- end }}
{{- end }}

restartPolicy: {{ .Values.restartPolicy }}
volumes:
- name: config
Expand All @@ -107,4 +107,3 @@ spec:
configMap:
name: rclone-config-{{ .Release.Name }}
backoffLimit: {{ .Values.backoffLimit }}

8 changes: 7 additions & 1 deletion charts/rclone-copy/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
nameOverride: bakdata-rclone-copy

# The rclone command to run. Default is "copy".
command: "copy"

# This is the cofiguration for the specific rclone-cronjob that you want to run.
# `sync` contains the config for the source and destination of the rclone copy job.
# It can be interpreted as:
# rclone copy {source.name}:{source.path} {dest.name}:{dest.path}
# rclone {command} {sync.source.name}:{sync.source.path} {sync.dest.name}:{sync.dest.path}
sync:
source:
# This is the name for the source remote from the rclone.conf file.
Expand All @@ -14,6 +17,9 @@ sync:
# This is the path to the source directory.
path: /tmp/sync-dir

# Alternatively for the case of `rclone copyurl`, provide a URL instead of a source
url: ""

dest:
# This is the name for the destination remote from the rclone.conf file.
# If the value specified here is not present in the config file, the job will fail.
Expand Down

0 comments on commit e4b778b

Please sign in to comment.