Skip to content

Commit

Permalink
♻️ Use .Data.thing instead of index .Data "thing" in yaml exporter ma…
Browse files Browse the repository at this point in the history
…nifests
  • Loading branch information
gwennlbh committed Apr 17, 2024
1 parent f68d252 commit 1c998f3
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions exporters/11ty.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ data:
in: projects/

work:
- log: [Exporting, cyan, '{{if .Verbose}}{{.Work.ID}} for 11ty to [bold]{{ index .Data "in" }}/{{.Work.ID}}.11tydata.json[reset]{{end}}']
- run: echo {{ .Work | json | escape }} > {{ index .Data "in" }}/{{.Work.ID}}.11tydata.json
- log: [Exporting, cyan, '{{if .Verbose}}{{.Work.ID}} for 11ty to [bold]{{ .Data.in }}/{{.Work.ID}}.11tydata.json[reset]{{end}}']
- run: echo {{ .Work | json | escape }} > {{ .Data.in }}/{{.Work.ID}}.11tydata.json
10 changes: 5 additions & 5 deletions exporters/cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ data:
remotes:

after:
- log: [Uploading, blue, '{{ .Ctx.OutputDatabaseFile }} to{{ range $remote := (index .Data "remotes") }} {{$remote}}:{{ index $.Data "path" }}/{{ index $.Data "name" }}, {{ end }}[dim]with rclone']
- log: [Uploading, blue, '{{ .Ctx.OutputDatabaseFile }} to{{ range $remote := .Data.remotes }} {{$remote}}:{{ $.Data.path }}/{{ $.Data.name }}, {{ end }}[dim]with rclone']
- run: mkdir -p .ortfo-cloud-exporter-tmp
- run: cp {{ $.Ctx.OutputDatabaseFile }} .ortfo-cloud-exporter-tmp/{{ index $.Data "name" }}
- run: cp {{ $.Ctx.OutputDatabaseFile }} .ortfo-cloud-exporter-tmp/{{ $.Data.name }}
- run: >-
{{ range $remote := (index .Data "remotes") }}
rclone copy --progress .ortfo-cloud-exporter-tmp/{{ index $.Data "name" }} {{$remote}}:{{ index $.Data "path" }}
{{ range $remote := .Data.remotes }}
rclone copy --progress .ortfo-cloud-exporter-tmp/{{ $.Data.name }} {{$remote}}:{{ $.Data.path }}
{{ end }}
- run: rm .ortfo-cloud-exporter-tmp/{{ index $.Data "name" }}
- run: rm .ortfo-cloud-exporter-tmp/{{ $.Data.name }}
- run: rmdir .ortfo-cloud-exporter-tmp
4 changes: 2 additions & 2 deletions exporters/copy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ data:
paths: []

after:
- log: [Copying, cyan, 'database to [bold]{{ index .Data "paths" | join ", " }}[reset]']
- log: [Copying, cyan, 'database to [bold]{{ .Data.paths | join ", " }}[reset]']
- run: >-
{{ range $path := index .Data "paths" }}
{{ range $path := .Data.paths }}
cp {{ if $.Verbose}}-v{{end}} {{ $.Ctx.OutputDatabaseFile }} {{$path}}
{{ end }}
4 changes: 2 additions & 2 deletions exporters/ftp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ data:
dry run: false

after:
- log: [Uploading, blue, '{{ .Ctx.OutputDatabaseFile }} to {{if (index .Data "secure")}}s{{end}}ftp://{{ index .Data "host" }}/{{ index .Data "path" }}']
- log: [Uploading, blue, '{{ .Ctx.OutputDatabaseFile }} to {{if .Data.secure}}s{{end}}ftp://{{ .Data.host }}/{{ .Data.path }}']
- run: >-
{{if .DryRun}} echo {{end}}
curl -T {{ .Ctx.OutputDatabaseFile }}
{{if (index .Data "secure")}}sftp://{{else}}ftp://{{end}}{{index .Data "username"}}:{{index .Data "password"}}@{{ index .Data "host" }}/{{ index .Data "path" }}
{{if .Data.secure}}sftp://{{else}}ftp://{{end}}{{.Data.username}}:{{.Data.password}}@{{ .Data.host }}/{{ .Data.path }}
10 changes: 5 additions & 5 deletions exporters/git.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ data:

