diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index eb5a316..0000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 5074759..0000000 --- a/.drone.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -kind: pipeline -type: kubernetes -name: Tests - -trigger: - event: - - push - -steps: - - name: Prepare helm and helmfile - image: ghcr.io/helmfile/helmfile:canary - commands: - - mkdir -p bin - - cp $(which helm) ./bin/helm - - cp $(which helmfile) ./bin/helmfile - - - name: Unit tests - image: rust:slim - environment: - CARGO_BUILD_JOBS: 1 - commands: - - export PATH=$PWD/bin:$PATH - - helm - - helmfile - - cargo test diff --git a/.github/workflows/container-stable.yaml b/.github/workflows/container-stable.yaml index 0748112..9189fff 100644 --- a/.github/workflows/container-stable.yaml +++ b/.github/workflows/container-stable.yaml @@ -5,10 +5,11 @@ on: push: branches: - main + paths: + - "src/**" jobs: - prepare_base: - name: Prepare the base image + containerization: runs-on: ubuntu-latest steps: - name: Checkout @@ -25,6 +26,7 @@ jobs: - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@master + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: @@ -32,7 +34,7 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.CR_PAT }} - - name: Build base + - name: Build uses: docker/build-push-action@v2 with: builder: ${{ steps.buildx.outputs.name }} @@ -41,57 +43,8 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: | - ghcr.io/${{ github.repository }}-base:latest - labels: | - action_id=${{ github.action }} - action_link=${{ env.LINK }} - actor=${{ github.actor }} - sha=${{ github.sha }} - ref=${{ github.ref }} - - build_containers: - name: Build final images - runs-on: ubuntu-latest - needs: prepare_base - strategy: - matrix: - target_image: - - helmfile - - helmfile-secrets - - argo - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set action link variable - run: echo "LINK=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV - - - name: Set up QEMU - uses: docker/setup-qemu-action@master - with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@master - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - - - name: Build ${{ matrix.target_image }} - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - context: ./dockerfiles - file: ./dockerfiles/Dockerfile-${{ matrix.target_image }} - platforms: linux/amd64,linux/arm64 - push: true - tags: | - ghcr.io/${{ github.repository }}-${{ matrix.target_image }}:latest - ghcr.io/${{ github.repository }}-${{ matrix.target_image }}:stable + ghcr.io/allanger/${{ env.GITHUB_REPOSITORY }}:stable + ghcr.io/allanger/${{ env.GITHUB_REPOSITORY }}:latest labels: | action_id=${{ github.action }} action_link=${{ env.LINK }} diff --git a/.github/workflows/container-version.yaml b/.github/workflows/container-version.yaml index 0c2d1b2..d40f07e 100644 --- a/.github/workflows/container-version.yaml +++ b/.github/workflows/container-version.yaml @@ -1,5 +1,5 @@ --- -name: "Versioned container" +name: "Version container" on: push: @@ -7,8 +7,7 @@ on: - "v*.*.*" jobs: - prepare_base: - name: Prepare the base image + containerization: runs-on: ubuntu-latest steps: - name: Checkout @@ -28,13 +27,15 @@ jobs: - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@master + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.CR_PAT }} - - name: Build base + + - name: Build uses: docker/build-push-action@v2 with: builder: ${{ steps.buildx.outputs.name }} @@ -43,64 +44,10 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: | - ghcr.io/${{ github.repository }}-base:${{ env.TAG }} + ghcr.io/allanger/${{ env.GITHUB_REPOSITORY }}:${{ env.TAG }} labels: | action_id=${{ github.action }} action_link=${{ env.LINK }} actor=${{ github.actor }} sha=${{ github.sha }} ref=${{ github.ref }} - - build_containers: - name: Build final images - runs-on: ubuntu-latest - needs: prepare_base - strategy: - matrix: - target_image: - - helmfile - - helmfile-secrets - - argo - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set version variable - run: echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV - - - name: Set action link variable - run: echo "LINK=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV - - - name: Set up QEMU - uses: docker/setup-qemu-action@master - with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@master - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - - - name: Build ${{ matrix.target_image }} - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - context: ./dockerfiles - file: ./dockerfiles/Dockerfile-${{ matrix.target_image }} - platforms: linux/amd64,linux/arm64 - push: true - tags: | - ghcr.io/${{ github.repository }}-${{ matrix.target_image }}:${{ env.TAG }} - ghcr.io/${{ github.repository }}-${{ matrix.target_image }}:${{ env.TAG }} - labels: | - action_id=${{ github.action }} - action_link=${{ env.LINK }} - actor=${{ github.actor }} - sha=${{ github.sha }} - ref=${{ github.ref }} - \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 2b39784..02db667 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,60 +4,18 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.2" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" dependencies = [ "memchr", ] [[package]] -name = "anstream" -version = "0.6.4" +name = "autocfg" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" - -[[package]] -name = "anstyle-parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" -dependencies = [ - "anstyle", - "windows-sys", -] +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" @@ -65,30 +23,30 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - [[package]] name = "block-buffer" -version = "0.10.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ "generic-array", ] [[package]] name = "bytecount" -version = "0.6.7" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" +checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" + +[[package]] +name = "cc" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cdh" -version = "0.1.9" +version = "0.1.0" dependencies = [ "clap", "clap_complete", @@ -99,7 +57,6 @@ dependencies = [ "serde_json", "serde_yaml", "tabled", - "tempfile", "version-compare", ] @@ -111,64 +68,55 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.8" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" dependencies = [ - "clap_builder", + "bitflags", "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" -dependencies = [ - "anstream", - "anstyle", "clap_lex", + "is-terminal", + "once_cell", "strsim", + "termcolor", ] [[package]] name = "clap_complete" -version = "4.4.4" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae" +checksum = "ce8955d4e8cd4f28f9a01c93a050194c4d131e73ca02f6636bcddbed867014d7" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" dependencies = [ "heck", + "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.39", + "syn", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" +dependencies = [ + "os_str_bytes", +] [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] @@ -185,9 +133,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.7" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" dependencies = [ "block-buffer", "crypto-common", @@ -195,9 +143,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ "humantime", "is-terminal", @@ -206,27 +154,26 @@ dependencies = [ "termcolor", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "errno" -version = "0.3.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" dependencies = [ + "errno-dragonfly", "libc", - "windows-sys", + "winapi", ] [[package]] -name = "fastrand" -version = "2.0.1" +name = "errno-dragonfly" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] [[package]] name = "fnv" @@ -236,9 +183,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -246,9 +193,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.5.0" +version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" +checksum = "433e4ab33f1213cdc25b5fa45c76881240cfe79284cf2b395e8b9e312a30a2fd" dependencies = [ "log", "pest", @@ -260,21 +207,24 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] [[package]] name = "humantime" @@ -284,66 +234,86 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "2.1.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ - "equivalent", + "autocfg", "hashbrown", ] [[package]] -name = "is-terminal" -version = "0.4.9" +name = "io-lifetimes" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "e394faa0efb47f9f227f1cd89978f854542b318a6f64fa695489c9c993056656" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" dependencies = [ "hermit-abi", + "io-lifetimes", "rustix", "windows-sys", ] [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "linux-raw-sys" -version = "0.4.11" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" [[package]] name = "log" -version = "0.4.20" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] [[package]] name = "memchr" -version = "2.6.4" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "once_cell" -version = "1.18.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "os_str_bytes" +version = "6.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" [[package]] name = "papergrid" -version = "0.10.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ccbe15f2b6db62f9a9871642746427e297b0ceb85f9a7f1ee5ff47d184d0c8" +checksum = "1526bb6aa9f10ec339fb10360f22c57edf81d5678d0278e93bc12a47ffbe4b01" dependencies = [ "bytecount", "fnv", @@ -352,20 +322,19 @@ dependencies = [ [[package]] name = "pest" -version = "2.7.5" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" dependencies = [ - "memchr", "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.5" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +checksum = "60b75706b9642ebcb34dab3bc7750f811609a0eb1dd8b88c2d15bf628c1c65b2" dependencies = [ "pest", "pest_generator", @@ -373,26 +342,26 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.5" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +checksum = "f4f9272122f5979a6511a749af9db9bfc810393f63119970d7085fed1c4ea0db" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.39", + "syn", ] [[package]] name = "pest_meta" -version = "2.7.5" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +checksum = "4c8717927f9b79515e565a64fe46c38b8cd0427e64c40680b14a7365ab09ac8d" dependencies = [ "once_cell", "pest", - "sha2", + "sha1", ] [[package]] @@ -404,7 +373,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn 1.0.109", + "syn", "version_check", ] @@ -421,48 +390,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "regex" -version = "1.10.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -471,18 +419,19 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "rustix" -version = "0.38.25" +version = "0.36.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" dependencies = [ - "bitflags 2.4.1", + "bitflags", "errno", + "io-lifetimes", "libc", "linux-raw-sys", "windows-sys", @@ -490,35 +439,35 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ "itoa", "ryu", @@ -527,9 +476,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.27" +version = "0.9.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" +checksum = "92b5b431e8907b50339b51223b97d102db8d987ced36f6e4d03621db9316c834" dependencies = [ "indexmap", "itoa", @@ -539,10 +488,10 @@ dependencies = [ ] [[package]] -name = "sha2" -version = "0.10.8" +name = "sha1" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if", "cpufeatures", @@ -557,20 +506,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.109" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", @@ -579,9 +517,9 @@ dependencies = [ [[package]] name = "tabled" -version = "0.14.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe9c3632da101aba5131ed63f9eed38665f8b3c68703a6bb18124835c1a5d22" +checksum = "56c3ee73732ffceaea7b8f6b719ce3bb17f253fa27461ffeaf568ebd0cdb4b85" dependencies = [ "papergrid", "tabled_derive", @@ -590,100 +528,81 @@ dependencies = [ [[package]] name = "tabled_derive" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99f688a08b54f4f02f0a3c382aefdb7884d3d69609f785bd253dc033243e3fe4" +checksum = "beca1b4eaceb4f2755df858b88d9b9315b7ccfd1ffd0d7a48a52602301f01a57" dependencies = [ "heck", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", -] - -[[package]] -name = "tempfile" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys", + "syn", ] [[package]] name = "termcolor" -version = "1.4.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn", ] [[package]] name = "typenum" -version = "1.17.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "unsafe-libyaml" -version = "0.2.9" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "bc7ed8ba44ca06be78ea1ad2c3682a43349126c8818054231ee6f4748012aed2" [[package]] name = "version-compare" -version = "0.1.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" +checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73" [[package]] name = "version_check" @@ -709,9 +628,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] @@ -724,18 +643,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -748,42 +658,42 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" diff --git a/Cargo.toml b/Cargo.toml index e5536ee..a6e103e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cdh" authors = ["allanger "] -version = "0.1.9" +version = "0.1.0" description = "Your helm releases are outdated, aren't they? Now you can check" edition = "2021" @@ -13,9 +13,7 @@ env_logger = "0.10.0" version-compare = "0.1.0" clap = { version = "4.1.1", features = ["derive", "env"] } serde_yaml = "0.9.16" -tabled = "0.14.0" +tabled = "0.10.0" handlebars = "4.3.1" clap_complete = "4.0.6" -[dev-dependencies] -tempfile = "3.4.0" diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 61ba6f5..0000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM rust:1.70.0-alpine3.18 as builder -WORKDIR /src -RUN apk update && apk add --no-cache gcc musl-dev -COPY ./ . -RUN rustup default nightly && rustup update -RUN cargo build --release --jobs 2 -Z sparse-registry - -FROM alpine:3.18 -COPY --from=builder /src/target/release/cdh /bin/cdh -WORKDIR /workdir -ENTRYPOINT ["/bin/cdh"] diff --git a/Makefile b/Makefile deleted file mode 100644 index acf3e73..0000000 --- a/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -build: - cargo build --release diff --git a/README.md b/README.md index 1100173..a322e3e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Prebuilt binaries exist for **Linux x86_64** and **MacOS arm64** and **x86_64** Don't forget to add the binary to $PATH ```BASH -$ curl https://raw.githubusercontent.com/allanger/check-da-helm/main/scripts/download_cdh.sh | bash +$ curl https://raw.githubusercontent.com/allanger/check-da-helm/main/scripts/download_cdm.sh | bash $ cdm -h ``` diff --git a/dockerfiles/Dockerfile-argo b/dockerfiles/Dockerfile-argo deleted file mode 100644 index 7913916..0000000 --- a/dockerfiles/Dockerfile-argo +++ /dev/null @@ -1,12 +0,0 @@ -ARG BASE_VERSION=latest -FROM ghcr.io/allanger/dumb-downloader as builder -ARG ARGOCD_VERSION=v2.7.6 -ENV RUST_LOG=info -RUN mkdir /out -RUN dudo -l "https://github.com/argoproj/argo-cd/releases/download/{{ version }}/argocd-{{ os }}-{{ arch }}" -d /tmp/argocd -p $ARGOCD_VERSION -RUN mv /tmp/argocd /out/argocd && chmod +x /out/argocd - -FROM ghcr.io/allanger/check-da-helm-base:${BASE_VERSION} -COPY --from=builder /out/ /usr/bin -RUN apk update --no-cache && apk add --no-cache jq bash -ENTRYPOINT ["cdh"] diff --git a/dockerfiles/Dockerfile-helmfile b/dockerfiles/Dockerfile-helmfile deleted file mode 100644 index d2ad685..0000000 --- a/dockerfiles/Dockerfile-helmfile +++ /dev/null @@ -1,18 +0,0 @@ -ARG BASE_VERSION=latest -FROM ghcr.io/allanger/dumb-downloader as builder -RUN apt-get update -y && apt-get install tar -y -ARG HELM_VERSION=v3.12.1 -ARG HELMFILE_VERSION=0.154.0 -ENV RUST_LOG=info -RUN dudo -l "https://github.com/helmfile/helmfile/releases/download/v{{ version }}/helmfile_{{ version }}_{{ os }}_{{ arch }}.tar.gz" -d /tmp/helmfile.tar.gz -p $HELMFILE_VERSION -RUN dudo -l "https://get.helm.sh/helm-{{ version }}-{{ os }}-{{ arch }}.tar.gz" -d /tmp/helm.tar.gz -p $HELM_VERSION -RUN tar -xf /tmp/helm.tar.gz -C /tmp && rm -f /tmp/helm.tar.gz -RUN tar -xf /tmp/helmfile.tar.gz -C /tmp && rm -f /tmp/helmfile.tar.gz -RUN mkdir /out && for bin in `find /tmp | grep helm`; do cp $bin /out/; done -RUN chmod +x /out/helm -RUN chmod +x /out/helmfile - -FROM ghcr.io/allanger/check-da-helm-base:${BASE_VERSION} -COPY --from=builder /out/ /usr/bin -RUN apk update --no-cache && apk add --no-cache jq bash -ENTRYPOINT ["cdh"] diff --git a/dockerfiles/Dockerfile-helmfile-secrets b/dockerfiles/Dockerfile-helmfile-secrets deleted file mode 100644 index 633780a..0000000 --- a/dockerfiles/Dockerfile-helmfile-secrets +++ /dev/null @@ -1,24 +0,0 @@ -ARG BASE_VERSION=latest -FROM ghcr.io/allanger/dumb-downloader as builder -RUN apt-get update -y && apt-get install tar -y -ARG HELM_VERSION=v3.12.1 -ARG HELMFILE_VERSION=0.154.0 -ARG SOPS_VERSION=v3.7.3 -ENV RUST_LOG=info -RUN dudo -l "https://github.com/helmfile/helmfile/releases/download/v{{ version }}/helmfile_{{ version }}_{{ os }}_{{ arch }}.tar.gz" -d /tmp/helmfile.tar.gz -p $HELMFILE_VERSION -RUN dudo -l "https://get.helm.sh/helm-{{ version }}-{{ os }}-{{ arch }}.tar.gz" -d /tmp/helm.tar.gz -p $HELM_VERSION -RUN tar -xf /tmp/helm.tar.gz -C /tmp && rm -f /tmp/helm.tar.gz -RUN tar -xf /tmp/helmfile.tar.gz -C /tmp && rm -f /tmp/helmfile.tar.gz -RUN mkdir /out && for bin in `find /tmp | grep helm`; do cp $bin /out/; done -RUN chmod +x /out/helm -RUN chmod +x /out/helmfile -# Download SOPS -RUN dudo -l "https://github.com/mozilla/sops/releases/download/{{ version }}/sops-{{ version }}.{{ os }}.{{ arch }}" -d /out/sops -p $SOPS_VERSION -RUN chmod +x /out/sops - - -FROM ghcr.io/allanger/check-da-helm-base:${BASE_VERSION} -COPY --from=builder /out/ /usr/bin -RUN apk update --no-cache && apk add --no-cache jq bash age git musl -RUN helm plugin install https://github.com/jkroepke/helm-secrets --version v4.4.2 -ENTRYPOINT ["cdh"] diff --git a/examples/argocd/application.yaml b/examples/argocd/application.yaml deleted file mode 100644 index cd2cc2a..0000000 --- a/examples/argocd/application.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: sealed-secrets - namespace: argocd -spec: - project: default - source: - chart: argo-cd - repoURL: https://argoproj.github.io/argo-helm - targetRevision: 5.23.3 - helm: - releaseName: sealed-secrets - syncPolicy: - automated: {} - destination: - server: "https://kubernetes.default.svc" - namespace: argocd diff --git a/examples/helmfile.yaml b/examples/helmfile.yaml index b0f2095..be825ca 100644 --- a/examples/helmfile.yaml +++ b/examples/helmfile.yaml @@ -1,23 +1,14 @@ repositories: - - name: argo - url: https://argoproj.github.io/argo-helm - - name: bitnami - url: registry-1.docker.io/bitnamicharts - oci: true + - name: keel + url: https://charts.keel.sh releases: - - name: argocd + # ----------------------------- + # -- Keel + # ----------------------------- + - name: keel installed: true - namespace: argocd + namespace: keel-system createNamespace: true - chart: argo/argo-cd - version: 5.23.3 - values: - - server: - extraArgs: - - --insecure - - - name: redis - installed: true - chart: bitnami/redis - version: 17.13.1 + chart: keel/keel + version: 0.9.11 diff --git a/scripts/download_cdh.sh b/scripts/download_cdh.sh index 1211dfa..3d47749 100755 --- a/scripts/download_cdh.sh +++ b/scripts/download_cdh.sh @@ -33,7 +33,7 @@ case "$(uname)" in exit 1 ;; esac -LATEST_VERSION="v$(curl -s https://raw.githubusercontent.com/allanger/check-da-helm/main/Cargo.toml | awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2); exit}')" +LATEST_VERSION="v$(curl -s https://raw.githubusercontent.com/allanger/check-da-helm/main/Cargo.toml | awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }')" echo "Downloading $LATEST_VERSION" RELEASE_NAME=cdh-$LATEST_VERSION-$TARGET @@ -47,4 +47,4 @@ chmod +x cdh echo 'Make sure that cdh is in your $PATH' echo 'Try: ' echo ' $ export PATH=$PATH:$PWD' -echo ' $ cdh -h' +echo ' $ cdh -h' \ No newline at end of file diff --git a/scripts/download_for_arch.sh b/scripts/download_for_arch.sh deleted file mode 100755 index 09287e9..0000000 --- a/scripts/download_for_arch.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -case $(uname -m) in - "arm64"|"aarch64") - PLATFORM="arm64" - ;; - "x86_64") - PLATFORM="amd64" - ;; - *) - echo "Unsuported target" - exit 1 - ;; -esac -echo "Downloading $2 from $1" -curl -LJO $1 $2 diff --git a/src/connectors/argo.rs b/src/connectors/argo.rs index 3bc7fb9..ecd2ed0 100644 --- a/src/connectors/argo.rs +++ b/src/connectors/argo.rs @@ -15,7 +15,7 @@ impl Connector for Argo { type ConnectorType = Argo; fn get_app(&self) -> Result> { - let cmd: String = "argocd app list -o json | jq '[.[] | {chart: .spec.source.chart, version: .spec.source.targetRevision, name: .spec.source.helm.releaseName}]'".to_string(); + let cmd: String = "argocd app list -o json | jq '[.[] | {chart: .spec.source.chart, version: .spec.source.targetRevision}]'".to_string(); debug!("executing '${}'", cmd); let output = Command::new("bash") @@ -27,7 +27,7 @@ impl Connector for Argo { match from_str::>(Borrow::borrow(&helm_stdout)) { Ok(mut charts) => { - charts.iter_mut().for_each(|chart| {chart.chart = Some(format!("{}/{}", chart.chart.clone().unwrap(), chart.chart.clone().unwrap()))}); + charts.dedup(); Ok(charts) } Err(err) => Err(err.into()), diff --git a/src/connectors/helmfile.rs b/src/connectors/helmfile.rs index 4166e68..bae5885 100644 --- a/src/connectors/helmfile.rs +++ b/src/connectors/helmfile.rs @@ -8,15 +8,13 @@ use std::{borrow::Borrow, io::Result, process::Command}; pub(crate) struct Helmfile { path: String, - env: String, } impl Connector for Helmfile { fn get_app(&self) -> Result> { let cmd: String = format!( - "helmfile -f {} -e {} list --output json | jq '[.[] | {{chart: .chart, version: .version, name: .name}}]'", - self.path, - self.env + "helmfile -f {} list --output json | jq '[.[] | {{chart: .name, version: .version}}]'", + self.path ) .to_string(); @@ -37,7 +35,7 @@ impl Connector for Helmfile { } } fn sync_repos(&self) -> Result<()> { - let cmd: String = format!("helmfile -f {} -e {} repos", self.path, self.env); + let cmd: String = format!("helmfile -f {} sync", self.path); Command::new("bash") .arg("-c") .arg(cmd) @@ -48,48 +46,8 @@ impl Connector for Helmfile { type ConnectorType = Helmfile; } - impl Helmfile { - pub(crate) fn init(path: String, env: String) -> Self { - Self {path, env} - } -} - -#[cfg(test)] -mod tests { - use tempfile::NamedTempFile; - use std::io::Write; - use crate::connectors::{Helmfile, Connector}; - use crate::types; - - static HELMFILE_EXAMPLE: &str = "repositories:\n - - name: argo\n - url: https://argoproj.github.io/argo-helm\n -releases:\n - - name: argocd\n - installed: true\n - namespace: argocd\n - createNamespace: true\n - chart: argo/argo-cd\n - version: 5.23.3\n - values:\n - - server:\n - extraArgs:\n - - --insecure"; - - #[test] - fn test_helmfile() { - let mut file = NamedTempFile::new().unwrap(); - writeln!(file, "{}", HELMFILE_EXAMPLE.clone()).unwrap(); - let path = file.into_temp_path(); - let helmfile_app = Helmfile::init(path.to_string_lossy().to_string(), "default".to_string()).get_app().unwrap(); - let app = types::HelmChart{ - chart: Some("argo/argo-cd".to_string()), - name: Some("argocd".to_string()), - version: Some("5.23.3".to_string()), - }; - let apps: Vec = vec![app]; - assert_eq!(apps, helmfile_app); - path.close().unwrap(); + pub(crate) fn init(path: String) -> Self { + Self { path: path } } } diff --git a/src/main.rs b/src/main.rs index 360e3dc..2031a8f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use crate::types::{HelmChart, Status}; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] enum Kinds { Argo, - //Helm, + Helm, Helmfile, } @@ -43,18 +43,12 @@ struct Args { /// Path to the helmfile #[clap(short, long, value_parser, default_value = "./")] path: String, - /// Pass an environment to the helmfile - #[arg(long, required = false, default_value = "default")] - helmfile_environment: String, /// Should execution be failed if you have outdated charts #[clap(short, long, action, default_value_t = false, env = "OUTDATED_FAIL")] outdated_fail: bool, /// Set to true if you don't want to sync repositories #[clap(short, long, action, default_value_t = false)] no_sync: bool, - /// Set to true if you don't wante to see up-to-date charts in the output - #[clap(long, action, default_value_t = true)] - no_uptodate: bool } #[derive(Debug, Subcommand)] @@ -87,13 +81,20 @@ fn main() { env_logger::init(); let args = Args::parse(); let mut result: Vec = Vec::new(); - + + let charts = match args.kind { + Kinds::Argo => Argo::init().get_app(), + Kinds::Helm => Helm::init().get_app(), + Kinds::Helmfile => Helmfile::init(args.path.clone()).get_app(), + } + .unwrap(); + if !args.no_sync { info!("syncing helm repositories"); let res = match args.kind { Kinds::Argo => Argo::init().sync_repos(), - // Kinds::Helm => Helm::init().sync_repos(), - Kinds::Helmfile => Helmfile::init(args.path.clone(), args.helmfile_environment.clone()).sync_repos(), + Kinds::Helm => Helm::init().sync_repos(), + Kinds::Helmfile => Helmfile::init(args.path).sync_repos(), }; match res { Ok(_) => info!("helm repos are synced"), @@ -101,21 +102,13 @@ fn main() { } } - let charts = match args.kind { - Kinds::Argo => Argo::init().get_app(), - //Kinds::Helm => Helm::init().get_app(), - Kinds::Helmfile => Helmfile::init(args.path.clone(), args.helmfile_environment.clone()).get_app(), - } - .unwrap(); - charts.iter().for_each(|a| { - debug!("{:?}", a); check_chart(&mut result, a).unwrap(); }); // Parse the helmfile // Handling the result - match handle_result(&mut result, args.outdated_fail, args.output, args.no_uptodate) { + match handle_result(&result, args.outdated_fail, args.output) { Ok(result) => { if result { exit(1); @@ -129,9 +122,9 @@ fn main() { } fn check_chart(result: &mut Vec, local_chart: &types::HelmChart) -> Result<()> { - if local_chart.chart.is_some() { + if local_chart.name.is_some() { let version = local_chart.version.clone().unwrap(); - let chart = local_chart.chart.clone().unwrap(); + let chart = local_chart.name.clone().unwrap(); return match version.is_empty() { true => { warn!( @@ -143,8 +136,8 @@ fn check_chart(result: &mut Vec, local_chart: &types::HelmChart) -> false => { info!("checking {} - {}", chart, version); let cmd = format!( - "helm search repo {} --versions --output json", - chart, + "helm search repo {}/{} --versions --output json", + chart, chart ); debug!("executing '${}'", cmd); let output = Command::new("bash") @@ -157,8 +150,6 @@ fn check_chart(result: &mut Vec, local_chart: &types::HelmChart) -> // Remove "v" from version definitions let mut versions: Vec = from_str(helm_stdout.borrow()).unwrap(); versions.iter_mut().for_each(|f| { - f.name = local_chart.name.clone(); - f.chart = local_chart.chart.clone(); if f.version.is_some() { f.version = Some(f.version.as_ref().unwrap().replace('v', "")); } @@ -175,10 +166,8 @@ fn check_chart(result: &mut Vec, local_chart: &types::HelmChart) -> ); } let remote = Version::from(current_version.as_str()).unwrap(); - debug!("{:?}", versions); let status: Status = if versions.contains(&HelmChart { - chart: Some(chart.clone()), - name: local_chart.name.clone(), + name: Some(format!("{}/{}", chart.clone(), chart.clone())), version: Some(version.clone()), }) { match local.compare(remote.clone()) { @@ -192,7 +181,6 @@ fn check_chart(result: &mut Vec, local_chart: &types::HelmChart) -> }; result.push(ExecResult::new( - local_chart.name.clone().unwrap(), chart.clone(), current_version.clone(), version.clone(), @@ -209,32 +197,28 @@ fn check_chart(result: &mut Vec, local_chart: &types::HelmChart) -> /// Handle result fn handle_result( - result: &mut Vec, + result: &Vec, outdated_fail: bool, output_kind: Outputs, - no_uptodate: bool, ) -> Result { let mut failed = false; - if no_uptodate { - result.retain(|r| r.status != types::Status::Uptodate) - } for r in result.clone() { match r.status { - Status::Uptodate => info!("{} is up-to-date", r.chart), + Status::Uptodate => info!("{} is up-to-date", r.name), Status::Outdated => { if outdated_fail { failed = true } warn!( "{} is outdated. Current version is {}, but the latest is {}", - r.chart, r.current_version, r.latest_version + r.name, r.current_version, r.latest_version ); } Status::Missing => { failed = true; error!( "{} is broken. Current version is {}, but it can't be found in the repo", - r.chart, r.current_version + r.name, r.current_version ); } } diff --git a/src/types/mod.rs b/src/types/mod.rs index 254f160..eaf52b4 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -5,10 +5,8 @@ use tabled::Tabled; /// Struct for parsing charts info from helmfile #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] pub(crate) struct HelmChart { - // #[serde(alias = "name", alias = "chart")] + #[serde(alias = "name", alias = "chart")] pub(crate) name: Option, - // #[serde(alias = "name", alias = "chart")] - pub(crate) chart: Option, pub(crate) version: Option, } @@ -18,7 +16,7 @@ pub(crate) struct HelmRepo { pub(crate) url: String, } -#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Clone, Serialize, Deserialize)] pub(crate) enum Status { Uptodate, Outdated, @@ -38,23 +36,15 @@ impl fmt::Display for Status { #[derive(Clone, Tabled, Serialize, Deserialize)] pub(crate) struct ExecResult { pub(crate) name: String, - pub(crate) chart: String, pub(crate) latest_version: String, pub(crate) current_version: String, pub(crate) status: Status, } impl ExecResult { - pub(crate) fn new( - name: String, - chart: String, - latest_version: String, - current_version: String, - status: Status, - ) -> Self { + pub(crate) fn new(name: String, latest_version: String, current_version: String, status: Status) -> Self { Self { name, - chart, latest_version, current_version, status,