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
Deprecate Config, replace with StackConfigDir #9145
Changes from 8 commits
70f5d71
b5e05b2
d83d628
4fa081f
c84abfd
a812591
9640c02
3268a8a
48693f0
c2658e8
47c26bd
2d16f7d
8aee8e4
73d19f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright 2016-2022, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package workspace | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDetectProjectAndPath(t *testing.T) { | ||
tmpDir, err := ioutil.TempDir("", "projecttest") | ||
assert.NoError(t, err) | ||
cwd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
defer func() { err := os.Chdir(cwd); assert.NoError(t, err) }() | ||
err = os.Chdir(tmpDir) | ||
assert.NoError(t, err) | ||
|
||
yamlPath := filepath.Join(tmpDir, "Pulumi.yaml") | ||
yamlContents := | ||
"name: some_project\ndescription: Some project\nruntime: nodejs\n" | ||
|
||
err = os.WriteFile(yamlPath, []byte(yamlContents), 0600) | ||
assert.NoError(t, err) | ||
|
||
project, path, err := DetectProjectAndPath() | ||
assert.NoError(t, err) | ||
assert.Equal(t, yamlPath, path) | ||
assert.Equal(t, tokens.PackageName("some_project"), project.Name) | ||
assert.Equal(t, "Some project", *project.Description) | ||
assert.Equal(t, "nodejs", project.Runtime.name) | ||
} | ||
|
||
func TestProjectStackPath(t *testing.T) { | ||
Frassle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expectedPath := func(expectedPath string) func(t *testing.T, projectDir, path string, err error) { | ||
return func(t *testing.T, projectDir, path string, err error) { | ||
assert.NoError(t, err) | ||
assert.Equal(t, filepath.Join(projectDir, expectedPath), path) | ||
} | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
yamlContents string | ||
validate func(t *testing.T, projectDir, path string, err error) | ||
}{{ | ||
"WithoutStacksDirectory", | ||
"name: some_project\ndescription: Some project\nruntime: nodejs\n", | ||
expectedPath("Pulumi.my_stack.yaml"), | ||
}, { | ||
"WithStacksDirectory", | ||
"name: some_project\ndescription: Some project\nruntime: nodejs\nstacksDirectory: stacks\n", | ||
expectedPath(filepath.Join("stacks", "Pulumi.my_stack.yaml")), | ||
}, { | ||
"WithConfig", | ||
"name: some_project\ndescription: Some project\nruntime: nodejs\nconfig: stacks\n", | ||
expectedPath(filepath.Join("stacks", "Pulumi.my_stack.yaml")), | ||
}, { | ||
"WithBoth", | ||
"name: some_project\ndescription: Some project\nruntime: nodejs\nconfig: stacks\nstacksDirectory: stacks\n", | ||
func(t *testing.T, projectDir, path string, err error) { | ||
assert.Error(t, err) | ||
}, | ||
}} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
tmpDir, err := ioutil.TempDir("", "projecttest") | ||
assert.NoError(t, err) | ||
cwd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
defer func() { err := os.Chdir(cwd); assert.NoError(t, err) }() | ||
err = os.Chdir(tmpDir) | ||
assert.NoError(t, err) | ||
|
||
err = os.WriteFile( | ||
filepath.Join(tmpDir, "Pulumi.yaml"), | ||
[]byte(tt.yamlContents), | ||
0600) | ||
assert.NoError(t, err) | ||
|
||
path, err := DetectProjectStackPath("my_stack") | ||
tt.validate(t, tmpDir, path, err) | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2016-2018, Pulumi Corporation. | ||
// Copyright 2016-2022, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -87,8 +87,12 @@ type Project struct { | |
// License is the optional license governing this project's usage. | ||
License *string `json:"license,omitempty" yaml:"license,omitempty"` | ||
|
||
// Config indicates where to store the Pulumi.<stack-name>.yaml files, combined with the folder Pulumi.yaml is in. | ||
Config string `json:"config,omitempty" yaml:"config,omitempty"` | ||
// Config has been renamed to StacksDirectory. | ||
Config interface{} `json:"config,omitempty" yaml:"config,omitempty"` | ||
|
||
// StacksDirectory indicates where to store the Pulumi.<stack-name>.yaml files, combined with the folder | ||
// Pulumi.yaml is in. | ||
StacksDirectory string `json:"stacksDirectory,omitempty" yaml:"stacksDirectory,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only comment here is for such a visible change which will need to be reflected in docs, might want to get wider feedback on the name. up to you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I want to get a few OKs on this before committing to this name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking off Josh's comment, maybe this should be "ConfigDirectory"? It used to just be called Config, how much do we need to make it clear its for stacks config? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Frassle What's the proper term for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shrug "Project settings file" and "stack config file" I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In our docs - these are currently "project file" and "stack configuration file". (Though this page includes a weird title that I feel like we should change "Project Configuration Reference"). From that page - the description of the current option is:
Here's suggestions in my order of preference:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stackConfigDir seems fine to me, will update. |
||
|
||
// Template is an optional template manifest, if this project is a template. | ||
Template *ProjectTemplate `json:"template,omitempty" yaml:"template,omitempty"` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we issue a deprecation warning, suggesting that the user switches to use
StacksDirectory
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure how well that would display, this is called into from a few different places.