-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encourage the use of root_path in production to ensure single deploym…
…ent (#1712) ## Changes This updates `mode: production` to allow `root_path` to indicate uniqueness. Historically, we required `run_as` for this, which isn't actually very effective for that purpose. `run_as` also had the problem that it doesn't work for pipelines. This is a cherry-pick from #1387 --------- Co-authored-by: Pieter Noordhuis <[email protected]>
- Loading branch information
1 parent
f8f804f
commit 3e40a0c
Showing
6 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,15 +321,15 @@ func TestProcessTargetModeProduction(t *testing.T) { | |
b := mockBundle(config.Production) | ||
|
||
diags := validateProductionMode(context.Background(), b, false) | ||
require.ErrorContains(t, diags.Error(), "run_as") | ||
require.ErrorContains(t, diags.Error(), "target with 'mode: production' must set 'workspace.root_path' to make sure only one copy is deployed. A common practice is to use a username or principal name in this path, i.e. root_path: /Workspace/Users/[email protected]/.bundle/${bundle.name}/${bundle.target}") | ||
|
||
b.Config.Workspace.StatePath = "/Shared/.bundle/x/y/state" | ||
b.Config.Workspace.ArtifactPath = "/Shared/.bundle/x/y/artifacts" | ||
b.Config.Workspace.FilePath = "/Shared/.bundle/x/y/files" | ||
b.Config.Workspace.ResourcePath = "/Shared/.bundle/x/y/resources" | ||
|
||
diags = validateProductionMode(context.Background(), b, false) | ||
require.ErrorContains(t, diags.Error(), "production") | ||
require.ErrorContains(t, diags.Error(), "target with 'mode: production' must set 'workspace.root_path' to make sure only one copy is deployed. A common practice is to use a username or principal name in this path, i.e. root_path: /Workspace/Users/[email protected]/.bundle/${bundle.name}/${bundle.target}") | ||
|
||
permissions := []resources.Permission{ | ||
{ | ||
|
@@ -375,6 +375,23 @@ func TestProcessTargetModeProductionOkForPrincipal(t *testing.T) { | |
require.NoError(t, diags.Error()) | ||
} | ||
|
||
func TestProcessTargetModeProductionOkWithRootPath(t *testing.T) { | ||
b := mockBundle(config.Production) | ||
|
||
// Our target has all kinds of problems when not using service principals ... | ||
diags := validateProductionMode(context.Background(), b, false) | ||
require.Error(t, diags.Error()) | ||
|
||
// ... but we're okay if we specify a root path | ||
b.Target = &config.Target{ | ||
Workspace: &config.Workspace{ | ||
RootPath: "some-root-path", | ||
}, | ||
} | ||
diags = validateProductionMode(context.Background(), b, false) | ||
require.NoError(t, diags.Error()) | ||
} | ||
|
||
// Make sure that we have test coverage for all resource types | ||
func TestAllResourcesMocked(t *testing.T) { | ||
b := mockBundle(config.Development) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters