Skip to content

Commit

Permalink
improvement(ext-tools): always print versions in garden tools output (
Browse files Browse the repository at this point in the history
#5718)

**What this PR does / why we need it**:
To improve UX, let's always print the concrete versions of the tools in
the `garden tools` output.

This PR also does refactoring in the tool definitions. It extracts tools
versions as named constants to make the version update process easier.
The PR also adds some missing tests to verify the binary hashes for the
tools.

**Which issue(s) this PR fixes**:

Fixes #

**Special notes for your reviewer**:
  • Loading branch information
vvagaytsev committed Feb 12, 2024
1 parent f93ecc6 commit e88bb86
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 158 deletions.
2 changes: 1 addition & 1 deletion core/src/mutagen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ export const mutagenVersion = "0.15.0"
export const mutagenCliSpec: PluginToolSpec = {
name: "mutagen",
version: mutagenVersion,
description: "The mutagen synchronization tool.",
description: `The mutagen synchronization tool, v${mutagenVersion}`,
type: "binary",
_includeInGardenImage: false,
builds: [
Expand Down
125 changes: 64 additions & 61 deletions core/src/plugins/container/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,73 @@ import { getDeployedImageId } from "../kubernetes/container/util.js"
import type { DeepPrimitiveMap } from "../../config/common.js"
import { DEFAULT_DEPLOY_TIMEOUT_SEC } from "../../constants.js"
import type { ExecBuildConfig } from "../exec/build.js"
import type { PluginToolSpec } from "../../plugin/tools.js"

export type ContainerProviderConfig = GenericProviderConfig

export type ContainerProvider = Provider<ContainerProviderConfig>

export const dockerVersion = "24.0.4"
export const dockerSpec: PluginToolSpec = {
name: "docker",
version: dockerVersion,
description: `The official Docker CLI, v${dockerVersion}`,
type: "binary",
_includeInGardenImage: true,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: `https://download.docker.com/mac/static/stable/x86_64/docker-${dockerVersion}.tgz`,
sha256: "a1016b319d8fb5b92e6a4f9ae4082b0fe934bcec4a18f4ddba9b6a5778af230c",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "darwin",
architecture: "arm64",
url: `https://download.docker.com/mac/static/stable/aarch64/docker-${dockerVersion}.tgz`,
sha256: "d99ce023f984b07a57621d804f226bfeedea513ce708aba480a62f5b63631367",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "linux",
architecture: "amd64",
url: `https://download.docker.com/linux/static/stable/x86_64/docker-${dockerVersion}.tgz`,
sha256: "0ab79ae5f19e2ef5bdc3c3009c8b770dea6189e0f1e0ef4935d78fd30519b11d",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "linux",
architecture: "arm64",
url: `https://download.docker.com/linux/static/stable/aarch64/docker-${dockerVersion}.tgz`,
sha256: "193a8e1f051adce6a30a4c8486ce9b39929b9633a0da8c96444c9239859f4354",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "windows",
architecture: "amd64",
url: `https://github.com/rgl/docker-ce-windows-binaries-vagrant/releases/download/v${dockerVersion}/docker-${dockerVersion}.zip`,
sha256: "1ffb063724147d871ec01824ee458b66a85191a8ecd943ae77775b5352db12ff",
extract: {
format: "zip",
targetPath: "docker/docker.exe",
},
},
],
}

// TODO: remove in 0.14. validation should be in the action validation handler.
export async function configureContainerModule({ log, moduleConfig }: ConfigureModuleParams<ContainerModule>) {
// validate services
Expand Down Expand Up @@ -195,6 +257,7 @@ function convertContainerModuleRuntimeActions(
}

const volumeModulesReferenced: string[] = []

function configureActionVolumes(action: ContainerRuntimeActionConfig, volumeSpec: ContainerModuleVolumeSpec[]) {
volumeSpec.forEach((v) => {
const referencedPvcAction = v.module ? { kind: <const>"Deploy", name: v.module } : undefined
Expand Down Expand Up @@ -505,67 +568,7 @@ export const gardenPlugin = () =>
},
],

tools: [
{
name: "docker",
version: "24.0.4",
description: "The official Docker CLI.",
type: "binary",
_includeInGardenImage: true,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: "https://download.docker.com/mac/static/stable/x86_64/docker-24.0.4.tgz",
sha256: "a1016b319d8fb5b92e6a4f9ae4082b0fe934bcec4a18f4ddba9b6a5778af230c",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "darwin",
architecture: "arm64",
url: "https://download.docker.com/mac/static/stable/aarch64/docker-24.0.4.tgz",
sha256: "d99ce023f984b07a57621d804f226bfeedea513ce708aba480a62f5b63631367",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "linux",
architecture: "amd64",
url: "https://download.docker.com/linux/static/stable/x86_64/docker-24.0.4.tgz",
sha256: "0ab79ae5f19e2ef5bdc3c3009c8b770dea6189e0f1e0ef4935d78fd30519b11d",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "linux",
architecture: "arm64",
url: "https://download.docker.com/linux/static/stable/aarch64/docker-24.0.4.tgz",
sha256: "193a8e1f051adce6a30a4c8486ce9b39929b9633a0da8c96444c9239859f4354",
extract: {
format: "tar",
targetPath: "docker/docker",
},
},
{
platform: "windows",
architecture: "amd64",
url: "https://github.com/rgl/docker-ce-windows-binaries-vagrant/releases/download/v24.0.4/docker-24.0.4.zip",
sha256: "1ffb063724147d871ec01824ee458b66a85191a8ecd943ae77775b5352db12ff",
extract: {
format: "zip",
targetPath: "docker/docker.exe",
},
},
],
},
],
tools: [dockerSpec],
})