after:
# - run: test ! -d .ortfodb-tmp || echo .ortfodb-tmp exists, please remove it >&2; exit 1
- log: [Cloning, blue, 'repository {{ index .Data "url" }}']
- run: git clone {{ index .Data "git_clone_flags" }} {{ index .Data "url" }} .ortfodb-tmp
- log: [Cloning, blue, 'repository {{ .Data.url }}']
- run: git clone {{ .Data.git_clone_flags }} {{ .Data.url }} .ortfodb-tmp
- log: [Comitting, blue, "{{ .Ctx.OutputDatabaseFile }} to the repository"]
- run: cp {{ .Ctx.OutputDatabaseFile }} .ortfodb-tmp/{{ index .Data "path" }}
- run: cd .ortfodb-tmp && git add {{ index .Data "git_add_flags" }} {{ index .Data "path" }} && git commit {{ index .Data "git_commit_flags" }} -m '{{ index .Data "commit" }}'
- run: cp {{ .Ctx.OutputDatabaseFile }} .ortfodb-tmp/{{ .Data.path }}
- run: cd .ortfodb-tmp && git add {{ .Data.git_add_flags }} {{ .Data.path }} && git commit {{ .Data.git_commit_flags }} -m '{{ .Data.commit }}'
- log: [Pushing, blue, "changes to the repository"]
- run: cd .ortfodb-tmp && git push {{ index .Data "git_push_flags" }}
- run: cd .ortfodb-tmp && git push {{ .Data.git_push_flags }}
- log: [Cleaning up, dim, ".ortfodb-tmp directory"]
- run: rm -rf .ortfodb-tmp
10 changes: 5 additions & 5 deletions exporters/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ data:
index: index.json

before:
- run: mkdir -p {{ index .Data "in" }}
- run: mkdir -p {{ .Data.in }}

work:
- log: [Exporting, cyan, '{{if .Verbose}}{{.Work.ID}} for Hugo to [bold]{{ index .Data "in" }}/{{.Work.ID}}.json[reset]{{end}}']
- run: echo {{ .Work | json | escape }} > {{ index .Data "in" }}/{{.Work.ID}}.json
- log: [Exporting, cyan, '{{if .Verbose}}{{.Work.ID}} for Hugo to [bold]{{ .Data.in }}/{{.Work.ID}}.json[reset]{{end}}']
- run: echo {{ .Work | json | escape }} > {{ .Data.in }}/{{.Work.ID}}.json

after:
- log: [Exporting, cyan, '{{ if .Verbose}}Index database to {{ index .Data "in" | splitList "/" | first }}/{{ index .Data "index" }}{{ end }}']
- run: echo {{ .Database.AsSlice | json | escape }} > {{ index .Data "in" | splitList "/" | first }}/{{ index .Data "index" }}
- log: [Exporting, cyan, '{{ if .Verbose}}Index database to {{ .Data.in | splitList "/" | first }}/{{ .Data.index }}{{ end }}']
- run: echo {{ .Database.AsSlice | json | escape }} > {{ .Data.in | splitList "/" | first }}/{{ .Data.index }}
6 changes: 3 additions & 3 deletions exporters/ssh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ after:
- log:
- Uploading
- blue
- '{{ .Ctx.OutputDatabaseFile }} to [bold]{{ index .Data "ssh" }} [dim]using{{ if (index .Data "rsync") }} rsync {{ else }} scp {{ end }} [reset]'
- '{{ .Ctx.OutputDatabaseFile }} to [bold]{{ .Data.ssh }} [dim]using{{ if .Data.rsync }} rsync {{ else }} scp {{ end }} [reset]'
- run: >-
{{ $from := .Ctx.OutputDatabaseFile }}
{{ $to := index .Data "ssh" }}
{{ $to := .Data.ssh }}
{{ if .DryRun }} echo {{end}}
{{ if (index .Data "rsync") }}
{{ if .Data.rsync }}
rsync -r --info=progress {{$from}} {{$to}}
{{ else }}
scp {{$from}} {{$to}}
Expand Down
6 changes: 3 additions & 3 deletions exporters/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ after:
- Triggering
- cyan
- 'webhook [bold]{{
index .Data "url"
.Data.url
| trimPrefix "http://"
| trimPrefix "https://"
}}[reset]'
Expand All @@ -25,7 +25,7 @@ after:
curl -X POST
{{if not .Verbose }} -sS {{ end }}
-d @{{ .Ctx.OutputDatabaseFile }}
{{ range $name, $value := (index .Data "headers") }}
{{ range $name, $value := .Data.headers }}
-H "{{ $name }}: {{ $value }}"
{{ end }}
{{ index .Data "url" }}
{{ .Data.url }}

0 comments on commit 1c998f3

Please sign in to comment.