Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit 69e224e

Browse files
authored
Merge pull request #55 from joe0BAB/feat/api-client
feat: bundle secret management API client
2 parents 4e28003 + 974353c commit 69e224e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+9808
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@
2323
/docs/.hugo_build.lock
2424
/functions/memory/memory.json
2525
/log/
26+
.idea

src/extension/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ RUN --mount=type=cache,target=/usr/src/app/.npm \
1010
COPY ui /ui
1111
RUN npm run build
1212

13-
FROM alpine
13+
FROM scratch
14+
ARG TARGETARCH
1415
LABEL org.opencontainers.image.title="Labs: AI Tools for Devs" \
1516
org.opencontainers.image.description="MCP Tool Catalog" \
1617
org.opencontainers.image.vendor="Docker Inc" \
@@ -26,6 +27,9 @@ LABEL org.opencontainers.image.title="Labs: AI Tools for Devs" \
2627
COPY docker-compose.yaml .
2728
COPY metadata.json .
2829
COPY docker.svg /docker.svg
30+
COPY host-binary/dist/windows-${TARGETARCH}/host-binary.exe /windows/host-binary.exe
31+
COPY host-binary/dist/darwin-${TARGETARCH}/host-binary /darwin/host-binary
32+
COPY host-binary/dist/linux-${TARGETARCH}/host-binary /linux/host-binary
2933
COPY --from=client-builder /ui/build ui
3034

3135
CMD sleep 600

