Skip to content

Commit

Permalink
chore(plugins): re-work old plugins deprecation (#6831)
Browse files Browse the repository at this point in the history
* chore: disable too-early deprecation arning for builtin plugins

* chore: re-work deprecation for old plugins

* chore: deprecate hadolint plugin

* chore: deprecate octant plugin

* chore: deprecate contest plugin

* docs: re-generate docs

* docs: re-generate terraform docs

Follow-up docs update for #6829.
  • Loading branch information
vvagaytsev authored Feb 10, 2025
1 parent 9cb1c1e commit 97782db
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 36 deletions.
3 changes: 0 additions & 3 deletions core/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ import { deepEvaluate } from "./template/evaluate.js"
import type { ResolvedTemplate } from "./template/types.js"
import { serialiseUnresolvedTemplates } from "./template/types.js"
import type { VariablesContext } from "./config/template-contexts/variables.js"
import { reportDeprecatedPluginsUsage } from "./util/deprecations.js"

const defaultLocalAddress = "localhost"

Expand Down Expand Up @@ -276,8 +275,6 @@ function getRegisteredPlugins(params: GardenParams): RegisterPluginParam[] {
const builtinPlugins = getBuiltinPlugins(projectApiVersion)
const customPlugins = params.plugins

reportDeprecatedPluginsUsage({ apiVersion: projectApiVersion, plugins: customPlugins, log: params.log })

return [...builtinPlugins, ...customPlugins]
}

Expand Down
9 changes: 8 additions & 1 deletion core/src/plugins/hadolint/hadolint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { BaseAction } from "../../actions/base.js"
import type { BuildAction } from "../../actions/build.js"
import { sdk } from "../../plugin/sdk.js"
import { styles } from "../../logger/styles.js"
import { reportDeprecatedFeatureUsage } from "../../util/deprecations.js"

const { pathExists, readFile } = fsExtra

Expand Down Expand Up @@ -262,7 +263,13 @@ const hadolintTest = provider.createActionType({
runtimeOutputsSchema: s.object({}),
})

hadolintTest.addHandler("configure", async ({ ctx, config }) => {
hadolintTest.addHandler("configure", async ({ ctx, config, log }) => {
reportDeprecatedFeatureUsage({
apiVersion: ctx.projectApiVersion,
log,
deprecation: "hadolintPlugin",
})

let dockerfilePath = config.spec.dockerfilePath

if (!config.include) {
Expand Down
7 changes: 7 additions & 0 deletions core/src/plugins/octant/octant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { execa } from "execa"
import getPort from "get-port"
import { getK8sProvider } from "../kubernetes/util.js"
import { createGardenPlugin } from "../../plugin/plugin.js"
import { reportDeprecatedFeatureUsage } from "../../util/deprecations.js"

let octantProc: ExecaChildProcess
let octantPort: number
Expand All @@ -36,6 +37,12 @@ export const gardenPlugin = () =>
],
handlers: {
async getDashboardPage({ ctx, log }: GetDashboardPageParams) {
reportDeprecatedFeatureUsage({
apiVersion: ctx.projectApiVersion,
log,
deprecation: "octantPlugin",
})

if (!octantProc) {
const tool = ctx.tools["octant.octant"]
const k8sProvider = getK8sProvider(ctx.provider.dependencies)
Expand Down
47 changes: 18 additions & 29 deletions core/src/util/deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,25 @@ import { GardenError } from "../exceptions.js"
import { emitNonRepeatableWarning } from "../warnings.js"
import type { Log } from "../logger/log-entry.js"
import dedent from "dedent"
import { naturalList } from "./string.js"
import type { RegisterPluginParam } from "../plugin/plugin.js"

const deprecatedPluginNames: string[] = ["conftest", "conftest-container", "conftest-kubernetes", "hadolint", "octant"]
const deprecatedPluginNames = ["conftest", "conftest-container", "conftest-kubernetes", "hadolint", "octant"] as const
export type DeprecatedPluginName = (typeof deprecatedPluginNames)[number]

export function isDeprecatedPlugin(pluginName: string): boolean {
return deprecatedPluginNames.includes(pluginName)
export function isDeprecatedPlugin(pluginName: string): pluginName is DeprecatedPluginName {
for (const deprecatedPluginName of deprecatedPluginNames) {
if (deprecatedPluginName === pluginName) {
return true
}
}
return false
}

export function reportDeprecatedPluginsUsage({
apiVersion,
plugins,
log,
}: {
apiVersion: GardenApiVersion
plugins: RegisterPluginParam[]
log: Log
}) {
for (const plugin of plugins) {
const pluginName = typeof plugin === "string" ? plugin : plugin.name
if (isDeprecatedPlugin(pluginName)) {
reportDeprecatedFeatureUsage({
apiVersion,
log,
deprecation: "deprecatedPlugins",
})
}
function makePluginDeprecation(pluginName: DeprecatedPluginName, style: (s: string) => string) {
return {
contextDesc: "Garden Plugins",
featureDesc: `The plugin ${style(pluginName)}`,
hint: "This plugin is still enabled by default in Garden 0.13, but will be removed in Garden 0.14. Do not use this plugin explicitly in Garden 0.14.",
hintReferenceLink: null,
}
}

Expand Down Expand Up @@ -85,12 +77,9 @@ export function getDeprecations(style: (s: string) => string = styles.highlight)
hint: "Do not use this command. It has no effect.",
hintReferenceLink: null,
},
deprecatedPlugins: {
contextDesc: "Garden Plugins",
featureDesc: `The ${naturalList(deprecatedPluginNames.map((p) => style(p)))} plugins`,
hint: "These plugins are still enabled by default in Garden 0.13, but will be removed in Garden 0.14. Do not use these plugins explicitly in Garden 0.14.",
hintReferenceLink: null,
},
hadolintPlugin: makePluginDeprecation("hadolint", style),
octantPlugin: makePluginDeprecation("octant", style),
conftestPlugin: makePluginDeprecation("conftest", style),
} as const
}

Expand Down
12 changes: 10 additions & 2 deletions docs/guides/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Do not use this command. It has no effect.

## Garden Plugins

<h3 id="deprecatedPlugins">The `conftest`, `conftest-container`, `conftest-kubernetes`, `hadolint` and `octant` plugins</h3>
<h3 id="hadolintPlugin">The plugin `hadolint`</h3>

These plugins are still enabled by default in Garden 0.13, but will be removed in Garden 0.14. Do not use these plugins explicitly in Garden 0.14.
This plugin is still enabled by default in Garden 0.13, but will be removed in Garden 0.14. Do not use this plugin explicitly in Garden 0.14.

<h3 id="octantPlugin">The plugin `octant`</h3>

This plugin is still enabled by default in Garden 0.13, but will be removed in Garden 0.14. Do not use this plugin explicitly in Garden 0.14.

<h3 id="conftestPlugin">The plugin `conftest`</h3>

This plugin is still enabled by default in Garden 0.13, but will be removed in Garden 0.14. Do not use this plugin explicitly in Garden 0.14.
13 changes: 13 additions & 0 deletions docs/reference/providers/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ providers:
# Use the specified Terraform workspace.
workspace:

# Set to `true` to make logs from Terraform Deploy actions visible in Garden Cloud/Enterprise. Defaults to `false`
streamLogsToCloud: false

# Configure the Terraform backend.
#
# The key-value pairs defined here are set as the `-backend-config` options when Garden
Expand Down Expand Up @@ -191,6 +194,16 @@ Use the specified Terraform workspace.
| -------- | -------- |
| `string` | No |

### `providers[].streamLogsToCloud`

[providers](#providers) > streamLogsToCloud

Set to `true` to make logs from Terraform Deploy actions visible in Garden Cloud/Enterprise. Defaults to `false`

| Type | Default | Required |
| --------- | ------- | -------- |
| `boolean` | `false` | No |

### `providers[].backendConfig`

[providers](#providers) > backendConfig
Expand Down
9 changes: 8 additions & 1 deletion plugins/conftest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type { HelmDeployAction } from "@garden-io/core/build/src/plugins/kuberne
import { actionRefMatches } from "@garden-io/core/build/src/actions/base.js"
import type { Resolved } from "@garden-io/core/build/src/actions/types.js"
import { DEFAULT_TEST_TIMEOUT_SEC } from "@garden-io/core/build/src/constants.js"
import { reportDeprecatedFeatureUsage } from "@garden-io/core/build/src/util/deprecations.js"

export interface ConftestProviderConfig extends BaseProviderConfig {
policyPath: string
Expand Down Expand Up @@ -280,7 +281,13 @@ export const gardenPlugin = () =>
.description("The Helm Deploy action to validate."),
}),
handlers: <TestActionHandlers<TestAction<ConftestHelmTestConfig>>>{
configure: async ({ ctx, config }) => {
configure: async ({ ctx, config, log }) => {
reportDeprecatedFeatureUsage({
apiVersion: ctx.projectApiVersion,
log,
deprecation: "conftestPlugin",
})

let files = config.spec.files || []

if (files.length > 0) {
Expand Down

0 comments on commit 97782db

Please sign in to comment.