function validateRuntimeCommon(action: Resolved<ContainerRuntimeAction>) {
Expand Down
13 changes: 7 additions & 6 deletions core/src/plugins/hadolint/hadolint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,36 +111,37 @@ export const gardenPlugin = sdk.createGardenPlugin({

const s = sdk.schema

const hadolintVersion = "2.12.0"
gardenPlugin.addTool({
name: "hadolint",
version: "2.12.0",
description: "A Dockerfile linter.",
version: hadolintVersion,
description: `A Dockerfile linter, v${hadolintVersion}`,
type: "binary",
_includeInGardenImage: false,
builds: [
// this version has no arm support yet. If you add a later release, please add the "arm64" architecture.
{
platform: "darwin",
architecture: "amd64",
url: "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Darwin-x86_64",
url: `https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Darwin-x86_64`,
sha256: "2a5b7afcab91645c39a7cebefcd835b865f7488e69be24567f433dfc3d41cd27",
},
{
platform: "linux",
architecture: "amd64",
url: "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64",
url: `https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Linux-x86_64`,
sha256: "56de6d5e5ec427e17b74fa48d51271c7fc0d61244bf5c90e828aab8362d55010",
},
{
platform: "linux",
architecture: "arm64",
url: "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-arm64",
url: `https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Linux-arm64`,
sha256: "5798551bf19f33951881f15eb238f90aef023f11e7ec7e9f4c37961cb87c5df6",
},
{
platform: "windows",
architecture: "amd64",
url: "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Windows-x86_64.exe",
url: `https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Windows-x86_64.exe`,
sha256: "ed89a156290e15452276b2b4c84efa688a5183d3b578bfaec7cfdf986f0632a8",
},
],
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/kubernetes/helm/helm-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const helmVersion = "3.14.0"

export const helm3Spec: PluginToolSpec = {
name: "helm",
description: `The Helm CLI (version ${helmVersion}).`,
description: `The Helm CLI, v${helmVersion}`,
version: helmVersion,
type: "binary",
_includeInGardenImage: true,
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/kubernetes/kubectl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const kubectlVersion = "1.29.1"
export const kubectlSpec: PluginToolSpec = {
name: "kubectl",
version: kubectlVersion,
description: "The official Kubernetes CLI.",
description: `The official Kubernetes CLI, v${kubectlVersion}`,
type: "binary",
_includeInGardenImage: true,
builds: [
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/kubernetes/kubernetes-type/kustomize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const kustomizeVersion = "4.5.2"
export const kustomizeSpec: PluginToolSpec = {
name: "kustomize",
version: kustomizeVersion,
description: "The kustomize config management CLI.",
description: `The kustomize config management CLI, v${kustomizeVersion}`,
type: "binary",
_includeInGardenImage: true,
builds: [
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/octant/octant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const gardenPlugin = () =>
{
name: "octant",
version: "0.25.1",
description: "A web admin UI for Kubernetes.",
description: "[DEPRECATED] A web admin UI for Kubernetes, v0.25.1",
type: "binary",
_includeInGardenImage: false,
builds: [
Expand Down
16 changes: 9 additions & 7 deletions core/src/plugins/otel-collector/otel-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getOtelCollectorConfigFile } from "./config.js"
import YAML from "yaml"
import { makeTempDir } from "../../util/fs.js"
import fsExtra from "fs-extra"

const { writeFile } = fsExtra
import { streamLogs, waitForLogLine, waitForProcessExit } from "../../util/process.js"
import getPort from "get-port"
Expand Down Expand Up @@ -50,17 +51,18 @@ export const gardenPlugin = sdk.createGardenPlugin({

const s = sdk.schema

const otelCollectorVersion = "0.80.0"
gardenPlugin.addTool({
name: "otel-collector",
version: "v0.80.0",
description: "Otel collector service",
version: `v${otelCollectorVersion}`,
description: `Otel collector service, v${otelCollectorVersion}`,
type: "binary",
_includeInGardenImage: false,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.80.0/otelcol-contrib_0.80.0_darwin_amd64.tar.gz",
url: `https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${otelCollectorVersion}/otelcol-contrib_${otelCollectorVersion}_darwin_amd64.tar.gz`,
sha256: "2769c382a8296c73f57c0cfece4337599473b9bc7752e22ee4fcd8e4f1e549ce",
extract: {
format: "tar",
Expand All @@ -70,7 +72,7 @@ gardenPlugin.addTool({
{
platform: "darwin",
architecture: "arm64",
url: "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.80.0/otelcol-contrib_0.80.0_darwin_arm64.tar.gz",
url: `https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${otelCollectorVersion}/otelcol-contrib_${otelCollectorVersion}_darwin_arm64.tar.gz`,
sha256: "93149de30b8a47f7c7412a3cf2b5395662c56a5198ab5e942c320216d9a2fd80",
extract: {
format: "tar",
Expand All @@ -80,7 +82,7 @@ gardenPlugin.addTool({
{
platform: "linux",
architecture: "amd64",
url: "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.80.0/otelcol-contrib_0.80.0_linux_amd64.tar.gz",
url: `https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${otelCollectorVersion}/otelcol-contrib_${otelCollectorVersion}_linux_amd64.tar.gz`,
sha256: "6196e2ec1f8e632abb3c98505c5e111aec47ca86a6f25d9ef5afe538a7b445f0",
extract: {
format: "tar",
Expand All @@ -90,7 +92,7 @@ gardenPlugin.addTool({
{
platform: "linux",
architecture: "arm64",
url: "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.80.0/otelcol-contrib_0.80.0_linux_arm64.tar.gz",
url: `https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${otelCollectorVersion}/otelcol-contrib_${otelCollectorVersion}_linux_arm64.tar.gz`,
sha256: "19d878166dbc39821f11b6a7c2ed896726c8d5ac6c15108b66d8e874efa8db85",
extract: {
format: "tar",
Expand All @@ -100,7 +102,7 @@ gardenPlugin.addTool({
{
platform: "windows",
architecture: "amd64",
url: "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.80.0/otelcol-contrib_0.80.0_windows_amd64.tar.gz",
url: `https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${otelCollectorVersion}/otelcol-contrib_${otelCollectorVersion}_windows_amd64.tar.gz`,
sha256: "b1a971a468da6d73926b9362029fde8f9142578d69179370ffb57ea35693452b",
extract: {
format: "tar",
Expand Down
5 changes: 5 additions & 0 deletions core/test/unit/src/verify-ext-tool-binary-hashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { kubectlSpec } from "../../../src/plugins/kubernetes/kubectl.js"
import { kustomizeSpec } from "../../../src/plugins/kubernetes/kubernetes-type/kustomize.js"
import { helm3Spec } from "../../../src/plugins/kubernetes/helm/helm-cli.js"
import { downloadBinariesAndVerifyHashes } from "../../../src/util/testing.js"
import { dockerSpec } from "../../../src/plugins/container/container.js"

describe("Docker binaries", () => {
downloadBinariesAndVerifyHashes([dockerSpec])
})

describe("Mutagen binaries", () => {
downloadBinariesAndVerifyHashes([mutagenCliSpec])
Expand Down

0 comments on commit e88bb86

Please sign in to comment.