src/extension/Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ BUILDER=buildx-multi-arch
66
INFO_COLOR = \033[0;36m
77
NO_COLOR = \033[m
88

9-
build-extension: ## Build service image to be deployed as a desktop extension
10-
docker build --tag=$(IMAGE):$(TAG) .
9+
.PHONY: host-binary/bin
10+
bin:
11+
cd host-binary && $(MAKE) bin
12+
13+
cross:
14+
cd host-binary && $(MAKE) cross
15+
16+
build-extension: cross ## Build service image to be deployed as a desktop extension
17+
docker build --platform=linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64,windows/arm64 --tag=$(IMAGE):$(TAG) .
1118

1219
install-extension: build-extension ## Install the extension
1320
docker extension install $(IMAGE):$(TAG)
@@ -18,7 +25,7 @@ update-extension: build-extension ## Update the extension
1825
prepare-buildx: ## Create buildx builder for multi-arch build, if not exists
1926
docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host
2027

21-
push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1
28+
push-extension: prepare-buildx cross ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1
2229
docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) .
2330

2431
help: ## Show this help

src/extension/host-binary/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
dist

src/extension/host-binary/Makefile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
EXTENSION:=
2+
OPENAPI_GENERATOR_VERSION ?= v6.0.1
3+
DD_API_NAME=secrets
4+
DD_API_PKGNAME=api
5+
BINARY?=host-binary
6+
7+
8+
STATIC_FLAGS=CGO_ENABLED=0
9+
LDFLAGS="-s -w"
10+
GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
11+
12+
INFO_COLOR = \033[0;36m
13+
NO_COLOR = \033[m
14+
15+
.PHONY: bin
16+
bin: ## Build the binary for the current platform
17+
@echo "$(INFO_COLOR)Building...$(NO_COLOR)"
18+
$(GO_BUILD) -o bin/$(BINARY)$(EXTENSION) ./cmd
19+
20+
lint:
21+
golangci-lint run
22+
23+
format:
24+
go fmt ./...
25+
26+
27+
cross: ## Cross compile the server
28+
GOOS=linux GOARCH=amd64 $(GO_BUILD) -o dist/linux-amd64/$(BINARY) ./cmd
29+
GOOS=linux GOARCH=arm64 $(GO_BUILD) -o dist/linux-arm64/$(BINARY) ./cmd
30+
GOOS=darwin GOARCH=amd64 $(GO_BUILD) -o dist/darwin-amd64/$(BINARY) ./cmd
31+
GOOS=darwin GOARCH=arm64 $(GO_BUILD) -o dist/darwin-arm64/$(BINARY) ./cmd
32+
GOOS=windows GOARCH=amd64 $(GO_BUILD) -o dist/windows-amd64/$(BINARY).exe ./cmd
33+
GOOS=windows GOARCH=arm64 $(GO_BUILD) -o dist/windows-arm64/$(BINARY).exe ./cmd
34+
35+
package: ## package the server binaries
36+
tar -C dist/linux-amd64 -czf dist/$(BINARY)-linux-amd64.tar.gz $(BINARY)
37+
tar -C dist/linux-arm64 -czf dist/$(BINARY)-linux-arm64.tar.gz $(BINARY)
38+
tar -C dist/darwin-amd64 -czf dist/$(BINARY)-darwin-amd64.tar.gz $(BINARY)
39+
tar -C dist/darwin-arm64 -czf dist/$(BINARY)-darwin-arm64.tar.gz $(BINARY)
40+
tar -C dist/windows-amd64 -czf dist/$(BINARY)-windows-amd64.tar.gz $(BINARY).exe
41+
tar -C dist/windows-arm64 -czf dist/$(BINARY)-windows-arm64.tar.gz $(BINARY).exe
42+
43+
help: ## Show this help
44+
@echo Please specify a build target. The choices are:
45+
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}'
46+
47+
48+
49+
pre-gen-clients:
50+
rm -rf ./pkg/generated/go/client/$(DD_API_NAME)
51+
52+
gen-go-client:
53+
docker run --rm -w /local -e JAVA_OPTS='-Dlog.level=error' -v ${PWD}:/local openapitools/openapi-generator-cli:${OPENAPI_GENERATOR_VERSION} \
54+
generate -g go -i ./api/schemas/$(DD_API_NAME).yaml \
55+
-o ./pkg/generated/go/client/$(DD_API_NAME) \
56+
--http-user-agent "Docker Desktop API" \
57+
--additional-properties=packageName=$(DD_API_PKGNAME) \
58+
--additional-properties=enumClassPrefix=true \
59+
--additional-properties=generateInterfaces=true \
60+
--additional-properties=isGoSubmodule=false
61+
62+
gen-secrets-api-html:
63+
docker run --rm -w /local -e JAVA_OPTS='-Dlog.level=error' -v ${PWD}:/local openapitools/openapi-generator-cli:${OPENAPI_GENERATOR_VERSION} \
64+
generate -g html2 -i ./api/schemas/$(DD_API_NAME).yaml \
65+
-o ./pkg/generated/go/client/$(DD_API_NAME)/html
66+
67+
post-gen-go-client:
68+
rm -rf \
69+
./pkg/generated/go/client/$(DD_API_NAME)/.gitignore \
70+
./pkg/generated/go/client/$(DD_API_NAME)/.openapi-generator-ignore \
71+
./pkg/generated/go/client/$(DD_API_NAME)/.travis.yml \
72+
./pkg/generated/go/client/$(DD_API_NAME)/go.* \
73+
./pkg/generated/go/client/$(DD_API_NAME)/git_push.sh
74+
75+
generate: DD_API_NAME=secrets
76+
generate: DD_API_PKGNAME=secretsapi
77+
generate: pre-gen-clients gen-go-client gen-ts-client gen-secrets-api-html post-gen-go-client
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
plugins:
2+
- plugins/customRules.js
3+
rules:
4+
info-license-url:
5+
severity: error
6+
no-ambiguous-paths:
7+
severity: error
8+
no-invalid-media-type-examples:
9+
severity: error
10+
no-server-example.com:
11+
severity: error
12+
no-unused-components:
13+
severity: error
14+
operation-2xx-response:
15+
severity: error
16+
operation-operationId:
17+
severity: error
18+
no-enum-type-mismatch:
19+
severity: error
20+
no-example-value-and-externalValue:
21+
severity: error
22+
no-identical-paths:
23+
severity: error
24+
no-path-trailing-slash:
25+
severity: error
26+
no-server-trailing-slash:
27+
severity: error
28+
no-server-variables-empty-enum:
29+
severity: error
30+
no-undefined-server-variable:
31+
severity: error
32+
no-unresolved-refs:
33+
severity: error
34+
operation-operationId-unique:
35+
severity: error
36+
operation-operationId-url-safe:
37+
severity: error
38+
operation-parameters-unique:
39+
severity: error
40+
operation-summary:
41+
severity: error
42+
path-declaration-must-exist:
43+
severity: error
44+
path-not-include-query:
45+
severity: error
46+
path-parameters-defined:
47+
severity: error
48+
spec-components-invalid-map-name:
49+
severity: error
50+
spec:
51+
severity: error
52+
pinata/noAnonymousEnum:
53+
severity: error
54+
55+
# Disable rules
56+
operation-4xx-response:
57+
severity: off
58+
tag-description:
59+
severity: off
60+
no-empty-servers:
61+
severity: off
62+
info-license:
63+
severity: off
64+
security-defined:
65+
severity: off
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
openapi: 3.0.3
2+
info:
3+
version: 0.0.0
4+
title: Docker Desktop secrets API
5+
description: This Docker Desktop API manages user secrets to be injected in containers.
6+
x-redocly-package-name: secrets
7+
tags:
8+
- name: secrets
9+
paths:
10+
/secrets:
11+
post:
12+
summary: sets a secret value
13+
tags: [ secrets ]
14+
operationId: setJfsSecret
15+
requestBody:
16+
description: the secret to be set
17+
required: true
18+
content:
19+
application/json:
20+
schema:
21+
$ref: '#/components/schemas/Secret'
22+
responses:
23+
'200':
24+
description: success
25+
'500':
26+
description: unexpected error
27+
get:
28+
summary: lists all secrets
29+
tags: [ secrets ]
30+
operationId: listJfsSecrets
31+
responses:
32+
'200':
33+
description: success
34+
content:
35+
application/json:
36+
schema:
37+
type: array
38+
items:
39+
$ref: '#/components/schemas/StoredSecret'
40+
'500':
41+
description: unexpected error
42+
/secrets/{secret}:
43+
get:
44+
summary: checks if a secret exists
45+
tags: [ secrets ]
46+
operationId: getJfsSecret
47+
parameters:
48+
- name: secret
49+
required: true
50+
in: path
51+
schema:
52+
type: string
53+
responses:
54+
'200':
55+
description: success
56+
content:
57+
application/json:
58+
schema:
59+
$ref: '#/components/schemas/StoredSecret'
60+
'404':
61+
description: secret not found
62+
delete:
63+
summary: deletes a secret
64+
tags: [ secrets ]
65+
operationId: deleteJfsSecret
66+
parameters:
67+
- name: secret
68+
required: true
69+
in: path
70+
schema:
71+
type: string
72+
responses:
73+
'200':
74+
description: success
75+
'500':
76+
description: unexpected error
77+
/policies:
78+
post:
79+
summary: sets the policy
80+
tags: [ secrets ]
81+
operationId: setJfsPolicy
82+
requestBody:
83+
description: the policy to be set
84+
required: true
85+
content:
86+
application/json:
87+
schema:
88+
$ref: '#/components/schemas/Policy'
89+
responses:
90+
'200':
91+
description: success
92+
'500':
93+
description: unexpected error
94+
get:
95+
summary: lists all policies
96+
tags: [ secrets ]
97+
operationId: listJfsPolicies
98+
responses:
99+
'200':
100+
description: success
101+
content:
102+
application/json:
103+
schema:
104+
type: array
105+
items:
106+
$ref: '#/components/schemas/Policy'
107+
'500':
108+
description: unexpected error
109+
/policies/{policy}:
110+
get:
111+
summary: retrieves a policy
112+
tags: [ secrets ]
113+
operationId: getJfsPolicy
114+
parameters:
115+
- name: policy
116+
required: true
117+
in: path
118+
schema:
119+
type: string
120+
responses:
121+
'200':
122+
description: success
123+
content:
124+
application/json:
125+
schema:
126+
$ref: '#/components/schemas/Policy'
127+
'404':
128+
description: policy not found
129+
delete:
130+
summary: deletes a policy
131+
tags: [ secrets ]
132+
operationId: deleteJfsPolicy
133+
parameters:
134+
- name: policy
135+
required: true
136+
in: path
137+
schema:
138+
type: string
139+
responses:
140+
'200':
141+
description: success
142+
'500':
143+
description: unexpected error
144+
components:
145+
schemas:
146+
Secret:
147+
type: object
148+
properties:
149+
name:
150+
type: string
151+
description: the name of the secret
152+
value:
153+
type: string
154+
description: the value of the secret
155+
policies:
156+
type: array
157+
items:
158+
type: string
159+
description: the list of policy names associated with the secret
160+
required:
161+
- name
162+
- value
163+
StoredSecret:
164+
type: object
165+
properties:
166+
name:
167+
type: string
168+
description: the name of the secret
169+
policies:
170+
type: array
171+
items:
172+
type: string
173+
description: the list of policy names associated with the secret
174+
required:
175+
- name
176+
- policies
177+
Policy:
178+
type: object
179+
properties:
180+
name:
181+
type: string
182+
description: the name of the policy
183+
images:
184+
type: array
185+
items:
186+
type: string
187+
description: the list of images allowed by the policy
188+
required:
189+
- name

0 commit comments

Comments
 (0)