mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix(vcs): send the archive credential the provider asks for
A Bitbucket deployment waited forever on a build that never started. Its source is fetched from an archive url by the jobs-service, and Bitbucket's archive host takes no credential from a url -- it answers a redirect to a login page, so the fetch landed empty with nothing to report. The adapter says what headers that fetch needs, and every source fetch carries them. Providers that authenticate through the url alone ask for none, so what they send is unchanged.
This commit is contained in:
1 parent
1ff43392e3
commit
09c5bb46e1
6 files changed
+13
-2
No files matched your search
@@ -118,13 +118,18 @@ readonly class Deployments
|
||||
* Same as createFromUpload(), but builds from a remote tarball at $url
|
||||
* (a VCS presigned URL) instead of the deployment's own uploaded source.
|
||||
*/
|
||||
/**
|
||||
* @param array<string, string> $headers Sent with the source fetch, for a
|
||||
* url whose provider authenticates by header
|
||||
*/
|
||||
public function createFromUrl(
|
||||
Document $resource,
|
||||
Document $deployment,
|
||||
string $url,
|
||||
string $rootDirectory = '',
|
||||
array $headers = [],
|
||||
): Document {
|
||||
return $this->submit($resource, $deployment, ['url' => $url, 'subdir' => $rootDirectory]);
|
||||
return $this->submit($resource, $deployment, ['url' => $url, 'subdir' => $rootDirectory, 'headers' => $headers]);
|
||||
}
|
||||
|
||||
private function submit(Document $resource, Document $deployment, ?array $source): Document
|
||||
@@ -322,7 +327,7 @@ readonly class Deployments
|
||||
if ($source !== null) {
|
||||
$subdir = \trim($source['subdir'] ?? '', '/');
|
||||
$sourceArtifacts = [
|
||||
new DownloadArtifact(id: 'source', in: $source['url'], out: 'source.tar.gz'),
|
||||
new DownloadArtifact(id: 'source', in: $source['url'], out: 'source.tar.gz', headers: $source['headers'] ?? []),
|
||||
new UnarchiveArtifact(id: 'extract', in: 'source.tar.gz', out: 'source', subdir: $subdir !== '' ? $subdir : null, strip: true, depends: 'source'),
|
||||
// Appwrite never sees the remote source (the sidecar fetches it),
|
||||
// so unlike the uploaded-tarball path it can't size it. Stat the
|
||||
|
||||
@@ -177,6 +177,7 @@ class Base extends Action
|
||||
$deployment,
|
||||
$vcs->getRepositoryPresignedUrl($owner, $repositoryName, $ref),
|
||||
$function->getAttribute('providerRootDirectory', ''),
|
||||
$vcs->getRepositoryPresignedUrlHeaders(),
|
||||
);
|
||||
} else {
|
||||
$deployment = $dbForProject->createDocument('deployments', new Document([
|
||||
@@ -398,6 +399,7 @@ class Base extends Action
|
||||
$deployment,
|
||||
$vcs->getRepositoryPresignedUrl($owner, $repositoryName, $ref),
|
||||
$site->getAttribute('providerRootDirectory', ''),
|
||||
$vcs->getRepositoryPresignedUrlHeaders(),
|
||||
);
|
||||
} else {
|
||||
$publisherForBuilds->enqueue(new BuildMessage(
|
||||
|
||||
@@ -162,6 +162,7 @@ class Create extends Action
|
||||
$deployment,
|
||||
$github->getRepositoryPresignedUrl($owner, $repository, $ref),
|
||||
$deployment->getAttribute('providerRootDirectory', ''),
|
||||
$github->getRepositoryPresignedUrlHeaders(),
|
||||
);
|
||||
} else {
|
||||
// Public template repo: providerBranch holds the resolved ref,
|
||||
|
||||
@@ -406,6 +406,7 @@ class Builds extends Action
|
||||
$deployment,
|
||||
$providerAdapter->getRepositoryPresignedUrl($cloneOwner, $cloneRepository, $ref),
|
||||
$resource->getAttribute('providerRootDirectory', ''),
|
||||
$providerAdapter->getRepositoryPresignedUrlHeaders(),
|
||||
);
|
||||
|
||||
Console::execute('rm -rf ' . \escapeshellarg('/tmp/builds/' . $deploymentId), '', $stdout, $stderr);
|
||||
|
||||
@@ -183,6 +183,7 @@ class Create extends Action
|
||||
$deployment,
|
||||
$vcs->getRepositoryPresignedUrl($owner, $repository, $ref),
|
||||
$deployment->getAttribute('providerRootDirectory', ''),
|
||||
$vcs->getRepositoryPresignedUrlHeaders(),
|
||||
);
|
||||
} else {
|
||||
// Public template repo: providerBranch holds the resolved ref,
|
||||
|
||||
@@ -397,6 +397,7 @@ trait Deployment
|
||||
$deployment,
|
||||
$vcs->getRepositoryPresignedUrl($providerRepositoryOwner, $providerRepositoryName, $providerCommitHash),
|
||||
$resource->getAttribute('providerRootDirectory', ''),
|
||||
$vcs->getRepositoryPresignedUrlHeaders(),
|
||||
));
|
||||
|
||||
if ($resource->getCollection() === 'sites') {
|
||||
|
||||
Reference in new issue
Block a user