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

Add atmos vendor commands. Add atmos vendor pull command. Improve error messages. Cleanup code #145

Merged
merged 49 commits into from May 2, 2022

Conversation

aknysh
Copy link
Member

@aknysh aknysh commented May 2, 2022

what

  • Add atmos vendor commands
  • Add atmos vendor pull command
  • Improve error messages
  • Cleanup code

why

  • atmos vendor commands are used to manage vendoring for components and stacks
  • atmos vendor pull -c <component> command pulls sources and mixins for the specified component
  • Support k8s-style YAML config (file component.yaml) to describe component vendoring configuration. The file is placed into the component folder and then the atmos command atmos vendor pull -c <component> is executed to pull the sources and mixins for the component
component.yaml
apiVersion: atmos/v1
kind: ComponentVendorConfig
metadata:
  name: vpc-flow-logs-bucket-vendor-config
  description: Source and mixins config for vendoring of 'vpc-flow-logs-bucket' component
spec:
  source:
    # 'uri' supports all protocols (local files, Git, Mercurial, HTTP, HTTPS, Amazon S3, Google GCP),
    # and all URL and archive formats as described in https://github.com/hashicorp/go-getter
    # In 'uri', Golang templates are supported  https://pkg.go.dev/text/template
    # If 'version' is provided, '{{.Version}}' will be replaced with the 'version' value before pulling the files from 'uri'
    uri: github.com/cloudposse/terraform-aws-components.git//modules/vpc-flow-logs-bucket?ref={{.Version}}
    version: 0.194.0
    # Only include the files that match the 'included_paths' patterns
    # If 'included_paths' is not specified, all files will be matched except those that match the patterns from 'excluded_paths'
    # 'included_paths' support POSIX-style Globs for file names/paths (double-star `**` is supported)
    # https://en.wikipedia.org/wiki/Glob_(programming)
    # https://github.com/bmatcuk/doublestar#patterns
    included_paths:
      - "**/*.tf"
      - "**/*.tfvars"
      - "**/*.md"
    # Exclude the files that match any of the 'excluded_paths' patterns
    # Note that we are excluding 'context.tf' since a newer version of it will be downloaded using 'mixins'
    # 'excluded_paths' support POSIX-style Globs for file names/paths (double-star `**` is supported)
    excluded_paths:
      - "**/context.tf"

  # mixins override files from 'source' with the same 'filename' (e.g. 'context.tf' will override 'context.tf' from the 'source')
  # mixins are processed in the order they are declared in the list
  mixins:
    # https://github.com/hashicorp/go-getter/issues/98
    - uri: https://raw.githubusercontent.com/cloudposse/terraform-null-label/0.25.0/exports/context.tf
      filename: context.tf
    - uri: https://raw.githubusercontent.com/cloudposse/terraform-aws-components/{{.Version}}/modules/datadog-agent/introspection.mixin.tf
      version: 0.194.0
      filename: introspection.mixin.tf
  • The URIs (uri) in the vendoring config support all protocols (local files, Git, Mercurial, HTTP, HTTPS, Amazon S3, Google GCP), and all URL and archive formats as described in https://github.com/hashicorp/go-getter

  • included_paths and excluded_paths support POSIX-style Globs for file names/paths (double-star ** is supported as well)

test

atmos vendor pull -c infra/vpc-flow-logs-bucket
Pulling sources for the component 'infra/vpc-flow-logs-bucket' 
from 'github.com/cloudposse/terraform-aws-components.git//modules/vpc-flow-logs-bucket?ref=0.194.0' 
and writing to 'examples/complete/components/terraform/infra/vpc-flow-logs-bucket'

Including the file 'README.md' since it matches the '**/*.md' pattern from 'included_paths'
Excluding the file 'context.tf' since it matches the '**/context.tf' pattern from 'excluded_paths'
Including the file 'default.auto.tfvars' since it matches the '**/*.tfvars' pattern from 'included_paths'
Including the file 'main.tf' since it matches the '**/*.tf' pattern from 'included_paths'
Including the file 'outputs.tf' since it matches the '**/*.tf' pattern from 'included_paths'
Including the file 'providers.tf' since it matches the '**/*.tf' pattern from 'included_paths'
Including the file 'variables.tf' since it matches the '**/*.tf' pattern from 'included_paths'
Including the file 'versions.tf' since it matches the '**/*.tf' pattern from 'included_paths'

Pulling the mixin 'https://raw.githubusercontent.com/cloudposse/terraform-null-label/0.25.0/exports/context.tf' 
for the component 'infra/vpc-flow-logs-bucket' 
and writing to 'examples/complete/components/terraform/infra/vpc-flow-logs-bucket'

Pulling the mixin 'https://raw.githubusercontent.com/cloudposse/terraform-aws-components/0.194.0/modules/datadog-agent/introspection.mixin.tf' 
for the component 'infra/vpc-flow-logs-bucket' 
and writing to 'examples/complete/components/terraform/infra/vpc-flow-logs-bucket'

@aknysh aknysh added the patch A minor, backward compatible change label May 2, 2022
@aknysh aknysh self-assigned this May 2, 2022
@aknysh aknysh requested review from a team as code owners May 2, 2022 15:35
@aknysh aknysh requested review from osterman and nitrocode May 2, 2022 16:06
Copy link
Member

@nitrocode nitrocode left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@aknysh aknysh merged commit 62cb109 into master May 2, 2022
@aknysh aknysh deleted the update-17 branch May 2, 2022 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants