This adds back Computed<T> as a short-hand for Promise<T | undefined>. Subtly, all resource properties need to permit undefined flowing through during planning Rather than forcing the long-hand version, which is easy to forget, we'll keep the convention of preferring Computed<T>. It's just a typedef and the runtime type is just a Promise.
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
|
|
|
import { Computed, ComputedValue } from "../resource";
|
|
import { Asset } from "./asset";
|
|
|
|
// An Archive represents a collection of named assets.
|
|
export abstract class Archive {
|
|
}
|
|
|
|
// AssetMap is a map of assets.
|
|
export type AssetMap = {[name: string]: Asset};
|
|
|
|
// An AssetArchive is an archive created with a collection of named assets.
|
|
export class AssetArchive extends Archive {
|
|
public readonly assets: Computed<AssetMap>; // a map of name to asset.
|
|
|
|
constructor(assets: ComputedValue<AssetMap>) {
|
|
super();
|
|
this.assets = Promise.resolve<AssetMap | undefined>(assets);
|
|
}
|
|
}
|
|
|
|
// A FileArchive is an archive in a file-based archive in one of the supported formats (.tar, .tar.gz, or .zip).
|
|
export class FileArchive extends Archive {
|
|
public readonly path: Computed<string>; // the path to the asset file.
|
|
|
|
constructor(path: ComputedValue<string>) {
|
|
super();
|
|
this.path = Promise.resolve<string | undefined>(path);
|
|
}
|
|
}
|
|
|
|
// A RemoteArchive is an archive in a file-based archive fetched from a remote location. The URI's scheme dictates the
|
|
// protocol for fetching the archive's contents: `file://` is a local file (just like a FileArchive), `http://` and
|
|
// `https://` specify HTTP and HTTPS, respectively, and specific providers may recognize custom schemes.
|
|
export class RemoteArchive extends Archive {
|
|
public readonly uri: Computed<string>; // the URI where the archive lives.
|
|
|
|
constructor(uri: ComputedValue<string>) {
|
|
super();
|
|
this.uri = Promise.resolve<string | undefined>(uri);
|
|
}
|
|
}
|
|
|