create-manifests.sh 854 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. ARGUMENT_LIST=(
  3. "target-image"
  4. "tags"
  5. "source-manifests"
  6. )
  7. # read arguments
  8. opts=$(getopt \
  9. --longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")" \
  10. --name "$(basename "$0")" \
  11. --options "" \
  12. -- "$@"
  13. )
  14. eval set --$opts
  15. while [[ $# -gt 0 ]]; do
  16. case "$1" in
  17. --source-manifests)
  18. sourceManifests=$2
  19. shift 2
  20. ;;
  21. --target-image)
  22. targetImage=$2
  23. shift 2
  24. ;;
  25. --tags)
  26. tags=$2
  27. shift 2
  28. ;;
  29. *)
  30. break
  31. ;;
  32. esac
  33. done
  34. for tag in $(echo $tags | tr "," "\n")
  35. do
  36. tag=`echo $tag | awk '{gsub(/ /,""); print}'`
  37. echo "docker manifest create $targetImage:$tag $sourceManifests"
  38. eval "docker manifest create $targetImage:$tag $sourceManifests"
  39. echo "docker manifest push $targetImage:$tag"
  40. eval "docker manifest push $targetImage:$tag"
  41. done