diff --git a/README.md b/README.md index bfd3cf3..8af987f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ score-compose init --provisioners https://raw.githubusercontent.com/score-spec/c | 10-dns-with-url.provisioners.yaml | `dns` | (any) | (none) | `host`, `url` | Outputs a `*.localhost` domain as the hostname and associated URL in http on port `8080`. | 10-endpoint-with-microcks.provisioners.yaml | `endpoint` | (any) | `port`, `openapi_file`, `openapi_title` | `url` | Outputs an endpoint URL for connecting to an other workload (a Microcks mock is generated if not found). | 10-env.provisioners.yaml | `environment` | (any) | (none) | (none) | Loads environment variables from a local `.env` file. +| 10-gcp-pubsub-emulator.provisioners.yaml | `gcp-pubsub-emulator` | (any) | `project_id` | `host`, `port`, `project_id`, `emulator_host` | Generates a Google Cloud Pub/Sub Emulator service for local development. | 10-hpa.provisioners.yaml | `horizontal-pod-autoscaler` | (any) | (none) | (none) | Generates an empty object because HPA is not supported in Docker Compose. | 10-dmr-llm-model-via-curl-cmd.provisioners.yaml | `llm-model` | (any) | `model` | `model`, `url`, `api-key` | Runs `curl` to download the model with the Docker Model Runner (DMR). | 10-dmr-llm-model-via-curl-service.provisioners.yaml | `llm-model` | (any) | `model` | `model`, `url`, `api-key` | Generates a `curl` service downloading the model with the Docker Model Runner (DMR). diff --git a/gcp-pubsub-emulator/score-compose/10-gcp-pubsub-emulator.provisioners.yaml b/gcp-pubsub-emulator/score-compose/10-gcp-pubsub-emulator.provisioners.yaml new file mode 100644 index 0000000..457382a --- /dev/null +++ b/gcp-pubsub-emulator/score-compose/10-gcp-pubsub-emulator.provisioners.yaml @@ -0,0 +1,40 @@ +# GCP Pub/Sub Emulator provisioner +# For local development and testing without connecting to real GCP +- uri: template://community-provisioners/gcp-pubsub-emulator + type: gcp-pubsub-emulator + description: Generates a Google Cloud Pub/Sub Emulator service for local development. + supported_params: + - project_id + init: | + port: 8085 + randomServiceName: pubsub-emulator-{{ randAlphaNum 6 | lower }} + defaultProjectId: test-project-{{ randAlphaNum 6 | lower }} + state: | + serviceName: {{ dig "serviceName" .Init.randomServiceName .State | quote }} + projectId: {{ dig "projectId" (.Params.project_id | default .Init.defaultProjectId) .State | quote }} + outputs: | + host: {{ .State.serviceName }} + port: {{ .Init.port }} + project_id: {{ .State.projectId }} + emulator_host: {{ .State.serviceName }}:{{ .Init.port }} + expected_outputs: + - host + - port + - project_id + - emulator_host + services: | + {{ .State.serviceName }}: + labels: + dev.score.compose.res.uid: {{ .Uid }} + image: gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators + command: + - gcloud + - beta + - emulators + - pubsub + - start + - --host-port=0.0.0.0:{{ .Init.port }} + - --project={{ .State.projectId }} + restart: always + info_logs: | + - "{{ .Uid }}: Pub/Sub Emulator is running at {{ .State.serviceName }}:{{ .Init.port }}" diff --git a/gcp-pubsub-emulator/score.yaml b/gcp-pubsub-emulator/score.yaml new file mode 100644 index 0000000..e9abaa0 --- /dev/null +++ b/gcp-pubsub-emulator/score.yaml @@ -0,0 +1,18 @@ +apiVersion: score.dev/v1b1 +metadata: + name: my-workload +containers: + my-container: + image: busybox + command: ["/bin/sh"] + args: ["-c", "while true; do echo $PUBSUB_EMULATOR_HOST; sleep 5; done"] + variables: + PUBSUB_HOST: "${resources.pubsub.host}" + PUBSUB_PORT: "${resources.pubsub.port}" + PUBSUB_PROJECT_ID: "${resources.pubsub.project_id}" + PUBSUB_EMULATOR_HOST: "${resources.pubsub.emulator_host}" +resources: + pubsub: + type: gcp-pubsub-emulator + params: + project_id: my-test-project