|
| 1 | +#!/bin/bash |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | + |
| 19 | +set -e |
| 20 | + |
| 21 | +CONTAINER_NAME="pyiceberg-polaris" |
| 22 | +BOOTSTRAP_FILE="dev/polaris-bootstrap.yaml" |
| 23 | +# Map local bootstrap file into the container |
| 24 | +# Actually, it's easier to just pipe it or use docker cp if needed, |
| 25 | +# but we can also just run the command from outside if the CLI is available locally. |
| 26 | +# The user said "don't need to uv pip install polaris... that's what the docker stuff is for" |
| 27 | +# This implies we should run the polaris command INSIDE the docker container. |
| 28 | + |
| 29 | +echo "Applying Polaris bootstrap configuration..." |
| 30 | +# We need to get the file into the container or use a command that can read from stdin if supported. |
| 31 | +# Assuming we can cat it to the container. |
| 32 | +docker cp $BOOTSTRAP_FILE $CONTAINER_NAME:/tmp/polaris-bootstrap.yaml |
| 33 | + |
| 34 | +docker exec $CONTAINER_NAME polaris \ |
| 35 | + --host localhost \ |
| 36 | + --port 8181 \ |
| 37 | + --client-id root \ |
| 38 | + --client-secret s3cr3t \ |
| 39 | + setup apply /tmp/polaris-bootstrap.yaml |
| 40 | + |
| 41 | +echo "Rotating credentials for pyiceberg_principal..." |
| 42 | +CREDS_JSON=$(docker exec $CONTAINER_NAME polaris \ |
| 43 | + --host localhost \ |
| 44 | + --port 8181 \ |
| 45 | + --client-id root \ |
| 46 | + --client-secret s3cr3t \ |
| 47 | + principals rotate-credentials pyiceberg_principal) |
| 48 | + |
| 49 | +# Extract CLIENT_ID and CLIENT_SECRET using python (since it's already a dependency) |
| 50 | +CLIENT_ID=$(echo $CREDS_JSON | python3 -c "import sys, json; print(json.load(sys.stdin)['clientId'])") |
| 51 | +CLIENT_SECRET=$(echo $CREDS_JSON | python3 -c "import sys, json; print(json.load(sys.stdin)['clientSecret'])") |
| 52 | + |
| 53 | +echo "CLIENT_ID=$CLIENT_ID" |
| 54 | +echo "CLIENT_SECRET=$CLIENT_SECRET" |
0 commit comments