Skip to content
Open
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
19 changes: 19 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,22 @@ generate-quay-api:
gofmt -w quay_api && \
cd quay_api && \
go mod tidy

# Update Quay API spec from a Quay instance
# This fetches the Swagger 2.0 spec from Quay and converts it to OpenAPI 3.0.1
# Prerequisites: podman (or docker), curl, jq
# Usage: make update-quay-api-spec QUAY_INSTANCE=https://quay.io
QUAY_INSTANCE ?= https://quay.io
.PHONY: update-quay-api-spec
update-quay-api-spec:
@echo "Starting swagger-converter..."
podman run -d --rm -p 8080:8080 --name swagger-converter docker.io/swaggerapi/swagger-converter:v1.0.5
@sleep 2
@echo "Converting Quay API spec from Swagger 2.0 to OpenAPI 3.0.1..."
curl --silent --data "$$(curl --silent --location $(QUAY_INSTANCE)/api/v1/discovery)" \
-H "Content-Type: application/json" \
http://localhost:8080/api/convert | \
jq 'del(.. | .security?) | del(.components.securitySchemes)' \
> code_generator/quay_api.json
podman stop swagger-converter
@echo "Done! quay_api.json updated from $(QUAY_INSTANCE)."
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,33 @@ export QUAY_TOKEN=""
make testacc
```

### Generate Quay API
### Update Quay API Spec
The Go API client is generated from an OpenAPI 3.0.1 specification stored in `code_generator/quay_api.json`. Quay instances expose their API spec in Swagger 2.0 format at `/api/v1/discovery`, so updating the spec requires fetching and converting it.

**Important:** Different Quay instances expose different API endpoints. Self-hosted Quay instances typically include superuser endpoints that are not available on quay.io. The current spec was generated from a self-hosted instance and the provider relies on these superuser endpoints for some operations (e.g., organization management).

**Prerequisites:** podman (or docker), curl, jq

To update the API spec from a Quay instance:
```bash
make update-quay-api-spec QUAY_INSTANCE=https://quay.example.com
```

This target:
1. Starts a swagger-converter container
2. Fetches the Swagger 2.0 spec from the Quay instance
3. Converts it to OpenAPI 3.0.1
4. Removes OAuth2 security definitions (not used by this provider)
5. Saves the result to `code_generator/quay_api.json`

After updating the spec, regenerate the Go client and verify the provider still builds:
```bash
make generate-quay-api
go build .
```

### Generate Quay API Client
Regenerate the Go client after spec changes:
```bash
make generate-quay-api
```
Loading
Loading