diff --git a/core/src/actions.ts b/core/src/actions.ts index 497e4135f3..4f500da77b 100644 --- a/core/src/actions.ts +++ b/core/src/actions.ts @@ -21,7 +21,7 @@ import { defaultProvider } from "./config/provider" import { ParameterError, PluginError, InternalError, RuntimeError } from "./exceptions" import { Garden, ModuleActionMap } from "./garden" import { LogEntry } from "./logger/log-entry" -import { Module } from "./types/module" +import { GardenModule } from "./types/module" import { PluginActionContextParams, PluginActionParamsBase, @@ -308,7 +308,7 @@ export class ActionRouter implements TypeGuard { return result } - async getBuildStatus( + async getBuildStatus( params: ModuleActionRouterParams> ): Promise { return this.callModuleHandler({ @@ -318,7 +318,7 @@ export class ActionRouter implements TypeGuard { }) } - async build(params: ModuleActionRouterParams>): Promise { + async build(params: ModuleActionRouterParams>): Promise { return this.callModuleHandler({ params, actionType: "build", @@ -326,17 +326,17 @@ export class ActionRouter implements TypeGuard { }) } - async publishModule( + async publishModule( params: ModuleActionRouterParams> ): Promise { return this.callModuleHandler({ params, actionType: "publish", defaultHandler: dummyPublishHandler }) } - async runModule(params: ModuleActionRouterParams>): Promise { + async runModule(params: ModuleActionRouterParams>): Promise { return this.callModuleHandler({ params, actionType: "runModule" }) } - async testModule( + async testModule( params: ModuleActionRouterParams, "artifactsPath">> ): Promise { const tmpDir = await tmp.dir({ unsafeCleanup: true }) @@ -364,7 +364,7 @@ export class ActionRouter implements TypeGuard { } } - async getTestResult( + async getTestResult( params: ModuleActionRouterParams> ): Promise { const result = await this.callModuleHandler({ @@ -989,9 +989,7 @@ export class ActionRouter implements TypeGuard { * Recursively wraps the base handler (if any) on an action handler, such that the base handler receives the _next_ * base handler as the `base` parameter when called from within the handler. */ - private wrapBase | ModuleActionHandler>( - handler?: T - ): T | undefined { + private wrapBase | ModuleActionHandler>(handler?: T): T | undefined { if (!handler) { return undefined } @@ -1206,19 +1204,19 @@ export class ActionRouter implements TypeGuard { type CommonParams = keyof PluginActionContextParams -type WrappedServiceActionHandlers = { +type WrappedServiceActionHandlers = { [P in keyof ServiceActionParams]: WrappedModuleActionHandler[P], ServiceActionOutputs[P]> } -type WrappedTaskActionHandlers = { +type WrappedTaskActionHandlers = { [P in keyof TaskActionParams]: WrappedModuleActionHandler[P], TaskActionOutputs[P]> } -type WrappedModuleActionHandlers = { +type WrappedModuleActionHandlers = { [P in keyof ModuleActionParams]: WrappedModuleActionHandler[P], ModuleActionOutputs[P]> } -type WrappedModuleAndRuntimeActionHandlers = WrappedModuleActionHandlers & +type WrappedModuleAndRuntimeActionHandlers = WrappedModuleActionHandlers & WrappedServiceActionHandlers & WrappedTaskActionHandlers diff --git a/core/src/build-dir.ts b/core/src/build-dir.ts index 1c5992dbfe..0430b14f1d 100644 --- a/core/src/build-dir.ts +++ b/core/src/build-dir.ts @@ -11,7 +11,7 @@ import semver from "semver" import { isAbsolute, join, parse, resolve, sep, relative } from "path" import { emptyDir, ensureDir } from "fs-extra" import { ConfigurationError, RuntimeError } from "./exceptions" -import { FileCopySpec, Module, getModuleKey } from "./types/module" +import { FileCopySpec, GardenModule, getModuleKey } from "./types/module" import { normalizeLocalRsyncPath, normalizeRelativePath } from "./util/fs" import { LogEntry } from "./logger/log-entry" import { ModuleConfig } from "./config/module" @@ -91,7 +91,7 @@ export class BuildDir { return new BuildDir(projectRoot, buildDirPath, buildMetadataDirPath) } - async syncFromSrc(module: Module, log: LogEntry) { + async syncFromSrc(module: GardenModule, log: LogEntry) { // We don't sync local exec modules to the build dir if (isLocalExecModule(module)) { log.silly("Skipping syncing from source for local exec module") @@ -111,7 +111,7 @@ export class BuildDir { }) } - async syncDependencyProducts(module: Module, graph: ConfigGraph, log: LogEntry) { + async syncDependencyProducts(module: GardenModule, graph: ConfigGraph, log: LogEntry) { const buildPath = await this.buildPath(module) const buildDependencies = module.build.dependencies @@ -154,7 +154,7 @@ export class BuildDir { await emptyDir(this.buildDirPath) } - async buildPath(moduleOrConfig: Module | ModuleConfig): Promise { + async buildPath(moduleOrConfig: GardenModule | ModuleConfig): Promise { // We don't stage the build for local exec modules, so the module path is effectively the build path. if (isLocalExecModule(moduleOrConfig)) { return moduleOrConfig.path @@ -192,7 +192,7 @@ export class BuildDir { log, files, }: { - module: Module + module: GardenModule sourcePath: string destinationPath: string withDelete: boolean diff --git a/core/src/commands/dev.ts b/core/src/commands/dev.ts index 856cd39196..042514e1a8 100644 --- a/core/src/commands/dev.ts +++ b/core/src/commands/dev.ts @@ -19,7 +19,7 @@ import { getModuleWatchTasks } from "../tasks/helpers" import { Command, CommandResult, CommandParams, handleProcessResults, PrepareParams } from "./base" import { STATIC_DIR } from "../constants" import { processModules } from "../process" -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { getTestTasks } from "../tasks/test" import { ConfigGraph } from "../config-graph" import { getHotReloadServiceNames, validateHotReloadServiceNames } from "./helpers" @@ -144,7 +144,7 @@ export class DevCommand extends Command { modules, watch: true, initialTasks, - changeHandler: async (updatedGraph: ConfigGraph, module: Module) => { + changeHandler: async (updatedGraph: ConfigGraph, module: GardenModule) => { return getDevCommandWatchTasks({ garden, log, @@ -172,7 +172,7 @@ export async function getDevCommandInitialTasks({ garden: Garden log: LogEntry graph: ConfigGraph - modules: Module[] + modules: GardenModule[] hotReloadServiceNames: string[] skipTests: boolean }) { @@ -235,7 +235,7 @@ export async function getDevCommandWatchTasks({ garden: Garden log: LogEntry updatedGraph: ConfigGraph - module: Module + module: GardenModule hotReloadServiceNames: string[] testNames: string[] | undefined skipTests: boolean @@ -249,7 +249,7 @@ export async function getDevCommandWatchTasks({ }) if (!skipTests) { - const testModules: Module[] = await updatedGraph.withDependantModules([module]) + const testModules: GardenModule[] = await updatedGraph.withDependantModules([module]) tasks.push( ...flatten( await Bluebird.map(testModules, (m) => diff --git a/core/src/commands/plugins.ts b/core/src/commands/plugins.ts index c022d40dce..e60dab3956 100644 --- a/core/src/commands/plugins.ts +++ b/core/src/commands/plugins.ts @@ -17,8 +17,8 @@ import { Command, CommandResult, CommandParams } from "./base" import Bluebird from "bluebird" import { printHeader, getTerminalWidth } from "../logger/util" import { LoggerType } from "../logger/logger" -import { Module } from "../types/module" import { StringOption } from "../cli/params" +import { GardenModule } from "../types/module" const pluginArgs = { plugin: new StringOption({ @@ -105,7 +105,7 @@ export class PluginsCommand extends Command { const provider = await garden.resolveProvider(log, args.plugin) const ctx = garden.getPluginContext(provider) - let modules: Module[] = [] + let modules: GardenModule[] = [] // Commands can optionally ask for all the modules in the project/environment if (command.resolveModules) { diff --git a/core/src/commands/publish.ts b/core/src/commands/publish.ts index c1dd792cf0..3ce8ba9f0c 100644 --- a/core/src/commands/publish.ts +++ b/core/src/commands/publish.ts @@ -17,7 +17,7 @@ import { processCommandResultSchema, resultMetadataKeys, } from "./base" -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { PublishTask } from "../tasks/publish" import { GraphResults } from "../task-graph" import { Garden } from "../garden" @@ -126,7 +126,7 @@ export async function publishModules({ garden: Garden graph: ConfigGraph log: LogEntry - modules: Module[] + modules: GardenModule[] forceBuild: boolean allowDirty: boolean }): Promise { diff --git a/core/src/commands/test.ts b/core/src/commands/test.ts index 48a085b9e1..390b1f9ef4 100644 --- a/core/src/commands/test.ts +++ b/core/src/commands/test.ts @@ -20,7 +20,7 @@ import { processCommandResultSchema, } from "./base" import { processModules } from "../process" -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { getTestTasks } from "../tasks/test" import { printHeader } from "../logger/util" import { GardenServer, startServer } from "../server/server" @@ -117,7 +117,7 @@ export class TestCommand extends Command { const graph = await garden.getConfigGraph(log) - const modules: Module[] = args.modules + const modules: GardenModule[] = args.modules ? graph.withDependantModules(graph.getModules({ names: args.modules })) : // All modules are included in this case, so there's no need to compute dependants. graph.getModules() diff --git a/core/src/config-graph.ts b/core/src/config-graph.ts index b56298d552..256a701bd8 100644 --- a/core/src/config-graph.ts +++ b/core/src/config-graph.ts @@ -9,7 +9,7 @@ import toposort from "toposort" import { flatten, pick, uniq, sortBy, pickBy } from "lodash" import { BuildDependencyConfig } from "./config/module" -import { Module, getModuleKey, moduleNeedsBuild } from "./types/module" +import { GardenModule, getModuleKey, moduleNeedsBuild } from "./types/module" import { Service, serviceFromConfig } from "./types/service" import { Task, taskFromConfig } from "./types/task" import { TestConfig } from "./config/test" @@ -28,7 +28,7 @@ export type DependencyGraphNodeType = "build" | "deploy" | "run" | "test" // The primary output type (for dependencies and dependants). export type DependencyRelations = { - build: Module[] + build: GardenModule[] deploy: Service[] run: Task[] test: TestConfig[] @@ -77,7 +77,7 @@ export type DependencyGraph = { [key: string]: DependencyGraphNode } */ export class ConfigGraph { private dependencyGraph: DependencyGraph - private modules: { [key: string]: Module } + private modules: { [key: string]: GardenModule } private serviceConfigs: { [key: string]: EntityConfigEntry<"service", ServiceConfig> @@ -89,7 +89,7 @@ export class ConfigGraph { [key: string]: EntityConfigEntry<"test", TestConfig> } - constructor(modules: Module[], moduleTypes: ModuleTypeMap) { + constructor(modules: GardenModule[], moduleTypes: ModuleTypeMap) { this.dependencyGraph = {} this.modules = {} this.serviceConfigs = {} @@ -271,7 +271,7 @@ export class ConfigGraph { } // Convenience method used in the constructor above. - keyForModule(module: Module | BuildDependencyConfig) { + keyForModule(module: GardenModule | BuildDependencyConfig) { return getModuleKey(module.name, module.plugin) } @@ -301,7 +301,7 @@ export class ConfigGraph { /** * Returns the Service with the specified name. Throws error if it doesn't exist. */ - getModule(name: string, includeDisabled?: boolean): Module { + getModule(name: string, includeDisabled?: boolean): GardenModule { return this.getModules({ names: [name], includeDisabled })[0] } @@ -358,7 +358,7 @@ export class ConfigGraph { /** * Returns the set union of modules with the set union of their dependants (across all dependency types, recursively). */ - withDependantModules(modules: Module[]): Module[] { + withDependantModules(modules: GardenModule[]): GardenModule[] { const dependants = modules.flatMap((m) => this.getDependantsForModule(m, true)) // We call getModules to ensure that the returned modules have up-to-date versions. const dependantModules = this.modulesForRelations(this.mergeRelations(...dependants)) @@ -370,7 +370,7 @@ export class ConfigGraph { * Includes the services and tasks contained in the given module, but does _not_ contain the build node for the * module itself. */ - getDependantsForModule(module: Module, recursive: boolean): DependencyRelations { + getDependantsForModule(module: GardenModule, recursive: boolean): DependencyRelations { return this.getDependants({ nodeType: "build", name: module.name, recursive }) } @@ -476,7 +476,7 @@ export class ConfigGraph { /** * Returns the (unique by name) list of modules represented in relations. */ - private modulesForRelations(relations: DependencyRelations): Module[] { + private modulesForRelations(relations: DependencyRelations): GardenModule[] { const moduleNames = uniq( flatten([ relations.build, @@ -493,7 +493,7 @@ export class ConfigGraph { * Given the provided lists of build and runtime (service/task) dependencies, return a list of all * modules required to satisfy those dependencies. */ - resolveDependencyModules(buildDependencies: BuildDependencyConfig[], runtimeDependencies: string[]): Module[] { + resolveDependencyModules(buildDependencies: BuildDependencyConfig[], runtimeDependencies: string[]): GardenModule[] { const moduleNames = buildDependencies.map((d) => getModuleKey(d.name, d.plugin)) const serviceNames = runtimeDependencies.filter( (d) => this.serviceConfigs[d] && !this.isDisabled(this.serviceConfigs[d]) diff --git a/core/src/config/common.ts b/core/src/config/common.ts index 603fd800e4..566f276bcd 100644 --- a/core/src/config/common.ts +++ b/core/src/config/common.ts @@ -112,14 +112,14 @@ export interface PosixPathSchema extends Joi.StringSchema { subPathOnly(): this } -interface CustomJoi extends Joi.Root { +export interface Schema extends Joi.Root { object: () => CustomObjectSchema environment: () => Joi.StringSchema gitUrl: () => GitUrlSchema posixPath: () => PosixPathSchema } -export let joi: CustomJoi = Joi.extend({ +export let joi: Schema = Joi.extend({ base: Joi.string(), type: "posixPath", flags: { diff --git a/core/src/config/config-context.ts b/core/src/config/config-context.ts index d61fe38bcd..28d4529dd0 100644 --- a/core/src/config/config-context.ts +++ b/core/src/config/config-context.ts @@ -19,7 +19,7 @@ import { KeyedSet } from "../util/keyed-set" import { RuntimeContext } from "../runtime-context" import { deline, dedent, naturalList } from "../util/string" import { getProviderUrl, getModuleTypeUrl } from "../docs/common" -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { ModuleConfig } from "./module" import { ModuleVersion } from "../vcs/vcs" import { isPrimitive } from "util" @@ -811,7 +811,7 @@ export class OutputConfigContext extends ModuleConfigContext { }: { garden: Garden resolvedProviders: ProviderMap - modules: Module[] + modules: GardenModule[] runtimeContext: RuntimeContext }) { const versions = fromPairs(modules.map((m) => [m.name, m.version])) diff --git a/core/src/garden.ts b/core/src/garden.ts index 5636a51c7a..667e7a5b72 100644 --- a/core/src/garden.ts +++ b/core/src/garden.ts @@ -17,7 +17,7 @@ const AsyncLock = require("async-lock") import { TreeCache } from "./cache" import { builtinPlugins } from "./plugins/plugins" -import { Module, getModuleCacheContext, getModuleKey, ModuleConfigMap, moduleFromConfig } from "./types/module" +import { GardenModule, getModuleCacheContext, getModuleKey, ModuleConfigMap, moduleFromConfig } from "./types/module" import { pluginModuleSchema, ModuleTypeMap } from "./types/plugin/plugin" import { SourceConfig, @@ -691,7 +691,7 @@ export class Garden { return Object.values(keys ? pickKeys(this.moduleConfigs, keys, "module config") : this.moduleConfigs) } - async getOutputConfigContext(log: LogEntry, modules: Module[], runtimeContext: RuntimeContext) { + async getOutputConfigContext(log: LogEntry, modules: GardenModule[], runtimeContext: RuntimeContext) { const providers = await this.resolveProviders(log) return new OutputConfigContext({ garden: this, @@ -906,7 +906,7 @@ export class Garden { */ async resolveVersion( moduleConfig: ModuleConfig, - moduleDependencies: (Module | BuildDependencyConfig)[], + moduleDependencies: (GardenModule | BuildDependencyConfig)[], force = false ) { const moduleName = moduleConfig.name diff --git a/core/src/plugins/conftest/conftest.ts b/core/src/plugins/conftest/conftest.ts index 77ca81613b..7ed9193fc9 100644 --- a/core/src/plugins/conftest/conftest.ts +++ b/core/src/plugins/conftest/conftest.ts @@ -12,7 +12,7 @@ import { providerConfigBaseSchema, ProviderConfig, Provider } from "../../config import { joi, joiIdentifier, joiArray } from "../../config/common" import { dedent, naturalList } from "../../util/string" import { TestModuleParams } from "../../types/plugin/module/testModule" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import chalk from "chalk" import { baseBuildSpecSchema } from "../../config/module" import { matchGlobs, listDirectory } from "../../util/fs" @@ -63,7 +63,7 @@ interface ConftestModuleSpec { combine?: boolean } -type ConftestModule = Module +type ConftestModule = GardenModule const moduleTypeUrl = getModuleTypeUrl("conftest") const containerProviderUrl = getProviderUrl("conftest-container") diff --git a/core/src/plugins/container/config.ts b/core/src/plugins/container/config.ts index d4fd36ab2e..66531bf4da 100644 --- a/core/src/plugins/container/config.ts +++ b/core/src/plugins/container/config.ts @@ -8,7 +8,7 @@ import deline = require("deline") -import { Module, FileCopySpec } from "../../types/module" +import { GardenModule, FileCopySpec } from "../../types/module" import { joiUserIdentifier, joiArray, @@ -622,4 +622,4 @@ export interface ContainerModule< S extends ContainerServiceSpec = ContainerServiceSpec, T extends ContainerTestSpec = ContainerTestSpec, W extends ContainerTaskSpec = ContainerTaskSpec -> extends Module {} +> extends GardenModule {} diff --git a/core/src/plugins/exec.ts b/core/src/plugins/exec.ts index 2a19e9006e..6e2a6b8d8f 100644 --- a/core/src/plugins/exec.ts +++ b/core/src/plugins/exec.ts @@ -13,7 +13,7 @@ import cpy = require("cpy") import { joiArray, joiEnvVars, joi } from "../config/common" import { validateWithPath, ArtifactSpec } from "../config/validation" import { createGardenPlugin } from "../types/plugin/plugin" -import { Module, getModuleKey } from "../types/module" +import { GardenModule, getModuleKey } from "../types/module" import { CommonServiceSpec } from "../config/service" import { BaseTestSpec, baseTestSpecSchema } from "../config/test" import { writeModuleVersionFile } from "../vcs/vcs" @@ -160,7 +160,7 @@ export const execModuleSpecSchema = () => .unknown(false) .description("The module specification for an exec module.") -export interface ExecModule extends Module {} +export interface ExecModule extends GardenModule {} export async function configureExecModule({ ctx, diff --git a/core/src/plugins/google/common.ts b/core/src/plugins/google/common.ts index 837981dd6e..ec44d2e8a5 100644 --- a/core/src/plugins/google/common.ts +++ b/core/src/plugins/google/common.ts @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { PrepareEnvironmentParams, PrepareEnvironmentResult } from "../../types/plugin/provider/prepareEnvironment" import { ConfigurationError } from "../../exceptions" import { ExecTestSpec } from "../exec" @@ -21,7 +21,7 @@ export interface GoogleCloudModule< M extends ModuleSpec = ModuleSpec, S extends CommonServiceSpec = CommonServiceSpec, T extends ExecTestSpec = ExecTestSpec -> extends Module {} +> extends GardenModule {} export async function getEnvironmentStatus() { let sdkInfo: any diff --git a/core/src/plugins/google/google-cloud-functions.ts b/core/src/plugins/google/google-cloud-functions.ts index 65749e4aec..be740c24e1 100644 --- a/core/src/plugins/google/google-cloud-functions.ts +++ b/core/src/plugins/google/google-cloud-functions.ts @@ -7,7 +7,7 @@ */ import { joiArray, joi } from "../../config/common" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { ServiceState, ServiceStatus, ingressHostnameSchema, Service } from "../../types/service" import { resolve } from "path" import { ExecTestSpec, execTestSchema } from "../exec" @@ -47,7 +47,7 @@ export interface GcfModuleSpec extends CommonServiceSpec { export type GcfServiceSpec = GcfModuleSpec -export interface GcfModule extends Module {} +export interface GcfModule extends GardenModule {} function getGcfProject(service: Service, provider: Provider) { return service.spec.project || provider.config.defaultProject || null diff --git a/core/src/plugins/hadolint/hadolint.ts b/core/src/plugins/hadolint/hadolint.ts index 4434d0e471..467d609e40 100644 --- a/core/src/plugins/hadolint/hadolint.ts +++ b/core/src/plugins/hadolint/hadolint.ts @@ -9,12 +9,11 @@ import Bluebird from "bluebird" import { join, relative, resolve } from "path" import { pathExists, readFile } from "fs-extra" -import { createGardenPlugin } from "../../types/plugin/plugin" +import { createGardenPlugin, GardenModule } from "../../sdk" import { providerConfigBaseSchema, ProviderConfig, Provider } from "../../config/provider" import { joi } from "../../config/common" import { dedent, splitLines, naturalList } from "../../util/string" import { TestModuleParams } from "../../types/plugin/module/testModule" -import { Module } from "../../types/module" import { STATIC_DIR } from "../../constants" import { padStart, padEnd } from "lodash" import chalk from "chalk" @@ -61,7 +60,7 @@ interface HadolintModuleSpec { dockerfilePath: string } -type HadolintModule = Module +type HadolintModule = GardenModule const moduleTypeUrl = getModuleTypeUrl("hadolint") const providerUrl = getProviderUrl("hadolint") @@ -157,7 +156,7 @@ export const gardenPlugin = createGardenPlugin({ moduleConfig.testConfigs = [{ name: "lint", dependencies: [], spec: {}, timeout: 10, disabled: false }] return { moduleConfig } }, - testModule: async ({ ctx, log, module, testConfig }) => { + testModule: async ({ ctx, log, module, testConfig }: TestModuleParams) => { const dockerfilePath = join(module.path, module.spec.dockerfilePath) const startedAt = new Date() let dockerfile: string diff --git a/core/src/plugins/kubernetes/commands/pull-image.ts b/core/src/plugins/kubernetes/commands/pull-image.ts index ba8a3d3a85..7fb8368645 100644 --- a/core/src/plugins/kubernetes/commands/pull-image.ts +++ b/core/src/plugins/kubernetes/commands/pull-image.ts @@ -12,7 +12,7 @@ import { KubernetesPluginContext, KubernetesProvider } from "../config" import { PluginError, ParameterError } from "../../../exceptions" import { PluginCommand } from "../../../types/plugin/command" import chalk from "chalk" -import { Module } from "../../../types/module" +import { GardenModule } from "../../../types/module" import { findByNames } from "../../../util/util" import { filter, map } from "lodash" import { KubeApi } from "../api" @@ -54,8 +54,8 @@ export const pullImage: PluginCommand = { }, } -function findModules(modules: Module[], names: string[]): Module[] { - let foundModules: Module[] +function findModules(modules: GardenModule[], names: string[]): GardenModule[] { + let foundModules: GardenModule[] if (!names || names.length === 0) { foundModules = modules @@ -68,7 +68,7 @@ function findModules(modules: Module[], names: string[]): Module[] { return foundModules } -function ensureAllModulesValid(modules: Module[]) { +function ensureAllModulesValid(modules: GardenModule[]) { const invalidModules = filter(modules, (module) => { return !module.compatibleTypes.includes("container") || !containerHelpers.hasDockerfile(module) }) @@ -85,7 +85,7 @@ function ensureAllModulesValid(modules: Module[]) { } } -async function pullModules(ctx: KubernetesPluginContext, modules: Module[], log: LogEntry) { +async function pullModules(ctx: KubernetesPluginContext, modules: GardenModule[], log: LogEntry) { await Promise.all( modules.map(async (module) => { const remoteId = await containerHelpers.getPublicImageId(module) @@ -97,7 +97,7 @@ async function pullModules(ctx: KubernetesPluginContext, modules: Module[], log: ) } -export async function pullModule(ctx: KubernetesPluginContext, module: Module, log: LogEntry) { +export async function pullModule(ctx: KubernetesPluginContext, module: GardenModule, log: LogEntry) { const localId = await containerHelpers.getLocalImageId(module) if (ctx.provider.config.deploymentRegistry?.hostname === inClusterRegistryHostname) { @@ -109,7 +109,7 @@ export async function pullModule(ctx: KubernetesPluginContext, module: Module, l async function pullFromInClusterRegistry( k8sCtx: KubernetesPluginContext, - module: Module, + module: GardenModule, log: LogEntry, localId: string ) { @@ -133,7 +133,12 @@ async function pullFromInClusterRegistry( await containerHelpers.dockerCli({ cwd: module.buildPath, args: ["rmi", pullImageId], log, containerProvider }) } -async function pullFromExternalRegistry(ctx: KubernetesPluginContext, module: Module, log: LogEntry, localId: string) { +async function pullFromExternalRegistry( + ctx: KubernetesPluginContext, + module: GardenModule, + log: LogEntry, + localId: string +) { const api = await KubeApi.factory(log, ctx.provider) const namespace = await getAppNamespace(ctx, log, ctx.provider) const podName = makePodName("skopeo", namespace, module.name) @@ -176,7 +181,7 @@ async function importImage({ log, containerProvider, }: { - module: Module + module: GardenModule runner: PodRunner tarName: string imageId: string @@ -217,7 +222,7 @@ async function launchSkopeoContainer( api: KubeApi, podName: string, systemNamespace: string, - module: Module, + module: GardenModule, log: LogEntry ): Promise { const sleepCommand = "sleep 86400" diff --git a/core/src/plugins/kubernetes/helm/common.ts b/core/src/plugins/kubernetes/helm/common.ts index 5486529d05..08dfecedb1 100644 --- a/core/src/plugins/kubernetes/helm/common.ts +++ b/core/src/plugins/kubernetes/helm/common.ts @@ -20,7 +20,7 @@ import { loadAll } from "js-yaml" import { helm } from "./helm-cli" import { HelmModule, HelmModuleConfig } from "./config" import { ConfigurationError, PluginError } from "../../../exceptions" -import { Module } from "../../../types/module" +import { GardenModule } from "../../../types/module" import { deline, tailString } from "../../../util/string" import { getAnnotation, flattenResources } from "../util" import { KubernetesPluginContext } from "../config" @@ -68,7 +68,7 @@ export async function containsBuildSource(module: HelmModule) { /** * Render the template in the specified Helm module (locally), and return all the resources in the chart. */ -export async function getChartResources(ctx: PluginContext, module: Module, hotReload: boolean, log: LogEntry) { +export async function getChartResources(ctx: PluginContext, module: GardenModule, hotReload: boolean, log: LogEntry) { const k8sCtx = ctx const objects = loadTemplate(await renderTemplates(k8sCtx, module, hotReload, log)) @@ -94,7 +94,12 @@ export async function getChartResources(ctx: PluginContext, module: Module, hotR /** * Renders the given Helm module and returns a multi-document YAML string. */ -export async function renderTemplates(ctx: KubernetesPluginContext, module: Module, hotReload: boolean, log: LogEntry) { +export async function renderTemplates( + ctx: KubernetesPluginContext, + module: GardenModule, + hotReload: boolean, + log: LogEntry +) { log.debug("Preparing chart...") const chartPath = await getChartPath(module) diff --git a/core/src/plugins/kubernetes/helm/config.ts b/core/src/plugins/kubernetes/helm/config.ts index 3031d48154..d74630de2c 100644 --- a/core/src/plugins/kubernetes/helm/config.ts +++ b/core/src/plugins/kubernetes/helm/config.ts @@ -15,7 +15,7 @@ import { joi, joiModuleIncludeDirective, } from "../../../config/common" -import { Module } from "../../../types/module" +import { GardenModule } from "../../../types/module" import { containsSource, getReleaseName } from "./common" import { ConfigurationError } from "../../../exceptions" import { deline, dedent } from "../../../util/string" @@ -39,7 +39,8 @@ export const defaultHelmTimeout = 300 // A Helm Module always maps to a single Service export type HelmModuleSpec = HelmServiceSpec -export interface HelmModule extends Module {} +export interface HelmModule + extends GardenModule {} export type HelmModuleConfig = HelmModule["_config"] export interface HelmServiceSpec { diff --git a/core/src/plugins/kubernetes/hot-reload.ts b/core/src/plugins/kubernetes/hot-reload.ts index b395e79b09..f2030311e6 100644 --- a/core/src/plugins/kubernetes/hot-reload.ts +++ b/core/src/plugins/kubernetes/hot-reload.ts @@ -30,7 +30,7 @@ import { kubectl } from "./kubectl" import { labelSelectorToString } from "./util" import { KubeApi } from "./api" import { syncWithOptions } from "../../util/sync" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" export type HotReloadableResource = KubernetesResource export type HotReloadableKind = "Deployment" | "DaemonSet" | "StatefulSet" @@ -383,7 +383,7 @@ export async function syncToService({ ctx, service, hotReloadSpec, namespace, wo * So e.g. `source` = `mydir` would transform a tracked path `/path/to/module/mydir/subdir/myfile` to * `subdir/myfile` in the output, and if `source` = `.` or `*`, it would be transformed to `mydir/subdir/myfile`. */ -export function filesForSync(module: Module, source: string): string[] { +export function filesForSync(module: GardenModule, source: string): string[] { const normalizedSource = source.replace("**/", "").replace("*", "") // Normalize to relative POSIX-style paths diff --git a/core/src/plugins/kubernetes/kubernetes-module/config.ts b/core/src/plugins/kubernetes/kubernetes-module/config.ts index 61fc08b752..7a48fb01e3 100644 --- a/core/src/plugins/kubernetes/kubernetes-module/config.ts +++ b/core/src/plugins/kubernetes/kubernetes-module/config.ts @@ -8,7 +8,7 @@ import { dependenciesSchema } from "../../../config/service" import { joiArray, joi, joiModuleIncludeDirective } from "../../../config/common" -import { Module } from "../../../types/module" +import { GardenModule } from "../../../types/module" import { ConfigureModuleParams, ConfigureModuleResult } from "../../../types/plugin/module/configure" import { Service } from "../../../types/service" import { baseBuildSpecSchema } from "../../../config/module" @@ -27,7 +27,7 @@ import { // A Kubernetes Module always maps to a single Service export type KubernetesModuleSpec = KubernetesServiceSpec -export interface KubernetesModule extends Module {} +export interface KubernetesModule extends GardenModule {} export type KubernetesModuleConfig = KubernetesModule["_config"] export interface KubernetesServiceSpec { diff --git a/core/src/plugins/kubernetes/run.ts b/core/src/plugins/kubernetes/run.ts index 1fdc75e476..0909d8147c 100644 --- a/core/src/plugins/kubernetes/run.ts +++ b/core/src/plugins/kubernetes/run.ts @@ -13,7 +13,7 @@ import { V1PodSpec, V1Pod, V1Container } from "@kubernetes/client-node" import { tailString } from "../../util/string" import { RunResult } from "../../types/plugin/base" import { kubectl } from "./kubectl" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { LogEntry } from "../../logger/log-entry" import { PluginError, GardenBaseError, TimeoutError, RuntimeError, ConfigurationError } from "../../exceptions" import { KubernetesProvider } from "./config" @@ -55,7 +55,7 @@ export async function runAndCopy({ stderr, namespace, volumes, -}: RunModuleParams & { +}: RunModuleParams & { image: string container?: V1Container podName?: string @@ -362,7 +362,7 @@ class PodRunnerParams { annotations?: { [key: string]: string } api: KubeApi image: string - module: Module + module: GardenModule namespace: string podName: string provider: KubernetesProvider diff --git a/core/src/plugins/kubernetes/task-results.ts b/core/src/plugins/kubernetes/task-results.ts index 00e0039184..23af57716f 100644 --- a/core/src/plugins/kubernetes/task-results.ts +++ b/core/src/plugins/kubernetes/task-results.ts @@ -19,7 +19,7 @@ import { deserializeValues } from "../../util/util" import { PluginContext } from "../../plugin-context" import { LogEntry } from "../../logger/log-entry" import { gardenAnnotationKey, tailString } from "../../util/string" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import hasha from "hasha" import { upsertConfigMap } from "./util" import { trimRunOutput } from "./helm/common" @@ -65,7 +65,7 @@ export async function getTaskResult({ } } -export function getTaskResultKey(ctx: PluginContext, module: Module, taskName: string, version: ModuleVersion) { +export function getTaskResultKey(ctx: PluginContext, module: GardenModule, taskName: string, version: ModuleVersion) { const key = `${ctx.projectName}--${module.name}--${taskName}--${version.versionString}` const hash = hasha(key, { algorithm: "sha1" }) return `task-result--${hash.slice(0, 32)}` @@ -74,7 +74,7 @@ export function getTaskResultKey(ctx: PluginContext, module: Module, taskName: s interface StoreTaskResultParams { ctx: PluginContext log: LogEntry - module: Module + module: GardenModule taskName: string taskVersion: ModuleVersion result: RunTaskResult diff --git a/core/src/plugins/kubernetes/test-results.ts b/core/src/plugins/kubernetes/test-results.ts index bc43ba47e8..26b51dd050 100644 --- a/core/src/plugins/kubernetes/test-results.ts +++ b/core/src/plugins/kubernetes/test-results.ts @@ -8,7 +8,7 @@ import { deserializeValues } from "../../util/util" import { KubeApi } from "./api" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { ModuleVersion } from "../../vcs/vcs" import { ContainerModule } from "../container/config" import { HelmModule } from "./helm/config" @@ -64,7 +64,7 @@ export async function getTestResult({ } } -export function getTestResultKey(ctx: PluginContext, module: Module, testName: string, version: ModuleVersion) { +export function getTestResultKey(ctx: PluginContext, module: GardenModule, testName: string, version: ModuleVersion) { const key = `${ctx.projectName}--${module.name}--${testName}--${version.versionString}` const hash = hasha(key, { algorithm: "sha1" }) return `test-result--${hash.slice(0, 32)}` @@ -73,7 +73,7 @@ export function getTestResultKey(ctx: PluginContext, module: Module, testName: s interface StoreTestResultParams { ctx: PluginContext log: LogEntry - module: Module + module: GardenModule testName: string testVersion: ModuleVersion result: TestResult diff --git a/core/src/plugins/kubernetes/volumes/persistentvolumeclaim.ts b/core/src/plugins/kubernetes/volumes/persistentvolumeclaim.ts index 41a47b65e0..d334ae19b5 100644 --- a/core/src/plugins/kubernetes/volumes/persistentvolumeclaim.ts +++ b/core/src/plugins/kubernetes/volumes/persistentvolumeclaim.ts @@ -17,7 +17,7 @@ import { DOCS_BASE_URL, STATIC_DIR } from "../../../constants" import { baseBuildSpecSchema } from "../../../config/module" import { ConfigureModuleParams } from "../../../types/plugin/module/configure" import { GetServiceStatusParams } from "../../../types/plugin/service/getServiceStatus" -import { Module } from "../../../types/module" +import { GardenModule } from "../../../types/module" import { KubernetesModule, KubernetesModuleConfig, KubernetesService } from "../kubernetes-module/config" import { KubernetesResource } from "../types" import { getKubernetesServiceStatus, deployKubernetesService } from "../kubernetes-module/handlers" @@ -30,7 +30,7 @@ export interface PersistentVolumeClaimSpec extends BaseVolumeSpec { spec: V1PersistentVolumeClaimSpec } -type PersistentVolumeClaimModule = Module +type PersistentVolumeClaimModule = GardenModule // Need to use a sync read to avoid having to refactor createGardenPlugin() // The `persistentvolumeclaim.json` file is copied from the handy diff --git a/core/src/plugins/maven-container/maven-container.ts b/core/src/plugins/maven-container/maven-container.ts index e38f595706..19d42ae458 100644 --- a/core/src/plugins/maven-container/maven-container.ts +++ b/core/src/plugins/maven-container/maven-container.ts @@ -17,7 +17,7 @@ import { ContainerTaskSpec, } from "../container/config" import { joiArray, joiProviderName, joi, joiModuleIncludeDirective } from "../../config/common" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { resolve } from "path" import { RuntimeError, ConfigurationError } from "../../exceptions" import { containerHelpers } from "../container/helpers" @@ -54,7 +54,7 @@ export interface MavenContainerModule< S extends ContainerServiceSpec = ContainerServiceSpec, T extends ContainerTestSpec = ContainerTestSpec, W extends ContainerTaskSpec = ContainerTaskSpec -> extends Module {} +> extends GardenModule {} const mavenKeys = { imageVersion: joi diff --git a/core/src/plugins/openfaas/config.ts b/core/src/plugins/openfaas/config.ts index 635dc8e5b4..2c5c90ad99 100644 --- a/core/src/plugins/openfaas/config.ts +++ b/core/src/plugins/openfaas/config.ts @@ -12,7 +12,7 @@ import { resolve as urlResolve } from "url" import { ConfigurationError } from "../../exceptions" import { PluginContext } from "../../plugin-context" import { joiArray, joiProviderName, joi, joiEnvVars, DeepPrimitiveMap } from "../../config/common" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { Service } from "../../types/service" import { ExecModuleSpecBase, ExecTestSpec } from "../exec" import { KubernetesProvider } from "../kubernetes/config" @@ -79,7 +79,7 @@ export const openfaasModuleOutputsSchema = () => .description(`The full URL to query this service _from within_ the cluster.`), }) -export interface OpenFaasModule extends Module {} +export interface OpenFaasModule extends GardenModule {} export type OpenFaasModuleConfig = OpenFaasModule["_config"] export interface OpenFaasService extends Service {} diff --git a/core/src/plugins/terraform/commands.ts b/core/src/plugins/terraform/commands.ts index a061940f5a..37751a43db 100644 --- a/core/src/plugins/terraform/commands.ts +++ b/core/src/plugins/terraform/commands.ts @@ -11,7 +11,7 @@ import { terraform } from "./cli" import { TerraformProvider } from "./terraform" import { ConfigurationError, ParameterError } from "../../exceptions" import { prepareVariables, tfValidate } from "./common" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { findByName } from "../../util/util" import { TerraformModule } from "./module" import { PluginCommand, PluginCommandParams } from "../../types/plugin/command" @@ -104,7 +104,7 @@ function makeModuleCommand(commandName: string) { } } -function findModule(modules: Module[], name: string): TerraformModule { +function findModule(modules: GardenModule[], name: string): TerraformModule { if (!name) { throw new ParameterError(`The first command argument must be a module name.`, { name }) } diff --git a/core/src/plugins/terraform/module.ts b/core/src/plugins/terraform/module.ts index 22853376e2..bd1c60c581 100644 --- a/core/src/plugins/terraform/module.ts +++ b/core/src/plugins/terraform/module.ts @@ -11,7 +11,7 @@ import { pathExists } from "fs-extra" import { joi } from "../../config/common" import { dedent, deline } from "../../util/string" import { supportedVersions } from "./cli" -import { Module } from "../../types/module" +import { GardenModule } from "../../types/module" import { ConfigureModuleParams } from "../../types/plugin/module/configure" import { ConfigurationError } from "../../exceptions" import { dependenciesSchema } from "../../config/service" @@ -27,7 +27,7 @@ export interface TerraformModuleSpec extends TerraformBaseSpec { root: string } -export interface TerraformModule extends Module {} +export interface TerraformModule extends GardenModule {} export const schema = joi.object().keys({ build: baseBuildSpecSchema(), diff --git a/core/src/process.ts b/core/src/process.ts index 905bc7abb8..cb625f59c4 100644 --- a/core/src/process.ts +++ b/core/src/process.ts @@ -10,7 +10,7 @@ import Bluebird from "bluebird" import chalk from "chalk" import { keyBy, flatten } from "lodash" -import { Module } from "./types/module" +import { GardenModule } from "./types/module" import { BaseTask } from "./tasks/base" import { GraphResults } from "./task-graph" import { isModuleLinked } from "./util/ext-source-util" @@ -22,7 +22,7 @@ import { ConfigurationError } from "./exceptions" import { uniqByName } from "./util/util" import { printEmoji, renderDivider } from "./logger/util" -export type ProcessHandler = (graph: ConfigGraph, module: Module) => Promise +export type ProcessHandler = (graph: ConfigGraph, module: GardenModule) => Promise interface ProcessParams { garden: Garden @@ -36,7 +36,7 @@ interface ProcessParams { } export interface ProcessModulesParams extends ProcessParams { - modules: Module[] + modules: GardenModule[] } export interface ProcessResults { diff --git a/core/src/sdk/index.ts b/core/src/sdk/index.ts new file mode 100644 index 0000000000..946d63849a --- /dev/null +++ b/core/src/sdk/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2018-2020 Garden Technologies, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +export { createGardenPlugin } from "../types/plugin/plugin" +export { GardenModule } from "../types/module" +export { ProviderConfig, Provider } from "../config/provider" diff --git a/core/src/tasks/build.ts b/core/src/tasks/build.ts index 72048231c7..88f69f01f5 100644 --- a/core/src/tasks/build.ts +++ b/core/src/tasks/build.ts @@ -8,7 +8,7 @@ import Bluebird from "bluebird" import chalk from "chalk" -import { Module, getModuleKey } from "../types/module" +import { GardenModule, getModuleKey } from "../types/module" import { BuildResult } from "../types/plugin/module/build" import { BaseTask, TaskType } from "../tasks/base" import { Garden } from "../garden" @@ -22,7 +22,7 @@ export interface BuildTaskParams { garden: Garden graph: ConfigGraph log: LogEntry - module: Module + module: GardenModule force: boolean } @@ -32,7 +32,7 @@ export class BuildTask extends BaseTask { concurrencyLimit = 5 private graph: ConfigGraph - private module: Module + private module: GardenModule constructor({ garden, graph, log, module, force }: BuildTaskParams & { _guard: true }) { // Note: The _guard attribute is to prevent accidentally bypassing the factory method @@ -80,7 +80,7 @@ export class BuildTask extends BaseTask { const deps = this.graph.getDependencies({ nodeType: "build", name: this.getName(), recursive: false }) const buildTasks = flatten( - await Bluebird.map(deps.build, async (m: Module) => { + await Bluebird.map(deps.build, async (m: GardenModule) => { return BuildTask.factory({ garden: this.garden, graph: this.graph, diff --git a/core/src/tasks/helpers.ts b/core/src/tasks/helpers.ts index 27acecf69a..37c38e43e2 100644 --- a/core/src/tasks/helpers.ts +++ b/core/src/tasks/helpers.ts @@ -10,7 +10,7 @@ import Bluebird from "bluebird" import { intersection, flatten, uniqBy } from "lodash" import { DeployTask } from "./deploy" import { Garden } from "../garden" -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { ConfigGraph } from "../config-graph" import { LogEntry } from "../logger/log-entry" import { BaseTask } from "./base" @@ -31,7 +31,7 @@ export async function getModuleWatchTasks({ garden: Garden log: LogEntry graph: ConfigGraph - module: Module + module: GardenModule hotReloadServiceNames: string[] }): Promise { let buildTasks: BaseTask[] = [] diff --git a/core/src/tasks/publish.ts b/core/src/tasks/publish.ts index 0cd29f8383..d82828af94 100644 --- a/core/src/tasks/publish.ts +++ b/core/src/tasks/publish.ts @@ -8,7 +8,7 @@ import chalk from "chalk" import { BuildTask } from "./build" -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { PublishResult } from "../types/plugin/module/publishModule" import { BaseTask, TaskType } from "../tasks/base" import { Garden } from "../garden" @@ -19,7 +19,7 @@ export interface PublishTaskParams { garden: Garden graph: ConfigGraph log: LogEntry - module: Module + module: GardenModule forceBuild: boolean } @@ -28,7 +28,7 @@ export class PublishTask extends BaseTask { concurrencyLimit = 5 private graph: ConfigGraph - private module: Module + private module: GardenModule private forceBuild: boolean constructor({ garden, graph, log, module, forceBuild }: PublishTaskParams) { diff --git a/core/src/tasks/resolve-module.ts b/core/src/tasks/resolve-module.ts index 2c6a52585a..c9a84942b8 100644 --- a/core/src/tasks/resolve-module.ts +++ b/core/src/tasks/resolve-module.ts @@ -7,7 +7,7 @@ */ import chalk from "chalk" -import { Module, moduleFromConfig, getModuleKey } from "../types/module" +import { GardenModule, moduleFromConfig, getModuleKey } from "../types/module" import { BaseTask, TaskType } from "../tasks/base" import { Garden } from "../garden" import { LogEntry } from "../logger/log-entry" @@ -203,7 +203,7 @@ export class ResolveModuleTask extends BaseTask { return `resolving module ${this.getName()}` } - async process(dependencyResults: GraphResults): Promise { + async process(dependencyResults: GraphResults): Promise { const resolvedConfig = dependencyResults["resolve-module-config." + this.getName()]!.output as ModuleConfig const dependencyModules = getResolvedModules(dependencyResults) @@ -217,8 +217,8 @@ function getResolvedModuleConfigs(dependencyResults: GraphResults): ModuleConfig .map((r) => r!.output) as ModuleConfig[] } -export function getResolvedModules(dependencyResults: GraphResults): Module[] { +export function getResolvedModules(dependencyResults: GraphResults): GardenModule[] { return Object.values(dependencyResults) .filter((r) => r && r.type === "resolve-module") - .map((r) => r!.output) as Module[] + .map((r) => r!.output) as GardenModule[] } diff --git a/core/src/tasks/stage-build.ts b/core/src/tasks/stage-build.ts index d2ac407de8..8bce18d05d 100644 --- a/core/src/tasks/stage-build.ts +++ b/core/src/tasks/stage-build.ts @@ -9,7 +9,7 @@ import Bluebird from "bluebird" import chalk from "chalk" import pluralize from "pluralize" -import { Module, getModuleKey } from "../types/module" +import { GardenModule, getModuleKey } from "../types/module" import { BuildResult } from "../types/plugin/module/build" import { BaseTask, TaskType } from "../tasks/base" import { Garden } from "../garden" @@ -21,7 +21,7 @@ export interface StageBuildTaskParams { garden: Garden graph: ConfigGraph log: LogEntry - module: Module + module: GardenModule force: boolean dependencies?: BaseTask[] } @@ -32,7 +32,7 @@ export class StageBuildTask extends BaseTask { concurrencyLimit = 10 private graph: ConfigGraph - private module: Module + private module: GardenModule private extraDependencies: BaseTask[] constructor({ garden, graph, log, module, force, dependencies }: StageBuildTaskParams) { @@ -45,7 +45,7 @@ export class StageBuildTask extends BaseTask { async resolveDependencies() { const deps = this.graph.getDependencies({ nodeType: "build", name: this.getName(), recursive: false }).build - const stageDeps = await Bluebird.map(deps, async (m: Module) => { + const stageDeps = await Bluebird.map(deps, async (m: GardenModule) => { return new StageBuildTask({ garden: this.garden, graph: this.graph, diff --git a/core/src/tasks/test.ts b/core/src/tasks/test.ts index 7dbbffcaab..43098d3c73 100644 --- a/core/src/tasks/test.ts +++ b/core/src/tasks/test.ts @@ -11,7 +11,7 @@ import chalk from "chalk" import { find, includes } from "lodash" import minimatch = require("minimatch") -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { TestConfig } from "../config/test" import { ModuleVersion } from "../vcs/vcs" import { DeployTask } from "./deploy" @@ -37,7 +37,7 @@ export interface TestTaskParams { garden: Garden log: LogEntry graph: ConfigGraph - module: Module + module: GardenModule testConfig: TestConfig force: boolean forceBuild: boolean @@ -48,7 +48,7 @@ export interface TestTaskParams { export class TestTask extends BaseTask { type: TaskType = "test" - private module: Module + private module: GardenModule private graph: ConfigGraph private testConfig: TestConfig private forceBuild: boolean @@ -238,7 +238,7 @@ export async function getTestTasks({ garden: Garden log: LogEntry graph: ConfigGraph - module: Module + module: GardenModule filterNames?: string[] hotReloadServiceNames?: string[] force?: boolean @@ -272,7 +272,7 @@ export async function getTestTasks({ export async function getTestVersion( garden: Garden, graph: ConfigGraph, - module: Module, + module: GardenModule, testConfig: TestConfig ): Promise { const moduleDeps = graph diff --git a/core/src/types/module.ts b/core/src/types/module.ts index 9b06a684d3..a7977b5722 100644 --- a/core/src/types/module.ts +++ b/core/src/types/module.ts @@ -24,7 +24,7 @@ export interface FileCopySpec { /** * The Module interface adds several internally managed keys to the ModuleConfig type. */ -export interface Module +export interface GardenModule extends ModuleConfig { buildPath: string buildMetadataPath: string @@ -82,7 +82,7 @@ export const moduleSchema = () => .description("The names of all the tasks and services that the tasks in this module depend on."), }) -export interface ModuleMap { +export interface ModuleMap { [key: string]: T } @@ -93,13 +93,13 @@ export interface ModuleConfigMap { export async function moduleFromConfig( garden: Garden, config: ModuleConfig, - buildDependencies: Module[] -): Promise { + buildDependencies: GardenModule[] +): Promise { const version = await garden.resolveVersion(config, config.build.dependencies) const moduleTypes = await garden.getModuleTypes() const compatibleTypes = [config.type, ...getModuleTypeBases(moduleTypes[config.type], moduleTypes).map((t) => t.name)] - const module: Module = { + const module: GardenModule = { ...cloneDeep(config), buildPath: await garden.buildDir.buildPath(config), diff --git a/core/src/types/plugin/base.ts b/core/src/types/plugin/base.ts index 0d04326a04..30a63f08e4 100644 --- a/core/src/types/plugin/base.ts +++ b/core/src/types/plugin/base.ts @@ -8,7 +8,7 @@ import { LogEntry } from "../../logger/log-entry" import { PluginContext, pluginContextSchema } from "../../plugin-context" -import { Module, moduleSchema } from "../module" +import { GardenModule, moduleSchema } from "../module" import { RuntimeContext, runtimeContextSchema } from "../../runtime-context" import { Service, serviceSchema } from "../service" import { Task } from "../task" @@ -37,7 +37,7 @@ export const actionParamsSchema = () => log: logEntrySchema(), }) -export interface PluginModuleActionParamsBase extends PluginActionParamsBase { +export interface PluginModuleActionParamsBase extends PluginActionParamsBase { module: T } export const moduleActionParamsSchema = () => @@ -45,8 +45,10 @@ export const moduleActionParamsSchema = () => module: moduleSchema(), }) -export interface PluginServiceActionParamsBase - extends PluginModuleActionParamsBase { +export interface PluginServiceActionParamsBase< + M extends GardenModule = GardenModule, + S extends GardenModule = GardenModule +> extends PluginModuleActionParamsBase { runtimeContext?: RuntimeContext service: Service } @@ -56,7 +58,8 @@ export const serviceActionParamsSchema = () => service: serviceSchema(), }) -export interface PluginTaskActionParamsBase extends PluginModuleActionParamsBase { +export interface PluginTaskActionParamsBase + extends PluginModuleActionParamsBase { task: Task } export const taskActionParamsSchema = () => diff --git a/core/src/types/plugin/command.ts b/core/src/types/plugin/command.ts index b95cc675af..526368efbb 100644 --- a/core/src/types/plugin/command.ts +++ b/core/src/types/plugin/command.ts @@ -9,7 +9,7 @@ import { LogEntry } from "../../logger/log-entry" import { PluginContext, pluginContextSchema } from "../../plugin-context" import { joi, joiArray, joiIdentifier, joiIdentifierDescription } from "../../config/common" -import { Module, moduleSchema } from "../module" +import { GardenModule, moduleSchema } from "../module" import { logEntrySchema } from "./base" // TODO: parse args and opts with a schema @@ -17,7 +17,7 @@ export interface PluginCommandParams { ctx: PluginContext args: string[] log: LogEntry - modules: Module[] + modules: GardenModule[] } export const pluginParamsSchema = () => diff --git a/core/src/types/plugin/module/build.ts b/core/src/types/plugin/module/build.ts index cddb233ec4..da2a2fe726 100644 --- a/core/src/types/plugin/module/build.ts +++ b/core/src/types/plugin/module/build.ts @@ -7,11 +7,11 @@ */ import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { PluginModuleActionParamsBase, moduleActionParamsSchema } from "../base" import { joi } from "../../../config/common" -export interface BuildModuleParams extends PluginModuleActionParamsBase {} +export interface BuildModuleParams extends PluginModuleActionParamsBase {} export interface BuildResult { buildLog?: string diff --git a/core/src/types/plugin/module/configure.ts b/core/src/types/plugin/module/configure.ts index 007a563415..aafe0cc233 100644 --- a/core/src/types/plugin/module/configure.ts +++ b/core/src/types/plugin/module/configure.ts @@ -7,20 +7,20 @@ */ import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { PluginContext, pluginContextSchema } from "../../../plugin-context" import { logEntrySchema, PluginActionContextParams } from "../base" import { baseModuleSpecSchema, ModuleConfig, moduleConfigSchema } from "../../../config/module" import { joi } from "../../../config/common" import { LogEntry } from "../../../logger/log-entry" -export interface ConfigureModuleParams extends PluginActionContextParams { +export interface ConfigureModuleParams extends PluginActionContextParams { ctx: PluginContext log: LogEntry moduleConfig: T["_config"] } -export interface ConfigureModuleResult { +export interface ConfigureModuleResult { moduleConfig: ModuleConfig< T["spec"], T["serviceConfigs"][0]["spec"], diff --git a/core/src/types/plugin/module/getBuildStatus.ts b/core/src/types/plugin/module/getBuildStatus.ts index 83240d2ef3..248e029892 100644 --- a/core/src/types/plugin/module/getBuildStatus.ts +++ b/core/src/types/plugin/module/getBuildStatus.ts @@ -7,11 +7,11 @@ */ import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { PluginModuleActionParamsBase, moduleActionParamsSchema } from "../base" import { joi } from "../../../config/common" -export interface GetBuildStatusParams extends PluginModuleActionParamsBase {} +export interface GetBuildStatusParams extends PluginModuleActionParamsBase {} export interface BuildStatus { ready: boolean diff --git a/core/src/types/plugin/module/getTestResult.ts b/core/src/types/plugin/module/getTestResult.ts index eea5b2f10f..0382e8252b 100644 --- a/core/src/types/plugin/module/getTestResult.ts +++ b/core/src/types/plugin/module/getTestResult.ts @@ -7,12 +7,12 @@ */ import { dedent, deline } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { PluginModuleActionParamsBase, moduleActionParamsSchema, RunResult, runResultSchema } from "../base" import { ModuleVersion, moduleVersionSchema } from "../../../vcs/vcs" import { joi, joiPrimitive } from "../../../config/common" -export interface GetTestResultParams extends PluginModuleActionParamsBase { +export interface GetTestResultParams extends PluginModuleActionParamsBase { testName: string testVersion: ModuleVersion } diff --git a/core/src/types/plugin/module/publishModule.ts b/core/src/types/plugin/module/publishModule.ts index 70afeeac99..00004ba08e 100644 --- a/core/src/types/plugin/module/publishModule.ts +++ b/core/src/types/plugin/module/publishModule.ts @@ -7,11 +7,11 @@ */ import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { PluginModuleActionParamsBase, moduleActionParamsSchema } from "../base" import { joi } from "../../../config/common" -export interface PublishModuleParams extends PluginModuleActionParamsBase {} +export interface PublishModuleParams extends PluginModuleActionParamsBase {} export interface PublishResult { published: boolean diff --git a/core/src/types/plugin/module/runModule.ts b/core/src/types/plugin/module/runModule.ts index d493e6da94..cd1f1bca25 100644 --- a/core/src/types/plugin/module/runModule.ts +++ b/core/src/types/plugin/module/runModule.ts @@ -7,12 +7,12 @@ */ import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { PluginModuleActionParamsBase, moduleActionParamsSchema, runBaseParams, runResultSchema } from "../base" import { RuntimeContext } from "../../../runtime-context" import { joiArray, joi } from "../../../config/common" -export interface RunModuleParams extends PluginModuleActionParamsBase { +export interface RunModuleParams extends PluginModuleActionParamsBase { command?: string[] args: string[] interactive: boolean diff --git a/core/src/types/plugin/module/testModule.ts b/core/src/types/plugin/module/testModule.ts index 62c15dece1..bf843b2e1c 100644 --- a/core/src/types/plugin/module/testModule.ts +++ b/core/src/types/plugin/module/testModule.ts @@ -7,7 +7,7 @@ */ import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { PluginModuleActionParamsBase, artifactsPathSchema } from "../base" import { RuntimeContext } from "../../../runtime-context" import { ModuleVersion } from "../../../vcs/vcs" @@ -15,7 +15,7 @@ import { testConfigSchema } from "../../../config/test" import { runModuleBaseSchema } from "./runModule" import { testResultSchema, testVersionSchema } from "./getTestResult" -export interface TestModuleParams extends PluginModuleActionParamsBase { +export interface TestModuleParams extends PluginModuleActionParamsBase { artifactsPath: string interactive: boolean runtimeContext: RuntimeContext diff --git a/core/src/types/plugin/plugin.ts b/core/src/types/plugin/plugin.ts index 757294fc0b..59a4e52855 100644 --- a/core/src/types/plugin/plugin.ts +++ b/core/src/types/plugin/plugin.ts @@ -31,7 +31,7 @@ import { RunTaskParams, RunTaskResult, runTask } from "./task/runTask" import { SetSecretParams, SetSecretResult, setSecret } from "./provider/setSecret" import { TestModuleParams, testModule } from "./module/testModule" import { joiArray, joiIdentifier, joi, joiSchema } from "../../config/common" -import { Module } from "../module" +import { GardenModule } from "../module" import { RunResult } from "./base" import { ServiceStatus } from "../service" import { mapValues } from "lodash" @@ -76,23 +76,24 @@ export type PluginActionHandlers = { [P in keyof PluginActionParams]: ActionHandler } -export type ModuleActionHandlers = { +export type ModuleActionHandlers = { [P in keyof ModuleActionParams]: ModuleActionHandler[P], ModuleActionOutputs[P]> } -export type ServiceActionHandlers = { +export type ServiceActionHandlers = { [P in keyof ServiceActionParams]: ModuleActionHandler[P], ServiceActionOutputs[P]> } -export type TaskActionHandlers = { +export type TaskActionHandlers = { [P in keyof TaskActionParams]: ModuleActionHandler[P], TaskActionOutputs[P]> } -export type ModuleAndRuntimeActionHandlers = ModuleActionHandlers & +export type ModuleAndRuntimeActionHandlers = ModuleActionHandlers & ServiceActionHandlers & TaskActionHandlers -export type AllActionHandlers = PluginActionHandlers & ModuleAndRuntimeActionHandlers +// export type AllActionHandlers = PluginActionHandlers & +// ModuleAndRuntimeActionHandlers export type PluginActionName = keyof PluginActionHandlers export type ServiceActionName = keyof ServiceActionParams @@ -187,7 +188,7 @@ export function getPluginActionDescriptions(): PluginActionDescriptions { return _pluginActionDescriptions } -interface _ServiceActionParams { +interface _ServiceActionParams { deployService: DeployServiceParams deleteService: DeleteServiceParams execInService: ExecInServiceParams @@ -200,7 +201,7 @@ interface _ServiceActionParams { } // Specify base parameter more precisely than the base schema -export type ServiceActionParams = { +export type ServiceActionParams = { [P in keyof _ServiceActionParams]: _ServiceActionParams[P] & { base?: WrappedModuleActionHandler<_ServiceActionParams[P], ServiceActionOutputs[P]> } @@ -230,13 +231,13 @@ const serviceActionDescriptions: { [P in ServiceActionName]: () => PluginActionD stopPortForward, } -interface _TaskActionParams { +interface _TaskActionParams { getTaskResult: GetTaskResultParams runTask: RunTaskParams } // Specify base parameter more precisely than the base schema -export type TaskActionParams = { +export type TaskActionParams = { [P in keyof _TaskActionParams]: _TaskActionParams[P] & { base?: WrappedModuleActionHandler<_TaskActionParams[P], TaskActionOutputs[P]> } @@ -252,7 +253,7 @@ const taskActionDescriptions: { [P in TaskActionName]: () => PluginActionDescrip runTask, } -interface _ModuleActionParams { +interface _ModuleActionParams { configure: ConfigureModuleParams suggestModules: SuggestModulesParams getBuildStatus: GetBuildStatusParams @@ -264,7 +265,7 @@ interface _ModuleActionParams { } // Specify base parameter more precisely than the base schema -export type ModuleActionParams = { +export type ModuleActionParams = { [P in keyof _ModuleActionParams]: _ModuleActionParams[P] & { base?: WrappedModuleActionHandler<_ModuleActionParams[P], ModuleActionOutputs[P]> } @@ -346,7 +347,7 @@ export interface ModuleTypeExtension { name: string } -export interface ModuleTypeDefinition extends ModuleTypeExtension { +export interface ModuleTypeDefinition extends ModuleTypeExtension { base?: string docs: string // TODO: specify the schemas using primitives (e.g. JSONSchema/OpenAPI) and not Joi objects @@ -357,7 +358,7 @@ export interface ModuleTypeDefinition extends ModuleTypeExtension { title?: string } -export interface ModuleType extends ModuleTypeDefinition { +export interface ModuleType extends ModuleTypeDefinition { plugin: GardenPlugin needsBuild: boolean } @@ -366,7 +367,7 @@ export interface ModuleTypeMap { [name: string]: ModuleType } -interface GardenPluginSpec { +export interface GardenPluginSpec { name: string base?: string docs?: string @@ -584,11 +585,7 @@ export const pluginModuleSchema = () => .description("A module containing a Garden plugin.") // This doesn't do much at the moment, but it makes sense to make this an SDK function to make it more future-proof -export function createGardenPlugin(spec: GardenPluginSpec | (() => GardenPluginSpec)): GardenPlugin { - if (typeof spec === "function") { - spec = spec() - } - +export function createGardenPlugin(spec: GardenPluginSpec): GardenPlugin { return { ...spec, dependencies: spec.dependencies || [], diff --git a/core/src/types/plugin/provider/augmentGraph.ts b/core/src/types/plugin/provider/augmentGraph.ts index a8dfec25ff..54e51143f3 100644 --- a/core/src/types/plugin/provider/augmentGraph.ts +++ b/core/src/types/plugin/provider/augmentGraph.ts @@ -11,10 +11,10 @@ import { dedent } from "../../../util/string" import { joi, joiArray, joiIdentifier, joiIdentifierMap } from "../../../config/common" import { baseModuleSpecSchema, AddModuleSpec } from "../../../config/module" import { providerSchema, ProviderMap } from "../../../config/provider" -import { Module, moduleSchema } from "../../module" +import { GardenModule, moduleSchema } from "../../module" export interface AugmentGraphParams extends PluginActionParamsBase { - modules: Module[] + modules: GardenModule[] providers: ProviderMap } diff --git a/core/src/types/plugin/service/deleteService.ts b/core/src/types/plugin/service/deleteService.ts index bb92561e2f..bc1c84eaae 100644 --- a/core/src/types/plugin/service/deleteService.ts +++ b/core/src/types/plugin/service/deleteService.ts @@ -8,10 +8,10 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { serviceStatusSchema } from "../../service" -export interface DeleteServiceParams +export interface DeleteServiceParams extends PluginServiceActionParamsBase {} export const deleteService = () => ({ diff --git a/core/src/types/plugin/service/deployService.ts b/core/src/types/plugin/service/deployService.ts index 9098bfe711..d54e6d1a4e 100644 --- a/core/src/types/plugin/service/deployService.ts +++ b/core/src/types/plugin/service/deployService.ts @@ -8,12 +8,12 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { RuntimeContext, runtimeContextSchema } from "../../../runtime-context" import { serviceStatusSchema } from "../../service" import { joi } from "../../../config/common" -export interface DeployServiceParams +export interface DeployServiceParams extends PluginServiceActionParamsBase { force: boolean hotReload: boolean diff --git a/core/src/types/plugin/service/execInService.ts b/core/src/types/plugin/service/execInService.ts index 213bc6f80a..1d24336dca 100644 --- a/core/src/types/plugin/service/execInService.ts +++ b/core/src/types/plugin/service/execInService.ts @@ -8,10 +8,10 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { joiArray, joi } from "../../../config/common" -export interface ExecInServiceParams +export interface ExecInServiceParams extends PluginServiceActionParamsBase { command: string[] interactive: boolean diff --git a/core/src/types/plugin/service/getPortForward.ts b/core/src/types/plugin/service/getPortForward.ts index edfc5b24a1..a4a12441e3 100644 --- a/core/src/types/plugin/service/getPortForward.ts +++ b/core/src/types/plugin/service/getPortForward.ts @@ -8,15 +8,14 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { ForwardablePort, forwardablePortKeys } from "../../service" import { joi } from "../../../config/common" -export type GetPortForwardParams = PluginServiceActionParamsBase< - M, - S -> & - ForwardablePort +export type GetPortForwardParams< + M extends GardenModule = GardenModule, + S extends GardenModule = GardenModule +> = PluginServiceActionParamsBase & ForwardablePort export interface GetPortForwardResult { hostname: string diff --git a/core/src/types/plugin/service/getServiceLogs.ts b/core/src/types/plugin/service/getServiceLogs.ts index e4665899f2..53c32f8b39 100644 --- a/core/src/types/plugin/service/getServiceLogs.ts +++ b/core/src/types/plugin/service/getServiceLogs.ts @@ -9,11 +9,11 @@ import { Stream } from "ts-stream" import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { runtimeContextSchema } from "../../../runtime-context" import { joi } from "../../../config/common" -export interface GetServiceLogsParams +export interface GetServiceLogsParams extends PluginServiceActionParamsBase { stream: Stream follow: boolean diff --git a/core/src/types/plugin/service/getServiceStatus.ts b/core/src/types/plugin/service/getServiceStatus.ts index d14619e12a..8351725670 100644 --- a/core/src/types/plugin/service/getServiceStatus.ts +++ b/core/src/types/plugin/service/getServiceStatus.ts @@ -8,14 +8,14 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { serviceStatusSchema } from "../../service" import { RuntimeContext, runtimeContextSchema } from "../../../runtime-context" import { joi } from "../../../config/common" export type hotReloadStatus = "enabled" | "disabled" -export interface GetServiceStatusParams +export interface GetServiceStatusParams extends PluginServiceActionParamsBase { hotReload: boolean runtimeContext: RuntimeContext diff --git a/core/src/types/plugin/service/hotReloadService.ts b/core/src/types/plugin/service/hotReloadService.ts index e1520ebe4a..04d76822d3 100644 --- a/core/src/types/plugin/service/hotReloadService.ts +++ b/core/src/types/plugin/service/hotReloadService.ts @@ -8,10 +8,10 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { joi } from "../../../config/common" -export interface HotReloadServiceParams +export interface HotReloadServiceParams extends PluginServiceActionParamsBase {} export interface HotReloadServiceResult {} diff --git a/core/src/types/plugin/service/runService.ts b/core/src/types/plugin/service/runService.ts index b8563b27e6..83669505ca 100644 --- a/core/src/types/plugin/service/runService.ts +++ b/core/src/types/plugin/service/runService.ts @@ -8,10 +8,10 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema, runBaseParams, runResultSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { RuntimeContext } from "../../../runtime-context" -export interface RunServiceParams +export interface RunServiceParams extends PluginServiceActionParamsBase { interactive: boolean runtimeContext: RuntimeContext diff --git a/core/src/types/plugin/service/stopPortForward.ts b/core/src/types/plugin/service/stopPortForward.ts index b479e835c1..542e8ecc6d 100644 --- a/core/src/types/plugin/service/stopPortForward.ts +++ b/core/src/types/plugin/service/stopPortForward.ts @@ -8,15 +8,14 @@ import { PluginServiceActionParamsBase, serviceActionParamsSchema } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { ForwardablePort, forwardablePortKeys } from "../../service" import { joi } from "../../../config/common" -export type StopPortForwardParams = PluginServiceActionParamsBase< - M, - S -> & - ForwardablePort +export type StopPortForwardParams< + M extends GardenModule = GardenModule, + S extends GardenModule = GardenModule +> = PluginServiceActionParamsBase & ForwardablePort export const stopPortForward = () => ({ description: dedent` diff --git a/core/src/types/plugin/task/getTaskResult.ts b/core/src/types/plugin/task/getTaskResult.ts index a904da9495..4bc27f36f7 100644 --- a/core/src/types/plugin/task/getTaskResult.ts +++ b/core/src/types/plugin/task/getTaskResult.ts @@ -8,7 +8,7 @@ import { taskActionParamsSchema, PluginTaskActionParamsBase } from "../base" import { dedent, deline } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { moduleVersionSchema, ModuleVersion } from "../../../vcs/vcs" import { joi, joiPrimitive } from "../../../config/common" @@ -17,7 +17,7 @@ export const taskVersionSchema = () => The task run's version. In addition to the parent module's version, this also factors in the module versions of the tasks's runtime dependencies (if any).`) -export interface GetTaskResultParams extends PluginTaskActionParamsBase { +export interface GetTaskResultParams extends PluginTaskActionParamsBase { taskVersion: ModuleVersion } diff --git a/core/src/types/plugin/task/runTask.ts b/core/src/types/plugin/task/runTask.ts index 7fefc05496..9a45798985 100644 --- a/core/src/types/plugin/task/runTask.ts +++ b/core/src/types/plugin/task/runTask.ts @@ -14,13 +14,13 @@ import { artifactsPathSchema, } from "../base" import { dedent } from "../../../util/string" -import { Module } from "../../module" +import { GardenModule } from "../../module" import { RuntimeContext } from "../../../runtime-context" import { ModuleVersion } from "../../../vcs/vcs" import { taskVersionSchema, taskResultSchema } from "./getTaskResult" import { PrimitiveMap } from "../../../config/common" -export interface RunTaskParams extends PluginTaskActionParamsBase { +export interface RunTaskParams extends PluginTaskActionParamsBase { artifactsPath: string interactive: boolean runtimeContext: RuntimeContext diff --git a/core/src/types/service.ts b/core/src/types/service.ts index 6a41cdface..33c155bd04 100644 --- a/core/src/types/service.ts +++ b/core/src/types/service.ts @@ -9,13 +9,13 @@ import normalizeUrl from "normalize-url" import { format } from "url" import { joiUserIdentifier, joi, joiIdentifier, joiArray, PrimitiveMap, joiVariables } from "../config/common" -import { Module } from "./module" +import { GardenModule } from "./module" import { ServiceConfig, serviceConfigSchema } from "../config/service" import dedent = require("dedent") import { uniq } from "lodash" import { ConfigGraph } from "../config-graph" -export interface Service { +export interface Service { name: string module: M config: M["serviceConfigs"][0] @@ -40,7 +40,7 @@ export const serviceSchema = () => spec: joi.object().description("The raw configuration of the service (specific to each plugin)."), }) -export function serviceFromConfig( +export function serviceFromConfig( graph: ConfigGraph, module: M, config: ServiceConfig diff --git a/core/src/types/task.ts b/core/src/types/task.ts index 5e4265ba7c..e6a1b98ee4 100644 --- a/core/src/types/task.ts +++ b/core/src/types/task.ts @@ -6,10 +6,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Module } from "./module" +import { GardenModule } from "./module" import { TaskConfig } from "../config/task" -export interface Task { +export interface Task { name: string description?: string module: M @@ -18,7 +18,7 @@ export interface Task { spec: M["taskConfigs"][0]["spec"] } -export function taskFromConfig(module: M, config: TaskConfig): Task { +export function taskFromConfig(module: M, config: TaskConfig): Task { return { name: config.name, module, diff --git a/core/src/types/test.ts b/core/src/types/test.ts index d9852d0514..41a43d0560 100644 --- a/core/src/types/test.ts +++ b/core/src/types/test.ts @@ -6,10 +6,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Module } from "./module" +import { GardenModule } from "./module" import { TestConfig } from "../config/test" -export interface Test { +export interface Test { name: string module: M disabled: boolean @@ -17,7 +17,7 @@ export interface Test { spec: M["testConfigs"][0]["spec"] } -export function testFromConfig(module: M, config: TestConfig): Test { +export function testFromConfig(module: M, config: TestConfig): Test { return { name: config.name, module, diff --git a/core/src/util/ext-source-util.ts b/core/src/util/ext-source-util.ts index c90120e24e..eaf203bf2d 100644 --- a/core/src/util/ext-source-util.ts +++ b/core/src/util/ext-source-util.ts @@ -13,7 +13,7 @@ import pathIsInside = require("path-is-inside") import { PROJECT_SOURCES_DIR_NAME, MODULE_SOURCES_DIR_NAME } from "../constants" import { LinkedSource, localConfigKeys } from "../config-store" import { ParameterError } from "../exceptions" -import { Module } from "../types/module" +import { GardenModule } from "../types/module" import { join } from "path" import { Garden } from "../garden" import { hashString } from "./util" @@ -45,7 +45,7 @@ export function hashRepoUrl(url: string) { return hashString(url, 10) } -export function hasRemoteSource(module: Module): boolean { +export function hasRemoteSource(module: GardenModule): boolean { return !!module.repositoryUrl } export function getConfigKey(type: ExternalSourceType): string { @@ -56,7 +56,7 @@ export function getConfigKey(type: ExternalSourceType): string { * Check if any module is linked, including those within an external project source. * Returns true if module path is not under the project root or alternatively if the module is a Garden module. */ -export function isModuleLinked(module: Module, garden: Garden) { +export function isModuleLinked(module: GardenModule, garden: Garden) { const isPluginModule = !!module.plugin return !pathIsInside(module.path, garden.projectRoot) && !isPluginModule } diff --git a/core/src/watch.ts b/core/src/watch.ts index 278533a8b4..3205050ca4 100644 --- a/core/src/watch.ts +++ b/core/src/watch.ts @@ -9,7 +9,7 @@ import { watch, FSWatcher } from "chokidar" import { parse, basename, resolve } from "path" import { pathToCacheContext } from "./cache" -import { Module } from "./types/module" +import { GardenModule } from "./types/module" import { Garden } from "./garden" import { LogEntry } from "./logger/log-entry" import { sleep } from "./util/util" @@ -22,7 +22,7 @@ import { EventEmitter } from "events" // How long we wait between processing added files and directories const DEFAULT_BUFFER_INTERVAL = 400 -export type ChangeHandler = (module: Module | null, configChanged: boolean) => Promise +export type ChangeHandler = (module: GardenModule | null, configChanged: boolean) => Promise type ChangeType = "added" | "changed" | "removed" @@ -48,7 +48,7 @@ export class Watcher extends EventEmitter { private garden: Garden, private log: LogEntry, private paths: string[], - private modules: Module[], + private modules: GardenModule[], private bufferInterval: number = DEFAULT_BUFFER_INTERVAL ) { super() @@ -388,7 +388,7 @@ export class Watcher extends EventEmitter { } } - private invalidateCached(modules: Module[]) { + private invalidateCached(modules: GardenModule[]) { // invalidate the cache for anything attached to the module path or upwards in the directory tree for (const module of modules) { const cacheContext = pathToCacheContext(module.path) diff --git a/core/test/helpers.ts b/core/test/helpers.ts index c8a75afbe9..7f2cc52c90 100644 --- a/core/test/helpers.ts +++ b/core/test/helpers.ts @@ -49,7 +49,7 @@ import { RunTaskParams, RunTaskResult } from "../src/types/plugin/task/runTask" import { SuiteFunction, TestFunction } from "mocha" import { GardenBaseError, GardenError } from "../src/exceptions" import { RuntimeContext } from "../src/runtime-context" -import { Module } from "../src/types/module" +import { GardenModule } from "../src/types/module" import { AnalyticsGlobalConfig } from "../src/config-store" import { WorkflowConfig } from "../src/config/workflow" @@ -371,7 +371,7 @@ export class TestGarden extends Garden { log: LogEntry runtimeContext?: RuntimeContext includeDisabled?: boolean - }): Promise { + }): Promise { const graph = await this.getConfigGraph(log, runtimeContext) return graph.getModules({ includeDisabled }) } diff --git a/core/test/integ/src/plugins/kubernetes/commands/pull-image.ts b/core/test/integ/src/plugins/kubernetes/commands/pull-image.ts index 7eee2e846c..84c4b68afb 100644 --- a/core/test/integ/src/plugins/kubernetes/commands/pull-image.ts +++ b/core/test/integ/src/plugins/kubernetes/commands/pull-image.ts @@ -13,7 +13,7 @@ import { getContainerTestGarden } from "../container/container" import { k8sBuildContainer } from "../../../../../../src/plugins/kubernetes/container/build" import { PluginContext } from "../../../../../../src/plugin-context" import { KubernetesProvider, KubernetesPluginContext } from "../../../../../../src/plugins/kubernetes/config" -import { Module } from "../../../../../../src/types/module" +import { GardenModule } from "../../../../../../src/types/module" import { containerHelpers } from "../../../../../../src/plugins/container/helpers" import { expect } from "chai" import { LogEntry } from "../../../../../../src/logger/log-entry" @@ -41,7 +41,7 @@ describe("pull-image plugin command", () => { ctx = garden.getPluginContext(provider) } - async function ensureImagePulled(module: Module, log: LogEntry) { + async function ensureImagePulled(module: GardenModule, log: LogEntry) { const imageId = await containerHelpers.getLocalImageId(module) const imageHash = await containerHelpers.dockerCli({ cwd: module.buildPath, @@ -54,7 +54,7 @@ describe("pull-image plugin command", () => { } grouped("cluster-docker", "remote-only").context("using an external cluster registry", () => { - let module: Module + let module: GardenModule before(async () => { await init("cluster-docker-remote-registry") @@ -78,7 +78,7 @@ describe("pull-image plugin command", () => { }) grouped("cluster-docker").context("using the in cluster registry", () => { - let module: Module + let module: GardenModule before(async () => { await init("cluster-docker") diff --git a/core/test/unit/src/actions.ts b/core/test/unit/src/actions.ts index e6cd7ce79f..7d1b0ed740 100644 --- a/core/test/unit/src/actions.ts +++ b/core/test/unit/src/actions.ts @@ -21,7 +21,7 @@ import { expectError, makeTestGardenA, stubModuleAction, projectRootA, TestGarde import { ActionRouter } from "../../../src/actions" import { Garden } from "../../../src/garden" import { LogEntry } from "../../../src/logger/log-entry" -import { Module } from "../../../src/types/module" +import { GardenModule } from "../../../src/types/module" import { ServiceLogEntry } from "../../../src/types/plugin/service/getServiceLogs" import Stream from "ts-stream" import { Task } from "../../../src/types/task" @@ -44,7 +44,7 @@ describe("ActionRouter", () => { let garden: TestGarden let log: LogEntry let actions: ActionRouter - let module: Module + let module: GardenModule let service: Service let runtimeContext: RuntimeContext let task: Task diff --git a/core/test/unit/src/plugins/maven-container/maven-container.ts b/core/test/unit/src/plugins/maven-container/maven-container.ts index 3769c60cb9..a4677c4624 100644 --- a/core/test/unit/src/plugins/maven-container/maven-container.ts +++ b/core/test/unit/src/plugins/maven-container/maven-container.ts @@ -22,7 +22,7 @@ import { import { gardenPlugin as containerPlugin } from "../../../../../src/plugins/container/container" import { PluginContext } from "../../../../../src/plugin-context" import { makeTestGarden, dataDir, expectError } from "../../../../helpers" -import { moduleFromConfig, Module } from "../../../../../src/types/module" +import { moduleFromConfig, GardenModule } from "../../../../../src/types/module" import { ModuleConfig } from "../../../../../src/config/module" import { DEFAULT_BUILD_TIMEOUT } from "../../../../../src/plugins/container/helpers" import { containerHelpers as helpers } from "../../../../../src/plugins/container/helpers" @@ -44,11 +44,11 @@ describe("maven-container", () => { const build = handlers.build! const configure = handlers.configure! const configureBase = baseHandlers.configure as WrappedModuleActionHandler< - ConfigureModuleParams>, - ConfigureModuleResult> + ConfigureModuleParams>, + ConfigureModuleResult> > const buildBase = baseHandlers.build! as WrappedModuleActionHandler< - BuildModuleParams>, + BuildModuleParams>, BuildResult >