Skip to content

Commit

Permalink
Support vendor.yaml as a new way of vendoring components, stacks or…
Browse files Browse the repository at this point in the history
… any other artifacts (#448)

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* Add `vendor.yaml`

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* update docs

* Update examples/complete/vendor.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* Update examples/complete/vendor/vendor2.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* Update examples/complete/vendor/vendor5.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* Update examples/complete/vendor/vendor6.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* Update examples/complete/vendor/vendor3.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* Update examples/complete/vendor/vendor4.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* Update website/docs/cli/commands/vendor/vendor-pull.md

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* Update website/docs/core-concepts/vendoring/vendoring.md

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* update docs

* update docs

* update docs

* updates

* updates

* updates

* updates

* Update website/docs/core-concepts/vendoring/vendoring.md

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>

* updates

* updates

* updates

* updates

* make file extensions of vendoring manifests optional, assume and use `.yaml` by default

* make file extensions of vendoring manifests optional, assume and use `.yaml` by default

---------

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
  • Loading branch information
aknysh and osterman authored Oct 25, 2023
1 parent 5fa72c9 commit 01154c2
Show file tree
Hide file tree
Showing 49 changed files with 1,324 additions and 438 deletions.
2 changes: 1 addition & 1 deletion cmd/atlantis_generate_repo_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
atlantisGenerateRepoConfigCmd.PersistentFlags().String("stacks", "",
"Generate Atlantis projects for the specified stacks only (comma-separated values).\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --stacks <stack1>,<stack2>\n"+
"The filter can contain the names of the top-level stack config files and the logical stack names (derived from the context vars)\n"+
"The filter can contain the names of the top-level stack manifests and the logical stack names (derived from the context vars)\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --stacks orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --stacks tenant1-ue2-staging,tenant1-ue2-prod\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --stacks orgs/cp/tenant1/staging/us-east-2,tenant1-ue2-prod",
Expand Down
2 changes: 1 addition & 1 deletion cmd/describe_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func init() {

describeStacksCmd.PersistentFlags().StringP("stack", "s", "",
"Filter by a specific stack: atmos describe stacks -s <stack>\n"+
"The filter supports names of the top-level stack config files (including subfolder paths), and 'atmos' stack names (derived from the context vars)",
"The filter supports names of the top-level stack manifests (including subfolder paths), and 'atmos' stack names (derived from the context vars)",
)

describeStacksCmd.PersistentFlags().String("components", "", "Filter by specific 'atmos' components: atmos describe stacks --components=<component1>,<component2>")
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"errors"

"github.com/spf13/cobra"

cfg "github.com/cloudposse/atmos/pkg/config"
Expand Down Expand Up @@ -28,7 +30,7 @@ func init() {
// system dir, home dir, current dir, ENV vars, command-line arguments
// Here we need the custom commands from the config
cliConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false)
if err != nil && err != cfg.NotFound {
if err != nil && !errors.Is(err, cfg.NotFound) {
u.LogErrorAndExit(err)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/terraform_generate_backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func init() {
terraformGenerateBackendsCmd.PersistentFlags().String("stacks", "",
"Only process the specified stacks (comma-separated values).\n"+
"atmos terraform generate backends --file-template <file_template> --stacks <stack1>,<stack2>\n"+
"The filter can contain names of the top-level stack config files (including subfolder paths), and 'atmos' stack names (derived from the context vars)\n"+
"The filter can contain names of the top-level stack manifests (including subfolder paths), and 'atmos' stack names (derived from the context vars)\n"+
"atmos terraform generate backends --stacks orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2\n"+
"atmos terraform generate backends --stacks tenant1-ue2-staging,tenant1-ue2-prod\n"+
"atmos terraform generate backends --stacks orgs/cp/tenant1/staging/us-east-2,tenant1-ue2-prod",
Expand Down
2 changes: 1 addition & 1 deletion cmd/terraform_generate_varfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {
terraformGenerateVarfilesCmd.PersistentFlags().String("stacks", "",
"Only process the specified stacks (comma-separated values).\n"+
"atmos terraform generate varfiles --file-template <file_template> --stacks <stack1>,<stack2>\n"+
"The filter can contain names of the top-level stack config files (including subfolder paths), and 'atmos' stack names (derived from the context vars)\n"+
"The filter can contain names of the top-level stack manifests (including subfolder paths), and 'atmos' stack names (derived from the context vars)\n"+
"atmos terraform generate varfiles --stacks orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2\n"+
"atmos terraform generate varfiles --stacks tenant1-ue2-staging,tenant1-ue2-prod\n"+
"atmos terraform generate varfiles --stacks orgs/cp/tenant1/staging/us-east-2,tenant1-ue2-prod",
Expand Down
6 changes: 3 additions & 3 deletions examples/complete/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Geodesic: https://github.com/cloudposse/geodesic/
ARG GEODESIC_VERSION=2.6.0
ARG GEODESIC_VERSION=2.7.0
ARG GEODESIC_OS=debian

# atmos: https://github.com/cloudposse/atmos
ARG ATMOS_VERSION=1.46.0
ARG ATMOS_VERSION=1.47.0

# Terraform: https://github.com/hashicorp/terraform/releases
ARG TF_VERSION=1.6.1
ARG TF_VERSION=1.6.2

FROM cloudposse/geodesic:${GEODESIC_VERSION}-${GEODESIC_OS}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
# 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/account-map?ref={{.Version}}
version: 1.315.1
version: 1.323.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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
# 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: 1.315.1
version: 1.323.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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "flow_logs_s3_bucket" {
source = "cloudposse/vpc-flow-logs-s3-bucket/aws"
version = "0.18.0"
version = "1.0.1"

lifecycle_prefix = var.lifecycle_prefix
lifecycle_tags = var.lifecycle_tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
# 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?ref={{.Version}}
version: 1.315.1
version: 1.323.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)
Expand Down
39 changes: 39 additions & 0 deletions examples/complete/vendor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
name: example-vendor-config
description: Atmos vendoring manifest
spec:
# `imports` or `sources` (or both) must be defined in a vendoring manifest
imports:
- "vendor/vendor2"
- "vendor/vendor3.yaml"

sources:
# `source` supports the following protocols: OCI (https://opencontainers.org), Git, Mercurial, HTTP, HTTPS, Amazon S3, Google GCP,
# and all URL and archive formats as described in https://github.com/hashicorp/go-getter.
# In 'source', 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 'source'.
# Download the component from the AWS public ECR registry (https://docs.aws.amazon.com/AmazonECR/latest/public/public-registries.html).
- component: "vpc"
source: "oci://public.ecr.aws/cloudposse/components/terraform/stable/aws/vpc:{{.Version}}"
version: "latest"
targets:
- "components/terraform/infra/vpc3"
# 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"
- component: "vpc-flow-logs-bucket"
source: "github.com/cloudposse/terraform-aws-components.git//modules/vpc-flow-logs-bucket?ref={{.Version}}"
version: "1.323.0"
targets:
- "components/terraform/infra/vpc-flow-logs-bucket/{{.Version}}"
excluded_paths:
- "**/*.yaml"
- "**/*.yml"
20 changes: 20 additions & 0 deletions examples/complete/vendor/vendor2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
name: example-vendor-config-2
description: Atmos vendoring manifest
spec:
imports:
- "vendor/vendor4"

sources:
- component: "my-vpc1"
source: "oci://public.ecr.aws/cloudposse/components/terraform/stable/aws/vpc:{{.Version}}"
version: "latest"
targets:
- "components/terraform/infra/my-vpc1"
- component: "my-vpc2"
source: "github.com/cloudposse/terraform-aws-components.git//modules/vpc?ref={{.Version}}"
version: "1.320.0"
targets:
- "components/terraform/infra/my-vpc2"
8 changes: 8 additions & 0 deletions examples/complete/vendor/vendor3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
name: example-vendor-config-3
description: Atmos vendoring manifest
spec:
imports:
- "vendor/vendor6"
15 changes: 15 additions & 0 deletions examples/complete/vendor/vendor4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
name: example-vendor-config-4
description: Atmos vendoring manifest
spec:
imports:
- "vendor/vendor5"

sources:
- component: "my-vpc4"
source: "github.com/cloudposse/terraform-aws-components.git//modules/vpc?ref={{.Version}}"
version: "1.319.0"
targets:
- "components/terraform/infra/my-vpc4"
12 changes: 12 additions & 0 deletions examples/complete/vendor/vendor5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
name: example-vendor-config-5
description: Atmos vendoring manifest
spec:
sources:
- component: "my-vpc5"
source: "github.com/cloudposse/terraform-aws-components.git//modules/vpc?ref={{.Version}}"
version: "1.317.0"
targets:
- "components/terraform/infra/my-vpc5"
12 changes: 12 additions & 0 deletions examples/complete/vendor/vendor6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
name: example-vendor-config-6
description: Atmos vendoring manifest
spec:
sources:
- component: "my-vpc6"
source: "github.com/cloudposse/terraform-aws-components.git//modules/vpc?ref={{.Version}}"
version: "1.315.0"
targets:
- "components/terraform/infra/my-vpc6"
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ go 1.21

require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/bmatcuk/doublestar/v4 v4.6.0
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/fatih/color v1.15.0
github.com/go-git/go-git/v5 v5.9.0
github.com/google/go-containerregistry v0.16.1
github.com/google/uuid v1.3.1
github.com/hashicorp/go-getter v1.7.2
github.com/hashicorp/go-getter v1.7.3
github.com/hashicorp/hcl v1.0.0
github.com/hashicorp/hcl/v2 v2.18.1
github.com/hashicorp/hcl/v2 v2.19.1
github.com/hashicorp/terraform-config-inspect v0.0.0-20230925220900-5a6f8d18746d
github.com/imdario/mergo v0.3.13
github.com/json-iterator/go v1.1.12
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.5.0
github.com/open-policy-agent/opa v0.57.0
github.com/open-policy-agent/opa v0.57.1
github.com/otiai10/copy v1.14.0
github.com/pkg/errors v0.9.1
github.com/samber/lo v1.38.1
Expand Down Expand Up @@ -119,17 +119,17 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/yashtewari/glob-intersection v0.2.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/sdk v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
Expand Down
Loading

0 comments on commit 01154c2

Please sign in to comment.