diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index 3d05772f65..aaf521a4fc 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -25,6 +25,8 @@ const ( ServiceNameArgName = "name" ServiceConfigArgName = "config" + + testRootModuleLocator = "./" ) func NewAddService( @@ -50,19 +52,20 @@ func NewAddService( Name: ServiceConfigArgName, IsOptional: false, ZeroValueProvider: builtin_argument.ZeroValueProvider[*service_config.ServiceConfig], - Validator: func(value starlark.Value) *startosis_errors.InterpretationError { - // we just try to convert the configs here to validate their shape, to avoid code duplication with Interpret - if _, _, err := validateAndConvertConfigAndReadyCondition( - serviceNetwork, - value, - "", - packageId, - packageContentProvider, - packageReplaceOptions); err != nil { - return err - } - return nil - }, + Validator: nil, + //Validator: func(value starlark.Value) *startosis_errors.InterpretationError { + // // we just try to convert the configs here to validate their shape, to avoid code duplication with Interpret + // if _, _, err := validateAndConvertConfigAndReadyCondition( + // serviceNetwork, + // value, + // packageId, // use package id for root locator + // packageId, + // packageContentProvider, + // packageReplaceOptions); err != nil { + // return err + // } + // return nil + //}, }, }, }, diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/add_service_image_build_spec_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/add_service_image_build_spec_test.go deleted file mode 100644 index a6b51e8061..0000000000 --- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/add_service_image_build_spec_test.go +++ /dev/null @@ -1 +0,0 @@ -package test_engine diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/image_build_spec_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/image_build_spec_framework_test.go index a6b51e8061..518401d8ec 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/image_build_spec_framework_test.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/image_build_spec_framework_test.go @@ -1 +1,59 @@ 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/service_config" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" + "github.com/stretchr/testify/require" + "testing" +) + +type imageBuildSpecTest struct { + *testing.T + + packageContentProvider *startosis_packages.MockPackageContentProvider +} + +func (suite *KurtosisTypeConstructorTestSuite) TestImageBuildSpecTest() { + suite.packageContentProvider.EXPECT(). + GetAbsoluteLocator(testModulePackageId, testModuleMainFileLocator, testBuildContextDir, testNoPackageReplaceOptions). + Times(1). + Return(testBuildContextLocator, nil) + + suite.packageContentProvider.EXPECT(). + GetOnDiskAbsoluteFilePath(testContainerImageLocator). + Times(1). + Return(testOnDiskContainerImagePath, nil) + + suite.run(&imageBuildSpecTest{ + T: suite.T(), + packageContentProvider: suite.packageContentProvider, + }) +} + +func (t *imageBuildSpecTest) GetStarlarkCode() string { + return fmt.Sprintf("%s(%s=%q, %s=%q, %s=%q)", + service_config.ImageBuildSpecTypeName, + service_config.BuiltImageNameAttr, + testContainerImageName, + service_config.BuildContextAttr, + testBuildContextDir, + service_config.TargetStageAttr, + testTargetStage) +} + +func (t *imageBuildSpecTest) Assert(typeValue builtin_argument.KurtosisValueType) { + imageBuildSpecStarlark, ok := typeValue.(*service_config.ImageBuildSpec) + require.True(t, ok) + + imageBuildSpec, err := imageBuildSpecStarlark.ToKurtosisType( + testModuleMainFileLocator, + testModulePackageId, + t.packageContentProvider, + testNoPackageReplaceOptions) + require.Nil(t, err) + require.Equal(t, testOnDiskContainerImagePath, imageBuildSpec.GetContainerImageFilePath()) + require.Equal(t, testOnDiskContextDirPath, imageBuildSpec.GetContextDirPath()) + require.Equal(t, testTargetStage, imageBuildSpec.GetTargetStage()) +} diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/service_config_image_build_spec_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/service_config_image_build_spec_test.go index d709375a8c..fc124e5199 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/service_config_image_build_spec_test.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/service_config_image_build_spec_test.go @@ -23,7 +23,7 @@ func (suite *KurtosisTypeConstructorTestSuite) TestServiceConfigWithImageBuildSp suite.packageContentProvider.EXPECT(). GetAbsoluteLocator(testModulePackageId, testModuleMainFileLocator, testBuildContextDir, testNoPackageReplaceOptions). Times(1). - Return(testModuleMainFileLocator, nil) + Return(testBuildContextLocator, nil) suite.packageContentProvider.EXPECT(). GetOnDiskAbsoluteFilePath(testContainerImageLocator). @@ -38,7 +38,7 @@ func (suite *KurtosisTypeConstructorTestSuite) TestServiceConfigWithImageBuildSp } func (t *serviceConfigImageBuildSpecTestCase) GetStarlarkCode() string { - imageBuildSpec := fmt.Sprintf("%s(%s=%q,%s=%q,%s=%q)", + imageBuildSpec := fmt.Sprintf("%s(%s=%q, %s=%q, %s=%q)", service_config.ImageBuildSpecTypeName, service_config.BuiltImageNameAttr, testContainerImageName, @@ -46,7 +46,7 @@ func (t *serviceConfigImageBuildSpecTestCase) GetStarlarkCode() string { testBuildContextDir, service_config.TargetStageAttr, testTargetStage) - return fmt.Sprintf("%s(%s=%q)", + return fmt.Sprintf("%s(%s=%s)", service_config.ServiceConfigTypeName, service_config.ImageAttr, imageBuildSpec) } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go index e607fb0b93..046fa5d5a2 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/static_constants.go @@ -29,6 +29,7 @@ var ( testContainerImageName = "kurtosistech/example-datastore-server" testBuildContextDir = "./" testTargetStage = "builder" + testBuildContextLocator = testModulePackageId testContainerImageLocator = "github.com/kurtosistech/test-package/Dockerfile" testOnDiskContextDirPath = "kurtosis-data/test-package" testOnDiskContainerImagePath = "kurtosis-data/test-package/Dockerfile" diff --git a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go index e59e046508..be9bcd7902 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go @@ -17,6 +17,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/starlark_warning" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" + "github.com/sirupsen/logrus" "go.starlark.net/starlark" "math" "path" @@ -597,6 +598,7 @@ func convertImageAttr( if interpretationErr != nil { return "", nil, interpretationErr } + logrus.Debugf("CONVERT IMAGE ATTRIBUTE: %v %v", imageName, imageBuildSpec) return imageName, imageBuildSpec, nil } else { imageName, interpretationErr := kurtosis_types.SafeCastToString(rawImageAttrValue, ImageAttr) diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go index 592191b36b..9509ec817a 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go @@ -13,6 +13,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/port_spec" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "go.starlark.net/starlark" @@ -33,12 +34,12 @@ var noPackageReplaceOptions = map[string]string{} type StartosisInterpreterIdempotentTestSuite struct { suite.Suite - packageContentProvider *startosis_packages.MockPackageContentProvider + packageContentProvider *mock_package_content_provider.MockPackageContentProvider interpreter *StartosisInterpreter } func (suite *StartosisInterpreterIdempotentTestSuite) SetupTest() { - suite.packageContentProvider = startosis_packages.NewMockPackageContentProvider(suite.T()) + suite.packageContentProvider = mock_package_content_provider.NewMockPackageContentProvider() enclaveDb := getEnclaveDBForTest(suite.T()) thread := &starlark.Thread{ diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_test.go index f449bcba4a..5963725fe6 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_test.go @@ -22,6 +22,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "net" @@ -53,14 +54,14 @@ const ( type StartosisInterpreterTestSuite struct { suite.Suite serviceNetwork *service_network.MockServiceNetwork - packageContentProvider *startosis_packages.MockPackageContentProvider + packageContentProvider *mock_package_content_provider.MockPackageContentProvider runtimeValueStore *runtime_value_store.RuntimeValueStore interpreter *StartosisInterpreter } func (suite *StartosisInterpreterTestSuite) SetupTest() { - suite.packageContentProvider = startosis_packages.NewMockPackageContentProvider(suite.T()) + suite.packageContentProvider = mock_package_content_provider.NewMockPackageContentProvider() enclaveDb := getEnclaveDBForTest(suite.T()) dummySerde := shared_helpers.NewDummyStarlarkValueSerDeForTest()