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

improvement: more useful "create project" yaml #4985

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

stefreak
Copy link
Member

@stefreak stefreak commented Aug 25, 2023

What this PR does / why we need it:

The previous yaml generated by the docs-generator looked like this:

# Documentation about Garden projects can be found at https://docs.garden.io/using-garden/projects
# Reference for Garden projects can be found at https://docs.garden.io/reference/project-config

# The Garden apiVersion for this project.
#
# The value garden.io/v0 is the default for backwards compatibility with
# Garden Acorn (0.12) when not explicitly specified.
#
# Configuring garden.io/v1 explicitly in your project configuration allows
# you to start using the new Action configs introduced in Garden Bonsai (0.13).
#
# Note that the value garden.io/v1 will break compatibility of your project
# with Garden Acorn (0.12).
apiVersion: garden.io/v1

# Indicate what kind of config this is.
kind: Project

# The name of the project.
name: foobar

# A list of environments to configure for the project.
environments:
  - # The name of the environment.
    name: default

# A list of providers that should be used for this project, and their configuration. Please refer to individual
# plugins/providers for details on how to configure them.
providers:
  - # The name of the provider plugin to use.
    name: local-kubernetes

While it is cool that we are re-using the descriptions from our docs,
there are some problems with this yaml code:

  • The comments often do not add any valuable information. For example
    it's already clear that name: foobar is the name of the project.
  • Another problem is that the description in the reference docs is not
    necessarily the information a user needs when getting started. This
    becomes apparent in the comment above apiVersion, for example.

This commit simplifies the create project command implementation to
just write a file with hardcoded yaml. The comments are hand-crafted for
a good getting-started experience.

This commit also updates the docs that refer to the "create project"
command.

The new yaml looks like this:

# Documentation about Garden projects can be found at https://docs.garden.io/using-garden/projects
# Reference for Garden projects can be found at https://docs.garden.io/reference/project-config

apiVersion: garden.io/v1
kind: Project
name: test

defaultEnvironment: local

# Environments typically represent different stages of your development and deployment process.
environments:
  # Use this environment to develop in your local Kubernetes solution of choice.
  # Installation instructions and list of supported local Kubernetes environments: https://docs.garden.io/kubernetes-plugins/local-k8s/install
  - name: local
    defaultNamespace: garden-local

  # Use this environment to develop in remote, production-like environments that scale with your stack.
  # This means you don't need any dependencies on your local machine, even the builds can be performed remotely.
  # It enables sharing build and test caches with your entire team, which can significantly speed up pipelines and development.
  - name: remote
    defaultNamespace: garden-remote-${local.username}

  - name: staging
    # Ask before performing potentially destructive commands like "deploy".
    production: true
    defaultNamespace: staging

# Providers make action types available in your Garden configuration and tell Garden how to connect with your infrastructure.
# For example the kubernetes and local-kubernetes providers allow you to use the container, helm and kubernetes action types.
# All available providers and their configuration options are listed in the reference docs: https://docs.garden.io/reference/providers
providers:
  - name: local-kubernetes
    environments:
      - local

  # To configure the remote kubernetes providers, follow the steps at https://docs.garden.io/kubernetes-plugins/remote-k8s
  - name: kubernetes
    environments:
      - remote
    context: # ... your remote development kubecontext here
  - name: kubernetes
    environments:
      - staging
    context: # ... your staging kubecontext here

# Next step: Define actions to tell Garden how to build, test and deploy your code.
# You can find out more here: https://docs.garden.io/using-garden/actions

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@stefreak stefreak force-pushed the more-useful-create-project branch 2 times, most recently from 873f6d7 to d5fb0e7 Compare August 25, 2023 08:29
@stefreak stefreak requested a review from a team August 25, 2023 08:31
@stefreak stefreak marked this pull request as ready for review August 25, 2023 08:31
# This means you don't need any dependencies on your local machine, even the builds can be performed remotely.
# It enables sharing build and test caches with your entire team, which can significantly speed up pipelines and development.
- name: remote
defaultNamespace: garden-remote-\${local.username}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backslash seems to end up in the final yaml file. We need to fix that before merging.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that true? In theory that should just escape the $ so it doesn't get templated in JS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm puzzled about this too. But I ran the command "garden create project" with the dev build, and the backslash was there. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimBeyer I now worked around this mystery and updated the tests.

TimBeyer
TimBeyer previously approved these changes Aug 25, 2023
@stefreak stefreak force-pushed the more-useful-create-project branch 3 times, most recently from bb6e30d to 1a0ffa3 Compare August 25, 2023 09:52
twelvemo
twelvemo previously approved these changes Aug 28, 2023
Copy link
Collaborator

@twelvemo twelvemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is great! I have a few suggestions around comments, feel free to adept or discard.

core/src/commands/create/create-project.ts Show resolved Hide resolved
# It enables sharing build and test caches with your entire team, which can significantly speed up pipelines and development.
- name: remote
defaultNamespace: garden-remote-${"${local.username}"}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# You could also define a staging environment, which is shared by several developers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided not to incorporate this one, because it does not add a lot of information– Here I'd value conciseness and usefulness over consistency

core/src/commands/create/create-project.ts Outdated Show resolved Hide resolved
core/src/commands/create/create-project.ts Show resolved Hide resolved
While it is cool that we are re-using the descriptions from our docs,
there are some problems with this yaml code:
- The comments often do not add any valuable information. For example
  it's already clear that `name: foobar` is the name of the project.
- Another problem is that the description in the reference docs is not
  necessarily the information a user needs when getting started. This
becomes apparent in the comment above `apiVersion`, for example.

This commit simplifies the `create project` command implementation to
just write a file with hardcoded yaml. The comments are hand-crafted for
a good getting-started experience.

This commit also updates the docs that refer to the "create project"
command.

Co-authored-by: Tim <tim@garden.io>
Co-authored-by: Anna <anna@garden.io>
Copy link
Collaborator

@twelvemo twelvemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for improving this!

@stefreak stefreak added this pull request to the merge queue Aug 29, 2023
Merged via the queue into main with commit 012d4ea Aug 29, 2023
41 checks passed
@stefreak stefreak deleted the more-useful-create-project branch August 29, 2023 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants