fix(core): update
This commit is contained in:
@ -47,7 +47,7 @@ export class DockerHost {
|
||||
|
||||
/**
|
||||
* sets an auth token
|
||||
* @param authToken
|
||||
* @param authToken
|
||||
*/
|
||||
public setAuthToken(authToken: string) {
|
||||
this.registryToken = authToken;
|
||||
@ -70,10 +70,9 @@ export class DockerHost {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* gets all containers
|
||||
*/
|
||||
|
@ -21,7 +21,6 @@ export class DockerImage {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
return result;
|
||||
}
|
||||
@ -30,7 +29,6 @@ export class DockerImage {
|
||||
dockerHostArg: DockerHost,
|
||||
creationObject: interfaces.IImageCreationDescriptor
|
||||
): Promise<DockerImage> {
|
||||
|
||||
// lets create a sanatized imageUrlObject
|
||||
const imageUrlObject: {
|
||||
imageUrl: string;
|
||||
@ -46,9 +44,7 @@ export class DockerImage {
|
||||
const imageTag = imageUrlObject.imageUrl.split(':')[1];
|
||||
if (imageUrlObject.imageTag) {
|
||||
throw new Error(
|
||||
`imageUrl ${imageUrlObject.imageUrl} can't be tagged with ${
|
||||
imageUrlObject.imageTag
|
||||
} because it is already tagged with ${imageTag}`
|
||||
`imageUrl ${imageUrlObject.imageUrl} can't be tagged with ${imageUrlObject.imageTag} because it is already tagged with ${imageTag}`
|
||||
);
|
||||
} else {
|
||||
imageUrlObject.imageUrl = imageUrl;
|
||||
|
@ -17,17 +17,20 @@ export class DockerSecret {
|
||||
return secrets;
|
||||
}
|
||||
|
||||
public static async getSecretByID (dockerHostArg: DockerHost, idArg: string) {
|
||||
public static async getSecretByID(dockerHostArg: DockerHost, idArg: string) {
|
||||
const secrets = await this.getSecrets(dockerHostArg);
|
||||
return secrets.find(secret => secret.ID === idArg);
|
||||
}
|
||||
|
||||
public static async getSecretByName (dockerHostArg: DockerHost, nameArg: string) {
|
||||
public static async getSecretByName(dockerHostArg: DockerHost, nameArg: string) {
|
||||
const secrets = await this.getSecrets(dockerHostArg);
|
||||
return secrets.find(secret => secret.Spec.Name === nameArg);
|
||||
}
|
||||
|
||||
public static async createSecret(dockerHostArg: DockerHost, secretDescriptor: interfaces.ISecretCreationDescriptor) {
|
||||
public static async createSecret(
|
||||
dockerHostArg: DockerHost,
|
||||
secretDescriptor: interfaces.ISecretCreationDescriptor
|
||||
) {
|
||||
const labels: interfaces.TLabels = {
|
||||
...secretDescriptor.labels,
|
||||
version: secretDescriptor.version
|
||||
@ -37,10 +40,13 @@ export class DockerSecret {
|
||||
Labels: labels,
|
||||
Data: plugins.smartstring.base64.encode(secretDescriptor.contentArg)
|
||||
});
|
||||
|
||||
|
||||
const newSecretInstance = new DockerSecret(dockerHostArg);
|
||||
Object.assign(newSecretInstance, response.body);
|
||||
Object.assign (newSecretInstance, await DockerSecret.getSecretByID(dockerHostArg, newSecretInstance.ID));
|
||||
Object.assign(
|
||||
newSecretInstance,
|
||||
await DockerSecret.getSecretByID(dockerHostArg, newSecretInstance.ID)
|
||||
);
|
||||
return newSecretInstance;
|
||||
}
|
||||
|
||||
@ -51,7 +57,7 @@ export class DockerSecret {
|
||||
Labels: interfaces.TLabels;
|
||||
};
|
||||
public Version: {
|
||||
Index:string;
|
||||
Index: string;
|
||||
};
|
||||
|
||||
public dockerHost: DockerHost;
|
||||
@ -62,22 +68,25 @@ export class DockerSecret {
|
||||
/**
|
||||
* updates a secret
|
||||
*/
|
||||
public async update (contentArg: string) {
|
||||
public async update(contentArg: string) {
|
||||
const route = `/secrets/${this.ID}/update?=version=${this.Version.Index}`;
|
||||
const response = await this.dockerHost.request('POST', `/secrets/${this.ID}/update?version=${this.Version.Index}`, {
|
||||
Name: this.Spec.Name,
|
||||
Labels: this.Spec.Labels,
|
||||
Data: plugins.smartstring.base64.encode(contentArg)
|
||||
});
|
||||
const response = await this.dockerHost.request(
|
||||
'POST',
|
||||
`/secrets/${this.ID}/update?version=${this.Version.Index}`,
|
||||
{
|
||||
Name: this.Spec.Name,
|
||||
Labels: this.Spec.Labels,
|
||||
Data: plugins.smartstring.base64.encode(contentArg)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public async remove () {
|
||||
public async remove() {
|
||||
await this.dockerHost.request('DELETE', `/secrets/${this.ID}`);
|
||||
}
|
||||
|
||||
|
||||
// get things
|
||||
public async getVersion() {
|
||||
return this.Spec.Labels.version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ export class DockerService {
|
||||
'info',
|
||||
`now creating service ${serviceCreationDescriptor.name}`
|
||||
);
|
||||
|
||||
|
||||
// await serviceCreationDescriptor.image.pullLatestImageFromRegistry();
|
||||
const serviceVersion = await serviceCreationDescriptor.image.getVersion();
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
// node native path
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
};
|
||||
export { path };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
@ -19,7 +17,18 @@ import * as smartversion from '@pushrocks/smartversion';
|
||||
|
||||
smartlog.defaultLogger.enableConsole();
|
||||
|
||||
export { lik, smartfile, smartjson, smartlog, smartnetwork, smartpath, smartpromise, smartrequest, smartstring, smartversion };
|
||||
export {
|
||||
lik,
|
||||
smartfile,
|
||||
smartjson,
|
||||
smartlog,
|
||||
smartnetwork,
|
||||
smartpath,
|
||||
smartpromise,
|
||||
smartrequest,
|
||||
smartstring,
|
||||
smartversion
|
||||
};
|
||||
|
||||
// third party
|
||||
import * as rxjs from 'rxjs';
|
||||
|
@ -5,4 +5,4 @@ export interface ISecretCreationDescriptor {
|
||||
version: string;
|
||||
contentArg: any;
|
||||
labels: interfaces.TLabels;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user