Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): pre-fetch provider tools and make tools a native feature #1858

Merged
merged 2 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 89 additions & 24 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,34 @@ Note: Currently only supports simple GET requests for HTTP/HTTPS ingresses.
| -------- | -------- | ----------- |
| `serviceAndPath` | Yes | The name of the service to call followed by the ingress path (e.g. my-container/somepath).

### garden config analytics-enabled

Update your preferences regarding analytics.

To help us make Garden better, you can opt in to the collection of usage data.
We make sure all the data collected is anonymized and stripped of sensitive
information. We collect data about which commands are run, what tasks they trigger,
which API calls are made to your local Garden server, as well as some info
about the environment in which Garden runs.

You will be asked if you want to opt-in when running Garden for the
first time and you can use this command to update your preferences later.

Examples:

garden config analytics-enabled true # enable analytics
garden config analytics-enabled false # disable analytics

##### Usage

garden config analytics-enabled [enable]

##### Arguments

| Argument | Required | Description |
| -------- | -------- | ----------- |
| `enable` | No | Enable analytics. Defaults to "true"

### garden create project

Create a new Garden project.
Expand Down Expand Up @@ -794,6 +822,48 @@ Examples:
| `--force-build` | | boolean | Force rebuild of module(s).
| `--watch` | `-w` | boolean | Watch for changes in module(s) and auto-test.

### garden tools

Access tools included by providers.

Run a tool defined by a provider in your project, downloading and extracting it if necessary. Run without arguments to get a list of all tools available.

Run with the --get-path flag to just print the path to the binary or library directory (depending on the tool type). If the tool is a non-executable library, this flag is implicit.

When multiple plugins provide a tool with the same name, you can choose a specific plugin/version by specifying <plugin name>.<tool name>, instead of just <tool name>. This is generally advisable when using this command in scripts, to avoid accidental conflicts.

When there are name conflicts and a plugin name is not specified, we first prefer tools defined by configured providers in the current project (if applicable), and then alphabetical by plugin name.

Examples:

# Run kubectl with <args>.
garden tools kubectl -- <args>

# Run the kubectl version defined specifically by the `kubernetes` plugin.
garden tools kubernetes.kubectl -- <args>

# Print the path to the kubernetes.kubectl tool to stdout, instead of running it.
garden tools kubernetes.kubectl --get-path

# List all available tools.
garden tools

##### Usage

garden tools [tool] [options]

##### Arguments

| Argument | Required | Description |
| -------- | -------- | ----------- |
| `tool` | No | The name of the tool to run.

##### Options

| Argument | Alias | Type | Description |
| -------- | ----- | ---- | ----------- |
| `--get-path` | | boolean | If specified, we print the path to the binary or library instead of running it.

### garden unlink source

Unlink a previously linked remote source from its local directory.
Expand Down Expand Up @@ -905,41 +975,36 @@ Examples:

garden update-remote all

### garden validate
### garden util fetch-tools
eysi09 marked this conversation as resolved.
Show resolved Hide resolved

Check your garden configuration for errors.
Pre-fetch plugin tools.

Throws an error and exits with code 1 if something's not right in your garden.yml files.
Pre-fetch all the available tools for the configured providers in the current
project/environment, or all registered providers if the --all parameter is
specified.

##### Usage
Examples:

garden validate
garden util fetch-tools # fetch for just the current project/env
garden util fetch-tools --all # fetch for all registered providers

### garden config analytics-enabled
##### Usage

Update your preferences regarding analytics.
garden util fetch-tools [options]

To help us make Garden better, you can opt in to the collection of usage data.
We make sure all the data collected is anonymized and stripped of sensitive
information. We collect data about which commands are run, what tasks they trigger,
which API calls are made to your local Garden server, as well as some info
about the environment in which Garden runs.

You will be asked if you want to opt-in when running Garden for the
first time and you can use this command to update your preferences later.
##### Options

Examples:
| Argument | Alias | Type | Description |
| -------- | ----- | ---- | ----------- |
| `--all` | | boolean | Fetch all tools for registered plugins, instead of just ones in the current env/project.

garden config analytics-enabled true # enable analytics
garden config analytics-enabled false # disable analytics
### garden validate

##### Usage
Check your garden configuration for errors.

garden config analytics-enabled [enable]
Throws an error and exits with code 1 if something's not right in your garden.yml files.

##### Arguments
##### Usage

| Argument | Required | Description |
| -------- | -------- | ----------- |
| `enable` | No | Enable analytics. Defaults to &quot;true&quot;
garden validate

13 changes: 7 additions & 6 deletions garden-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ RUN apk add --no-cache \

WORKDIR /tmp

RUN npm install [email protected].2 && node_modules/.bin/pkg-fetch node12 alpine x64
RUN npm install [email protected].8 && node_modules/.bin/pkg-fetch node12 alpine x64

ADD package.json /tmp/
ADD package-lock.json /tmp/

RUN npm install \
&& rm -rf /root/.npm/* \
/usr/lib/node_modules/npm/man/* \
/usr/lib/node_modules/npm/doc/* \
/usr/lib/node_modules/npm/html/* \
/usr/lib/node_modules/npm/scripts/*
/usr/lib/node_modules/npm/man/* \
/usr/lib/node_modules/npm/doc/* \
/usr/lib/node_modules/npm/html/* \
/usr/lib/node_modules/npm/scripts/*

ADD bin/garden /tmp/bin/garden
ADD bin/garden-debug /tmp/bin/garden-debug
Expand Down Expand Up @@ -56,6 +56,7 @@ WORKDIR /project

RUN chmod +x /garden/garden \
&& ln -s /garden/garden /bin/garden \
&& chmod +x /bin/garden
&& chmod +x /bin/garden \
&& cd /garden/static && garden util fetch-tools --all --logger-type=basic

ENTRYPOINT ["/garden/garden"]
5 changes: 4 additions & 1 deletion garden-service/buster.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ ADD . /garden
WORKDIR /project

RUN ln -s /garden/garden /bin/garden \
&& chmod +x /bin/garden
&& chmod +x /bin/garden \
&& cd /garden/static \
&& git init \
&& garden util fetch-tools --all --logger-type=basic

ENTRYPOINT ["/garden/garden"]
2 changes: 1 addition & 1 deletion garden-service/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ export class ActionRouter implements TypeGuard {
const environmentStatuses: EnvironmentStatusMap = {}

const providers = await this.garden.resolveProviders()
await Bluebird.each(providers, async (provider) => {
await Bluebird.each(Object.values(providers), async (provider) => {
await this.cleanupEnvironment({ pluginName: provider.name, log: envLog })
environmentStatuses[provider.name] = await this.getEnvironmentStatus({ pluginName: provider.name, log: envLog })
})
Expand Down
5 changes: 2 additions & 3 deletions garden-service/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const GLOBAL_OPTIONS_GROUP_NAME = "Global options"
* Used by commands that have noProject=true. That is, commands that need
* to run outside of valid Garden projects.
*/
class DummyGarden extends Garden {
export class DummyGarden extends Garden {
async resolveProviders() {
return []
return {}
}
async scanAndAddConfigs() {}
}
Expand Down Expand Up @@ -312,7 +312,6 @@ export class GardenCli {
// the screen the logs are printed.
const headerLog = logger.placeholder()
const log = logger.placeholder()
logger.info("")
const footerLog = logger.placeholder()

// Init event & log streaming.
Expand Down
10 changes: 7 additions & 3 deletions garden-service/src/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ import { ConfigCommand } from "./config/config"
import { PluginsCommand } from "./plugins"
import { LoginCommand } from "./login"
import { LogOutCommand } from "./logout"
import { ToolsCommand } from "./tools"
import { UtilCommand } from "./util"

export const coreCommands: Command[] = [
new BuildCommand(),
new CallCommand(),
new ConfigCommand(),
new CreateCommand(),
new DeleteCommand(),
new DeployCommand(),
new DevCommand(),
new ExecCommand(),
new GetCommand(),
new LinkCommand(),
new LoginCommand(),
new LogOutCommand(),
new LogsCommand(),
new MigrateCommand(),
new OptionsCommand(),
Expand All @@ -53,10 +58,9 @@ export const coreCommands: Command[] = [
new ServeCommand(),
new SetCommand(),
new TestCommand(),
new ToolsCommand(),
new UnlinkCommand(),
new UpdateRemoteCommand(),
new UtilCommand(),
new ValidateCommand(),
new ConfigCommand(),
new LoginCommand(),
new LogOutCommand(),
]
2 changes: 1 addition & 1 deletion garden-service/src/commands/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async function listPlugins(garden: Garden, log: LogEntry, pluginsToList: string[
log.info(dedent`
${chalk.white.bold("USAGE")}

garden ${chalk.yellow("[global options]")} ${chalk.blueBright("<command>")} ${chalk.white("[args ...]")}
garden ${chalk.yellow("[global options]")} ${chalk.blueBright("<command>")} -- ${chalk.white("[args ...]")}

${chalk.white.bold("PLUGIN COMMANDS")}
`)
Expand Down
Loading