Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Add image_aliases and hook script support #9

Merged
merged 2 commits into from
Aug 27, 2020
Merged

Add image_aliases and hook script support #9

merged 2 commits into from
Aug 27, 2020

Conversation

rnorth
Copy link
Member

@rnorth rnorth commented Aug 26, 2020

This is intended to provide a crude solution to testcontainers/testcontainers-java#3099 for teams using Drone CI.

It allows users to specify a set of images that should be pulled and retagged, and exposes a hook script mechanism so that more custom implementations can be developed.

Note that I believe testcontainers/testcontainers-java#3102 is by far the better solution, but I believe this provides another option for Drone users who cannot use that approach.

Example usage from README:

pipeline:
  build:
    image: quay.io/testcontainers/dind-drone-plugin
    build_image: openjdk:8-jdk-alpine
    cmd: ./gradlew clean check --info

    # Not mandatory; sets up image name 'aliases' by pulling from one registry and tagging
    #  as a different name. Intended as a simplistic mechanism for using a private registry 
    #  rather than Docker Hub for a known set of images. Accepts a dictionary of
    #  private registry image name to the Docker Hub image that it is a substitute for.
    #  Note that all images are pulled synchronously before the build starts, so this is
    #  inefficient if any unnecessary images are listed.
    image_aliases:
      someregistry.com/redis:4.0.6: redis:4.0.6

@@ -0,0 +1,7 @@
#!/bin/bash

echo $PLUGIN_IMAGE_ALIASES | jq -r 'to_entries[] | [.key, .value] | @tsv' | while read ORIGINAL NEW; do
Copy link

@gjtempleton gjtempleton Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since I did drone plugin dev work, does Drone inject the dict variables as JSON formatted text for the env var? (I did try digging through the Drone docs and couldn't see any mention of how this is handled.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed to demo the answer to my own question, it does indeed.

Copy link
Member Author

@rnorth rnorth Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's weirdly inconsistent about it though:

  • for a single value drone parameter, it comes through as a single plain env var
  • for a list parameter, it comes through comma-separated (with no usable escaping AFAICT 😱)
  • for a dict parameter, it comes as a JSON dict

I honestly have no idea why, but it is what it is 🤷‍♂️

Copy link

@gjtempleton gjtempleton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rnorth
Copy link
Member Author

rnorth commented Aug 27, 2020

Thanks @gjtempleton

@rnorth rnorth merged commit 65fbbf9 into master Aug 27, 2020
@rnorth rnorth deleted the hook-scripts branch August 27, 2020 12:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants