Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

internal/config: Remove redundant context append for parsing #4744

Merged
merged 3 commits into from
May 25, 2023
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
3 changes: 3 additions & 0 deletions .changelog/4744.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
config: Remove extra eval context append for parsing configs which caused a slowdown during pipeline config parsing.
```
2 changes: 0 additions & 2 deletions internal/config/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ func (c *Config) Pipelines() []string {
// Note that currently this parsing function does not attempt to detect cycles
// between embedded pipelines.
func (c *Config) Pipeline(id string, ctx *hcl.EvalContext) (*Pipeline, error) {
ctx = appendContext(c.ctx, ctx)

// Find the pipeline by progressively decoding
var rawPipeline *hclPipeline
for _, p := range c.hclConfig.Pipelines {
Expand Down
14 changes: 14 additions & 0 deletions internal/config/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,20 @@ func TestPipelineProtos(t *testing.T) {
},
},

{
"pipelines_many_many_many.hcl",
func(t *testing.T, c *Config) {
require := require.New(t)

pipelines, err := c.PipelineProtos()
require.NoError(err)
require.Len(pipelines, 7)

require.Equal(pipelines[0].Name, "foo")
require.Equal(pipelines[1].Name, "bar")
},
},

{
"pipeline_nested_pipes.hcl",
func(t *testing.T, c *Config) {
Expand Down
84 changes: 84 additions & 0 deletions internal/config/testdata/pipelines/pipelines_many_many_many.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
project = "foo"

pipeline "foo" {
step "test" {
image_url = "example.com/test"

use "exec" {
command = "bar"
}
}
}


pipeline "bar" {
step "test2" {
image_url = "example.com/test"

use "exec" {
command = "bar"
}
}
}

pipeline "foofoo" {
step "test2" {
image_url = "example.com/test"

use "exec" {
command = "bar"
}
}
}

pipeline "barbar" {
step "test2" {
image_url = "example.com/test"

use "exec" {
command = "bar"
}
}
}

pipeline "foobar" {
step "test2" {
image_url = "example.com/test"

use "exec" {
command = "bar"
}
}
}

pipeline "naming-is-hard" {
step "test2" {
image_url = "example.com/test"

use "exec" {
command = "bar"
}
}
}

pipeline "hey-we-made-it" {
step "test2" {
image_url = "example.com/test"

use "exec" {
command = "bar"
}
}
}

app "web" {
config {
env = {
static = "hello"
}
}

build {}

deploy {}
}