-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: allow to mount multiple artifacts to the same folder in a serv…
…ice. Users will need to replace the `Directory.artifac_name` field key with `Directory.artifac_names` (#2025) ## Description: allow to mount multiple artifacts to the same folder in a service ## Is this change user facing? YES ## References (if applicable): Fix #1519
- Loading branch information
Showing
29 changed files
with
411 additions
and
98 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
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
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
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
33 changes: 33 additions & 0 deletions
33
...rtosis_starlark_framework/test_engine/directory_multiple_file_artifacts_framework_test.go
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package test_engine | ||
|
||
import ( | ||
"fmt" | ||
"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" | ||
"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/directory" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
type directoryMultipleFileArtifactsTestCase struct { | ||
*testing.T | ||
} | ||
|
||
func (suite *KurtosisTypeConstructorTestSuite) TestDirectoryMultipleFileArtifacts() { | ||
suite.run(&directoryMultipleFileArtifactsTestCase{ | ||
T: suite.T(), | ||
}) | ||
} | ||
|
||
func (t *directoryMultipleFileArtifactsTestCase) GetStarlarkCode() string { | ||
return fmt.Sprintf("%s(%s=[%q, %q])", directory.DirectoryTypeName, directory.ArtifactNamesAttr, testFilesArtifactName1, testFilesArtifactName2) | ||
} | ||
|
||
func (t *directoryMultipleFileArtifactsTestCase) Assert(typeValue builtin_argument.KurtosisValueType) { | ||
directoryStarlark, ok := typeValue.(*directory.Directory) | ||
require.True(t, ok) | ||
|
||
artifactNames, found, err := directoryStarlark.GetArtifactNamesIfSet() | ||
require.Nil(t, err) | ||
require.True(t, found) | ||
require.Equal(t, []string{testFilesArtifactName1, testFilesArtifactName2}, artifactNames) | ||
} |
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
64 changes: 64 additions & 0 deletions
64
...tosis_starlark_framework/test_engine/service_config_multiple_files_in_same_folder_test.go
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package test_engine | ||
|
||
import ( | ||
"fmt" | ||
"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" | ||
"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" | ||
"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/directory" | ||
"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" | ||
"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" | ||
"github.com/stretchr/testify/require" | ||
"net" | ||
"testing" | ||
) | ||
|
||
type serviceConfigMultipleFilesInSameFolderTestCase struct { | ||
*testing.T | ||
serviceNetwork *service_network.MockServiceNetwork | ||
packageContentProvider *startosis_packages.MockPackageContentProvider | ||
} | ||
|
||
func (suite *KurtosisTypeConstructorTestSuite) TestServiceConfigMultipleFilesInSameFolder() { | ||
|
||
suite.serviceNetwork.EXPECT().GetApiContainerInfo().Times(1).Return( | ||
service_network.NewApiContainerInfo(net.IPv4(0, 0, 0, 0), 0, "0.0.0"), | ||
) | ||
|
||
suite.run(&serviceConfigMultipleFilesInSameFolderTestCase{ | ||
T: suite.T(), | ||
serviceNetwork: suite.serviceNetwork, | ||
packageContentProvider: suite.packageContentProvider, | ||
}) | ||
} | ||
|
||
func (t *serviceConfigMultipleFilesInSameFolderTestCase) GetStarlarkCode() string { | ||
filesArtifactsDirectory := fmt.Sprintf("%s(%s=[%q, %q])", directory.DirectoryTypeName, directory.ArtifactNamesAttr, testFilesArtifactName1, testFilesArtifactName2) | ||
starlarkCode := fmt.Sprintf("%s(%s=%q, %s=%s)", | ||
service_config.ServiceConfigTypeName, | ||
service_config.ImageAttr, testContainerImageName, | ||
service_config.FilesAttr, fmt.Sprintf("{%q: %s}", testFilesArtifactPath1, filesArtifactsDirectory), | ||
) | ||
|
||
return starlarkCode | ||
} | ||
|
||
func (t *serviceConfigMultipleFilesInSameFolderTestCase) Assert(typeValue builtin_argument.KurtosisValueType) { | ||
serviceConfigStarlark, ok := typeValue.(*service_config.ServiceConfig) | ||
require.True(t, ok) | ||
|
||
serviceConfig, err := serviceConfigStarlark.ToKurtosisType( | ||
t.serviceNetwork, | ||
testModulePackageId, | ||
testModuleMainFileLocator, | ||
t.packageContentProvider, | ||
testNoPackageReplaceOptions) | ||
require.Nil(t, err) | ||
|
||
require.Equal(t, testContainerImageName, serviceConfig.GetContainerImageName()) | ||
|
||
expectedFilesArtifactMap := map[string][]string{ | ||
testFilesArtifactPath1: {testFilesArtifactName1, testFilesArtifactName2}, | ||
} | ||
require.NotNil(t, serviceConfig.GetFilesArtifactsExpansion()) | ||
require.Equal(t, expectedFilesArtifactMap, serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers) | ||
} |
Oops, something went wrong.