Skip to content

Commit 05bfad4

Browse files
committed
Updated workflows to use Pulp CLI
fixes: #8364 https://pulp.plan.io/issues/8364
1 parent 3bbaa8c commit 05bfad4

22 files changed

Lines changed: 216 additions & 327 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env sh
2+
3+
export BASE_ADDR=http://pulp:80
4+
export CONTENT_ADDR=http://pulp:80
5+
6+
cd docs/_scripts/
7+
bash ./quickstart.sh

CHANGES/8364.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated workflows to use Pulp CLI commands

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ pulp_python
77

88
A Pulp plugin to support hosting your own pip compatible Python packages.
99

10-
For more information, please see the [documentation](https://pulp-python.readthedocs.io/en/latest/) or the [Pulp project page](
11-
(https://pulpproject.org>).
10+
For more information, please see the [documentation](https://pulp-python.readthedocs.io/en/latest/) or the
11+
[Pulp project page](https://pulpproject.org).

docs/_scripts/add_content_repo.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
# Add created PythonPackage content to repository
2-
echo "Add created Python Package to repository"
3-
export TASK_URL=$(http POST $BASE_ADDR$REPO_HREF'modify/' \
4-
add_content_units:="[\"$PACKAGE_HREF\"]" | jq -r '.task')
5-
6-
# Poll the task (here we use a function defined in docs/_scripts/base.sh)
7-
wait_until_task_finished $BASE_ADDR$TASK_URL
2+
pulp python repository add --name foo --filename "shelf-reader-0.1.tar.gz"
83

94
# After the task is complete, it gives us a new repository version
10-
echo "Set REPOVERSION_HREF from finished task."
11-
export REPOVERSION_HREF_WITH_PKG=$(http $BASE_ADDR$TASK_URL| jq -r '.created_resources | first')
12-
13-
echo "Inspecting RepositoryVersion."
14-
http $BASE_ADDR$REPOVERSION_HREF_WITH_PKG
5+
pulp python repository version show --repository foo

docs/_scripts/artifact.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# Get a Python package or choose your own
2-
curl -O https://repos.fedorapeople.org/pulp/pulp/fixtures/python-pypi/packages/shelf-reader-0.1.tar.gz
2+
curl -O https://fixtures.pulpproject.org/python-pypi/packages/shelf-reader-0.1.tar.gz
33
export PKG="shelf-reader-0.1.tar.gz"
44

5-
# Upload it as an Artifact
6-
echo "Upload a Python Package"
7-
export ARTIFACT_HREF=$(http --form POST $BASE_ADDR/pulp/api/v3/artifacts/ \
8-
file@./$PKG | jq -r '.pulp_href')
9-
10-
echo "Inspecting artifact."
11-
http $BASE_ADDR$ARTIFACT_HREF
12-
5+
# Upload it to Pulp
6+
pulp python content upload --relative-path "$PKG" --file "$PKG"

docs/_scripts/base.sh

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,20 @@ export CONTENT_ADDR=${CONTENT_ADDR:-http://localhost:24816}
77
# Necessary for `django-admin`
88
export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
99

10-
# Poll a Pulp task until it is finished.
11-
wait_until_task_finished() {
12-
echo "Polling the task until it has reached a final state."
13-
local task_url=$1
14-
while true
15-
do
16-
local response=$(http $task_url)
17-
local state=$(jq -r .state <<< ${response})
18-
jq . <<< "${response}"
19-
case ${state} in
20-
failed|canceled)
21-
echo "Task in final state: ${state}"
22-
exit 1
23-
;;
24-
completed)
25-
echo "$task_url complete."
26-
break
27-
;;
28-
*)
29-
echo "Still waiting..."
30-
sleep 1
31-
;;
32-
esac
33-
done
34-
}
10+
# Install from source
11+
if [ -z "$(pip freeze | grep pulp-cli)" ]; then
12+
echo "Installing Pulp CLI"
13+
git clone https://github.com/pulp/pulp-cli.git
14+
cd pulp-cli
15+
pip install -e .
16+
cd ..
17+
fi
18+
19+
# Set up CLI config file
20+
mkdir ~/.config/pulp
21+
cat > ~/.config/pulp/settings.toml << EOF
22+
[cli]
23+
base_url = "$BASE_ADDR" # common to be localhost
24+
verify_ssl = false
25+
format = "json"
26+
EOF

docs/_scripts/clean.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
pstop
2-
pclean
3-
prestart
4-
pip uninstall -y shelf-reader
1+
if [ -n "$(pulp python repository list | grep foo)" ]; then
2+
pulp python repository destroy --name foo
3+
fi
4+
5+
if [ -n "$(pulp python remote list | grep foo)" ]; then
6+
pulp python remote destroy --name bar
7+
fi
8+
9+
if [ -n "$(pulp python publication list | grep pulp)" ]; then
10+
pulp python publication destroy --href "$(pulp python publication list | jq .[0].pulp_href)"
11+
fi
512

6-
echo "is shelf reader installed?"
7-
pip freeze | grep shelf-reader
13+
if [ -n "$(pulp python distribution list | grep foo)" ]; then
14+
pulp python distribution destroy --name foo
15+
fi
16+
17+
pulp orphans delete
18+
pip uninstall -y shelf-reader

docs/_scripts/distribution.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
# Distributions are created asynchronously. Create one, and specify the publication that will
22
# be served at the base path specified.
3-
export TASK_URL=$(http POST $BASE_ADDR/pulp/api/v3/distributions/python/pypi/ \
4-
name='baz' \
5-
base_path='foo' \
6-
publication=$PUBLICATION_HREF | jq -r '.task')
7-
8-
# Poll the task (here we use a function defined in docs/_scripts/base.sh)
9-
# When the task is complete, it gives us the href for our new Distribution
10-
wait_until_task_finished $BASE_ADDR$TASK_URL
11-
echo "Set DIST_PATH from finished task."
12-
export DIST_PATH=$(http $BASE_ADDR$TASK_URL| jq -r '.created_resources | first')
13-
14-
# Lets inspect the Distribution
15-
http $BASE_ADDR$DIST_PATH
3+
pulp python distribution create --name foo --base-path foo --publication "$PUBLICATION_HREF"

docs/_scripts/package.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/_scripts/pip.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
echo 'pip install --trusted-host localhost -i $CONTENT_ADDR/pulp/content/foo/simple/ shelf-reader'
2-
pip install --trusted-host localhost -i $CONTENT_ADDR/pulp/content/foo/simple/ shelf-reader
1+
echo 'pip install --trusted-host pulp -i $CONTENT_ADDR/pulp/content/foo/simple/ shelf-reader'
2+
pip install --trusted-host pulp -i $CONTENT_ADDR/pulp/content/foo/simple/ shelf-reader
33

44
echo "is shelf reader installed?"
5-
pip freeze | grep shelf-reader
5+
pip list | grep shelf-reader

0 commit comments

Comments
 (0)