Created
November 27, 2018 14:27
-
-
Save akofink/1b43205ef02aef76cf4912533a2e458a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
(which http > /dev/null && which jq > /dev/null) || exit | |
PAV3=pulp/api/v3 | |
DEBUG=${DEBUG-false} | |
FILE=${FILE-/tmp/file.txt} | |
SHA256SUM=${SHA256SUM-$(sha256sum $FILE | awk '{print $1}')} | |
REPO=${REPO-files} | |
PUBLISHER=${PUBLISHER-txt} | |
PUBLISHER_TYPE=${PUBLISHER_TYPE-file} | |
SRV=${SRV-centos7-pulp3-source.virbr0.akofink-desktop} | |
AUTH=${AUTH-admin:password} | |
REPO_HREF=$(http -a $AUTH GET $SRV/$PAV3/repositories/ name==$REPO | jq -re ".results[] | select(.name == \"$REPO\")._href" || | |
http -a $AUTH POST $SRV/$PAV3/repositories/ name=$REPO | jq -r '._href') | |
$DEBUG && echo $REPO_HREF | |
ARTIFACT_HREF=$(http -a $AUTH GET $SRV/$PAV3/artifacts/ sha256==$SHA256SUM | jq -re ".results[] | select(.sha256 == \"$SHA256SUM\")._href" || | |
http --form -a $AUTH POST $SRV/$PAV3/artifacts/ file@$FILE | jq -r '._href') | |
$DEBUG && echo $ARTIFACT_HREF | |
CONTENT_HREF=$(http -a $AUTH GET $SRV/$PAV3/content/file/files/ artifact==$ARTIFACT_HREF | jq -re ".results[] | select(.artifact == \"$ARTIFACT_HREF\")._href" || | |
http -a $AUTH POST $SRV/$PAV3/content/file/files/ relative_path=$(basename $FILE) artifact=$ARTIFACT_HREF | jq -r '._href') | |
$DEBUG && echo $CONTENT_HREF | |
PUBLISHER_HREF=$(http -a $AUTH GET $SRV/$PAV3/publishers/$PUBLISHER_TYPE/ name==$PUBLISHER | jq -re ".results[] | select(.name == \"$PUBLISHER\")._href" || | |
http -a $AUTH POST $SRV/$PAV3/publishers/$PUBLISHER_TYPE/ name=$PUBLISHER | jq -r '._href') | |
$DEBUG && echo $PUBLISHER_HREF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment