Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove development azurite keys #235

Merged
merged 13 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
tenant-id: ${{ fromJSON(secrets.SECURE_AZURE_CREDENTIALS).tenantId }}
subscription-id: ${{ fromJSON(secrets.SECURE_AZURE_CREDENTIALS).subscriptionId }}

- name: Set Azurite Default Key
run: |
echo "AZURITE_ACCOUNT_KEY=${{ secrets.AZURITE_ACCOUNT_KEY }}" >> $GITHUB_ENV
echo "Using Azurite default key: $AZURITE_ACCOUNT_KEY"

- name: Authenticate
run: ./scripts/ciauthenticate

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set Azurite Default Key
run: |
echo "AZURITE_ACCOUNT_KEY=${{ secrets.AZURITE_ACCOUNT_KEY }}" >> $GITHUB_ENV
echo "Using Azurite default key: $AZURITE_ACCOUNT_KEY"

- name: Run cibuild
run: ./scripts/cibuild

Expand All @@ -22,5 +27,11 @@ jobs:
with:
python-version: "3.10" # stac-api-validator requires >= 3.10
cache: "pip"

- name: Set Azurite Default Key
run: |
echo "AZURITE_ACCOUNT_KEY=${{ secrets.AZURITE_ACCOUNT_KEY }}" >> $GITHUB_ENV
echo "Using Azurite default key: $AZURITE_ACCOUNT_KEY"

- name: Validate
run: ./scripts/validate
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ This project uses a variation on [scripts to rule them all](https://github.com/g

#### Environment setup and building images

Before setting up the local environment, ensure that you have set the AZURITE_ACCOUNT_KEY environment variable.
The account key can be found in the [Azurite GitHub repository](https://github.com/Azure/Azurite?tab=readme-ov-file#usage-with-azure-storage-sdks-or-tools)

For example, you can set the environment variable in your terminal with:
```console
> export AZURITE_ACCOUNT_KEY=<azurite_account_key>
```

To set up a local environment, use

```console
Expand Down
14 changes: 8 additions & 6 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ services:
- TILER_HREF=http://localhost:8080/data/

# Azure Storage
- AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__TABLE_NAME=collectionconfig

- PCAPIS_CONTAINER_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_CONTAINER_CONFIG__TABLE_NAME=containerconfig

- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_IP_EXCEPTION_CONFIG__TABLE_NAME=ipexceptionlist

# Redis
Expand Down Expand Up @@ -92,19 +93,20 @@ services:
- WORKERS_PER_CORE=1

# Azure Storage
- AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__TABLE_NAME=collectionconfig

- PCAPIS_CONTAINER_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_CONTAINER_CONFIG__TABLE_NAME=containerconfig

- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_IP_EXCEPTION_CONFIG__TABLE_NAME=ipexceptionlist

# Redis
Expand Down
11 changes: 5 additions & 6 deletions pc-funcs.dev.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
AzureWebJobsStorage=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1;
WEBSITE_HOSTNAME=funcs:8083

ANIMATION_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/animations"
ANIMATION_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

ANIMATION_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1"
ANIMATION_TILE_REQUEST_CONCURRENCY=2

IMAGE_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/images"
IMAGE_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

IMAGE_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1"
IMAGE_TILE_REQUEST_CONCURRENCY=2

STORAGE_ACCOUNT_URL=https://pctapisstagingsa.table.core.windows.net/
BANNED_IP_TABLE=blobstoragebannedip
LOG_ANALYTICS_WORKSPACE_ID=78d48390-b6bb-49a9-b7fd-a86f6522e9c4
LOG_ANALYTICS_WORKSPACE_ID=78d48390-b6bb-49a9-b7fd-a86f6522e9c4

AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
1 change: 1 addition & 0 deletions pc-stac.dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WEB_CONCURRENCY=1
USE_API_HYDRATE=TRUE

# Azure Storage
AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
PCAPIS_COLLECTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
PCAPIS_COLLECTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
PCAPIS_COLLECTION_CONFIG__TABLE_NAME=collectionconfig
Expand Down
7 changes: 3 additions & 4 deletions pccommon/pccommon/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from opencensus.trace.attributes_helper import COMMON_ATTRIBUTES

DEFAULT_COLLECTION_CONFIG_TABLE_NAME = "collectionconfig"
Expand Down Expand Up @@ -34,7 +36,4 @@
# This is the Azurite storage account key.
# This is not a key for a real Storage Account and is publicly accessible
# on Azurite's GitHub repo. This is used only in development.
AZURITE_ACCOUNT_KEY = (
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUz"
"FT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
)
AZURITE_ACCOUNT_KEY: str = os.environ.get("AZURITE_ACCOUNT_KEY", "")
5 changes: 3 additions & 2 deletions pcfuncs/tests/ipban/test_ipban.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from ipban.models import UpdateBannedIPTask
from pytest_mock import MockerFixture

from pccommon.constants import AZURITE_ACCOUNT_KEY

MOCK_LOGS_QUERY_RESULT = [("192.168.1.1", 8000), ("192.168.1.4", 12000)]
TEST_ID = str(uuid.uuid4()).replace("-", "") # dash is not allowed in table name
TEST_BANNED_IP_TABLE = f"testblobstoragebannedip{TEST_ID}"
Expand Down Expand Up @@ -58,8 +60,7 @@ def mock_clients(
logs_query_client.query_workspace.return_value = mock_response
CONNECTION_STRING: str = (
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;"
"AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsu"
"Fq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;"
f"AccountKey={AZURITE_ACCOUNT_KEY};"
"TableEndpoint=http://azurite:10002/devstoreaccount1;"
)

Expand Down
5 changes: 2 additions & 3 deletions scripts/bin/setup_azurite.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pccommon.config.collections import CollectionConfig, CollectionConfigTable
from pccommon.config.containers import ContainerConfig, ContainerConfigTable
from pccommon.constants import (
AZURITE_ACCOUNT_KEY,
DEFAULT_COLLECTION_CONFIG_TABLE_NAME,
DEFAULT_CONTAINER_CONFIG_TABLE_NAME,
DEFAULT_IP_EXCEPTION_CONFIG_TABLE_NAME,
Expand All @@ -27,9 +28,7 @@

AZURITE_CONNECT_STRING = (
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;"
"AccountKey="
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq"
"/K1SZFPTOtr/KBHBeksoGMGw==;"
f"AccountKey={AZURITE_ACCOUNT_KEY};"
"BlobEndpoint=http://azurite:10000/devstoreaccount1;"
"QueueEndpoint=http://azurite:10001/devstoreaccount1;"
"TableEndpoint=http://azurite:10002/devstoreaccount1;"
Expand Down
2 changes: 1 addition & 1 deletion scripts/cideploy
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ while [[ "$#" -gt 0 ]]; do case $1 in
;;
esac done

DOCKER_COMPOSE="docker-compose -f deployment/docker-compose.yml"
DOCKER_COMPOSE="docker compose -f deployment/docker-compose.yml"

# Set terraform to deploy to dev or staging
if [ "${DEV_DEPLOY}" = "1" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/cipublish-func
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ while [[ "$#" -gt 0 ]]; do case $1 in
;;
esac done

DOCKER_COMPOSE="docker-compose -f deployment/docker-compose.yml"
DOCKER_COMPOSE="docker compose -f deployment/docker-compose.yml"

# Set terraform to deploy to dev or staging
if [[ "${CI}" != "true" ]]; then
Expand Down
10 changes: 5 additions & 5 deletions scripts/console
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ while [[ "$#" > 0 ]]; do case $1 in
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

if [[ "${DB_CONSOLE}" ]]; then
docker-compose \
docker compose \
-f docker-compose.yml \
exec database psql postgres://username:password@database:5432/postgis

exit 0
fi

if [[ "${DEV_TILER_CONSOLE}" ]]; then
docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
Expand All @@ -75,7 +75,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
fi

if [[ "${FUNCS_CONSOLE}" ]]; then
docker-compose \
docker compose \
-f docker-compose.yml \
run --rm \
funcs /bin/bash
Expand All @@ -84,7 +84,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
fi

if [[ "${DEPLOY_CONSOLE}" ]]; then
GIT_COMMIT="$(git rev-parse --short HEAD)" docker-compose \
GIT_COMMIT="$(git rev-parse --short HEAD)" docker compose \
-f deployment/docker-compose.yml \
run --rm \
deploy /bin/bash
Expand All @@ -93,7 +93,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
fi

if [[ "${DEV_STAC_CONSOLE}" ]]; then
docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
Expand Down
10 changes: 5 additions & 5 deletions scripts/format
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ Runs formatting for the project.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
stac-dev scripts/bin/format-common;

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
tiler-dev scripts/bin/format-tiler;

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
stac-dev scripts/bin/format-stac;

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
funcs /bin/bash -c "cd /opt/src && scripts/bin/format-funcs";

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
Expand Down
8 changes: 4 additions & 4 deletions scripts/generate-requirements
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ set -e
echo "== Generating requirements.txt ..."
pip_compile_options="--emit-index-url --annotate --verbose"

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
stac-dev \
pip-compile ./pcstac/setup.py --extra server -o pcstac/requirements-server.txt $pip_compile_options

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
tiler-dev \
pip-compile ./pctiler/setup.py --extra server -o pctiler/requirements-server.txt $pip_compile_options

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
tiler-dev \
pip-compile ./pctiler/setup.py --extra dev -o pctiler/requirements-dev.txt $pip_compile_options

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
Expand Down
2 changes: 1 addition & 1 deletion scripts/migrate
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Run migrations against the development database.
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

# Run database migrations
docker-compose \
docker compose \
-f docker-compose.yml \
run --rm stac \
bash -c "pypgstac pgready && pypgstac migrate"
Expand Down
2 changes: 1 addition & 1 deletion scripts/server
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ while [[ "$#" > 0 ]]; do case $1 in
esac; done

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker-compose \
docker compose \
-f docker-compose.yml \
up ${DETACHED_ARG} $@;
fi
4 changes: 2 additions & 2 deletions scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

echo "Ingesting development data..."

docker-compose \
docker compose \
-f docker-compose.yml \
run --rm \
stac \
python3 /opt/src/pcstac/tests/loadtestdata.py

echo "Setting up azurite..."

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
Expand Down
8 changes: 4 additions & 4 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

if [ -z "${TILER_ONLY}${STAC_ONLY}${FUNCS_ONLY}" ]; then

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
stac-dev scripts/bin/test-common
fi

if [ -z "${STAC_ONLY}${COMMON_ONLY}${FUNCS_ONLY}" ]; then
docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
Expand All @@ -82,7 +82,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

if [ -z "${TILER_ONLY}${COMMON_ONLY}${FUNCS_ONLY}" ]; then

docker-compose \
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
Expand All @@ -91,7 +91,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

if [ -z "${STAC_ONLY}${TILER_ONLY}${COMMON_ONLY}" ]; then

docker-compose \
docker compose \
-f docker-compose.yml \
run --rm \
funcs /bin/bash -c "cd /opt/src && scripts/bin/test-funcs ${NO_INTEGRATION}"
Expand Down
Loading
Loading