feat: upload endpoint POST /v1/namespaces/{ns}/functions/{name}/upload
- s3/client.go: Bucket() accessor + UploadContext() для tar.gz build context
- handler/upload.go: принимает zip, генерирует Dockerfile (FROM naeel/sless-runtime-{runtime}),
перепаковывает в tar.gz, загружает в S3, обновляет Function CRD → kaniko запускается
- router.go: маршрут POST .../upload зарегистрирован
This commit is contained in:
@@ -80,3 +80,22 @@ func (c *Client) Delete(ctx context.Context, key string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Bucket возвращает имя бакета, с которым работает клиент.
|
||||
func (c *Client) Bucket() string {
|
||||
return c.bucket
|
||||
}
|
||||
|
||||
// UploadContext загружает tar.gz с контекстом сборки (Dockerfile + код) в S3.
|
||||
// Ключ: contexts/{namespace}/{name}/{version}.tar.gz
|
||||
// Kaniko читает этот tar.gz как build context (--context=s3://bucket/key).
|
||||
func (c *Client) UploadContext(ctx context.Context, namespace, funcName, version string, r io.Reader, size int64) (string, error) {
|
||||
key := fmt.Sprintf("contexts/%s/%s/%s.tar.gz", namespace, funcName, version)
|
||||
_, err := c.mc.PutObject(ctx, c.bucket, key, r, size, minio.PutObjectOptions{
|
||||
ContentType: "application/gzip",
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("upload build context: %w", err)
|
||||
}
|
||||
return key, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user