diff --git a/updatecli/policies/copy/CHANGELOG.md b/updatecli/policies/copy/CHANGELOG.md new file mode 100644 index 0000000..a715cde --- /dev/null +++ b/updatecli/policies/copy/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 0.1.0 + + * Initial release diff --git a/updatecli/policies/copy/Policy.yaml b/updatecli/policies/copy/Policy.yaml new file mode 100644 index 0000000..9343705 --- /dev/null +++ b/updatecli/policies/copy/Policy.yaml @@ -0,0 +1,29 @@ +--- +# Policy.yaml contains metadata for the Updatecli policy. + +# Authors is the policy authors +authors: + - José Guilherme Vanz + +# URL is the policy url +url: "https://github.com/updatecli/policies/" + +# Documentation is the policy documentation URL +documentation: "https://github.com/updatecli/policies/tree/main/updatecli/policies/copy/README.md" + +# Source is the policy source URL +source: "https://github.com/updatecli/policies/tree/main/updatecli/policies/copy/" + +# Version is the policy version. +version: 0.1.0 + +# Vendor is the policy vendor +vendor: Updatecli project + +# License is the policy licenses +licenses: + - "Apache-2.0 license" + +# Description is the short policy description +description: | + Copy files from a git repository to a local file diff --git a/updatecli/policies/copy/README.md b/updatecli/policies/copy/README.md new file mode 100644 index 0000000..3ccc5e9 --- /dev/null +++ b/updatecli/policies/copy/README.md @@ -0,0 +1,29 @@ +## DESCRIPTION + +This policy can be used to copy files from a source repository to a local file + + +Here is a basic example of a configuration + +```values.yaml + +src: + url: "https://github.com/updatecli/updatecli.git" + branch: "main" + +files: + - src: .golangci.yml + dst: .golangci.yml + - src: _typos.toml + dst: _typos.toml + - src: codecov.yaml + dst: codecov.yaml + - src: .gitignore + dst: .gitignore +``` + +Then you can execute this policy running: + +``` +updatecli diff --values values.yaml ghcr.io/updatecli/policies/updatecli/copy:latest +``` diff --git a/updatecli/policies/copy/testdata/values.yaml b/updatecli/policies/copy/testdata/values.yaml new file mode 100644 index 0000000..b41f0dc --- /dev/null +++ b/updatecli/policies/copy/testdata/values.yaml @@ -0,0 +1,13 @@ +src: + url: "https://github.com/updatecli/updatecli.git" + branch: "main" + +files: + - src: .golangci.yml + dst: .golangci.yml + - src: _typos.toml + dst: _typos.toml + - src: codecov.yaml + dst: codecov.yaml + - src: .gitignore + dst: .gitignore diff --git a/updatecli/policies/copy/updatecli.d/default.yaml b/updatecli/policies/copy/updatecli.d/default.yaml new file mode 100644 index 0000000..e552a4d --- /dev/null +++ b/updatecli/policies/copy/updatecli.d/default.yaml @@ -0,0 +1,40 @@ +--- +# Helpers +# {{ $DefaultTitle := (print "copy file(s) from " .src.url ) }} + +name: '{{ default $DefaultTitle .title }}' + +# {{ if .pipelineid }} +pipelineid: '{{ .pipelineid }}' +# {{ end }} + +# scms defines the source control management system to interact with. +scms: + source: + kind: git + spec: + url: "{{ .src.url }}" + branch: "{{ .src.branch }}" + +# sources defines where to find the information. +sources: +# {{ range $index, $file := .files }} + {{ $index }}: + name: 'Get {{$file.src }} from source repository' + scmid: 'source' + kind: 'file' + spec: + file: '{{ $file.src }}' +# {{ end }} + +## targets defines where to apply the changes. +targets: +# {{ range $index, $file := .files }} + "{{ $index }}": + name: 'sync {{ $file.dst }} file' + kind: 'file' + sourceid: '{{ $index }}' + spec: + file: '{{ $file.dst }}' + forcecreate: true +# {{ end }} diff --git a/updatecli/policies/copy/values.yaml b/updatecli/policies/copy/values.yaml new file mode 100644 index 0000000..f425d60 --- /dev/null +++ b/updatecli/policies/copy/values.yaml @@ -0,0 +1,23 @@ +--- +# Values.yaml contains settings that be used from Updatecli manifest. + +## title override the default title of the policy +#title: "chore: sync file from source repository" + +## files contains the list of files to be copied from the source repository to the target repository. +#files: +# - src: "" +# dst: "" + +## pipelineid is the pipeline id to be used by the policy +## It is used to identify the pipeline that is running the policy. +## Different pipelines sharing the same pipelineid and the same scm configuration +## will update the same pullrequest +#pipelineid: "file" + + +## src contains the source repository information +## It is used to fetch the files to be copied to the target repository +#src: +# url: "" +# branch: ""