mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-29 18:18:52 +00:00
fix: Don't attempt a pull if the token requests fails
Change-type: patch Closes: #879 Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
93460d36b9
commit
d8085a6ef8
@ -11,6 +11,7 @@ import {
|
||||
DeltaStillProcessingError,
|
||||
InternalInconsistencyError,
|
||||
InvalidNetGatewayError,
|
||||
ImageAuthenticationError,
|
||||
} from './errors';
|
||||
import { request, requestLib, resumable } from './request';
|
||||
import { EnvVarObject } from './types';
|
||||
@ -113,17 +114,18 @@ export class DockerUtils extends DockerToolbelt {
|
||||
const tokenResponseBody = (await request.getAsync(tokenUrl, tokenOpts))[1];
|
||||
const token = tokenResponseBody != null ? tokenResponseBody.token : null;
|
||||
|
||||
if (token == null) {
|
||||
throw new ImageAuthenticationError();
|
||||
}
|
||||
|
||||
const opts: requestLib.CoreOptions = {
|
||||
followRedirect: false,
|
||||
timeout: deltaOpts.deltaRequestTimeout,
|
||||
};
|
||||
|
||||
if (token != null) {
|
||||
opts.auth = {
|
||||
auth: {
|
||||
bearer: token,
|
||||
sendImmediately: true,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const url = `${deltaOpts.deltaEndpoint}/api/v${
|
||||
deltaOpts.deltaVersion
|
||||
|
@ -60,3 +60,5 @@ export class ConfigurationValidationError extends TypedError {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class ImageAuthenticationError extends TypedError {}
|
||||
|
Loading…
Reference in New Issue
Block a user