You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/05/17 06:22:23 UTC

[GitHub] [camel-k] tadayosi opened a new pull request, #3279: chore(cmd/trait): refactor cmd & trait packages

tadayosi opened a new pull request, #3279:
URL: https://github.com/apache/camel-k/pull/3279

   <!-- Description -->
   
   Moved test and helper functions to where they should be.
   
   
   <!--
   Enter your extended release note in the below block. If the PR requires
   additional action from users switching to the new release, include the string
   "action required". If no release note is required, write "NONE". 
   
   You can (optionally) mark this PR with labels "kind/bug" or "kind/feature" to make sure
   the text is added to the right section of the release notes. 
   -->
   
   **Release Note**
   ```release-note
   NONE
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] tadayosi commented on pull request #3279: chore(cmd/trait): refactor cmd & trait packages

Posted by GitBox <gi...@apache.org>.
tadayosi commented on PR #3279:
URL: https://github.com/apache/camel-k/pull/3279#issuecomment-1129579155

   @squakez Actually the tests in `trait_types_test.go` are for testing the methods `e.collectConfigurationValues()` and `e.collectConfigurationPairs()`, which operate on the deprecated `Configuration` fields. So I don't think there is any point in having those tests if we rewrite them to use the corresponding traits.
   
   I think the best timing to remove those tests is when we finally remove the deprecated fields and related coded.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] tadayosi merged pull request #3279: chore(cmd/trait): refactor cmd & trait packages

Posted by GitBox <gi...@apache.org>.
tadayosi merged PR #3279:
URL: https://github.com/apache/camel-k/pull/3279


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] squakez commented on a diff in pull request #3279: chore(cmd/trait): refactor cmd & trait packages

Posted by GitBox <gi...@apache.org>.
squakez commented on code in PR #3279:
URL: https://github.com/apache/camel-k/pull/3279#discussion_r874925513


##########
pkg/trait/trait_types_test.go:
##########
@@ -45,89 +38,79 @@ func TestMultilinePropertiesHandled(t *testing.T) {
 	assert.Equal(t, "prop = multi\\nline\n", cm.Data["application.properties"])
 }
 
-func createNominalDeploymentTraitTest() (*Environment, *appsv1.Deployment) {
-	deployment := &appsv1.Deployment{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: appsv1.DeploymentSpec{
-			Template: corev1.PodTemplateSpec{},
-		},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationValues(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-integration"},
+					{Type: "env", Value: "my-env-integration"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(deployment),
-	}
-
-	return environment, deployment
-}
-
-func createNominalMissingDeploymentTraitTest() *Environment {
-	environment := &Environment{
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
+		IntegrationKit: &v1.IntegrationKit{
+			Spec: v1.IntegrationKitSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-kit"},
+					{Type: "property", Value: "my-p-kit"},
+				},
 			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+		},
+		Platform: &v1.IntegrationPlatform{
+			Spec: v1.IntegrationPlatformSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-platform"},
+					{Type: "secret", Value: "my-secret-platform"},
+					{Type: "property", Value: "my-p-platform"},
+					{Type: "env", Value: "my-env-platform"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(),
 	}
+	e.Platform.ResyncStatusFullConfig()
 
-	return environment
+	assert.Contains(t, e.collectConfigurationValues("configmap"), "my-cm-integration")
+	assert.Contains(t, e.collectConfigurationValues("secret"), "my-secret-platform")
+	assert.Contains(t, e.collectConfigurationValues("property"), "my-p-kit")
+	assert.Contains(t, e.collectConfigurationValues("env"), "my-env-integration")
 }
 
-func createNominalKnativeServiceTraitTest() (*Environment, *serving.Service) {
-	knativeService := &serving.Service{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: serving.ServiceSpec{},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationPairs(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{

Review Comment:
   Ditto



##########
pkg/trait/trait_types_test.go:
##########
@@ -45,89 +38,79 @@ func TestMultilinePropertiesHandled(t *testing.T) {
 	assert.Equal(t, "prop = multi\\nline\n", cm.Data["application.properties"])
 }
 
-func createNominalDeploymentTraitTest() (*Environment, *appsv1.Deployment) {
-	deployment := &appsv1.Deployment{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: appsv1.DeploymentSpec{
-			Template: corev1.PodTemplateSpec{},
-		},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationValues(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-integration"},
+					{Type: "env", Value: "my-env-integration"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(deployment),
-	}
-
-	return environment, deployment
-}
-
-func createNominalMissingDeploymentTraitTest() *Environment {
-	environment := &Environment{
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
+		IntegrationKit: &v1.IntegrationKit{
+			Spec: v1.IntegrationKitSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-kit"},
+					{Type: "property", Value: "my-p-kit"},
+				},
 			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+		},
+		Platform: &v1.IntegrationPlatform{
+			Spec: v1.IntegrationPlatformSpec{
+				Configuration: []v1.ConfigurationSpec{

Review Comment:
   Not yet deprecated, but it will be soon. Let's try to use traits instead.



##########
pkg/trait/trait_types_test.go:
##########
@@ -45,89 +38,79 @@ func TestMultilinePropertiesHandled(t *testing.T) {
 	assert.Equal(t, "prop = multi\\nline\n", cm.Data["application.properties"])
 }
 
-func createNominalDeploymentTraitTest() (*Environment, *appsv1.Deployment) {
-	deployment := &appsv1.Deployment{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: appsv1.DeploymentSpec{
-			Template: corev1.PodTemplateSpec{},
-		},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationValues(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-integration"},
+					{Type: "env", Value: "my-env-integration"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(deployment),
-	}
-
-	return environment, deployment
-}
-
-func createNominalMissingDeploymentTraitTest() *Environment {
-	environment := &Environment{
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
+		IntegrationKit: &v1.IntegrationKit{
+			Spec: v1.IntegrationKitSpec{
+				Configuration: []v1.ConfigurationSpec{

Review Comment:
   Not yet deprecated, but it will be soon. Let's try to use traits instead.



##########
pkg/trait/trait_types_test.go:
##########
@@ -45,89 +38,79 @@ func TestMultilinePropertiesHandled(t *testing.T) {
 	assert.Equal(t, "prop = multi\\nline\n", cm.Data["application.properties"])
 }
 
-func createNominalDeploymentTraitTest() (*Environment, *appsv1.Deployment) {
-	deployment := &appsv1.Deployment{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: appsv1.DeploymentSpec{
-			Template: corev1.PodTemplateSpec{},
-		},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationValues(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-integration"},
+					{Type: "env", Value: "my-env-integration"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(deployment),
-	}
-
-	return environment, deployment
-}
-
-func createNominalMissingDeploymentTraitTest() *Environment {
-	environment := &Environment{
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
+		IntegrationKit: &v1.IntegrationKit{
+			Spec: v1.IntegrationKitSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-kit"},
+					{Type: "property", Value: "my-p-kit"},
+				},
 			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+		},
+		Platform: &v1.IntegrationPlatform{
+			Spec: v1.IntegrationPlatformSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-platform"},
+					{Type: "secret", Value: "my-secret-platform"},
+					{Type: "property", Value: "my-p-platform"},
+					{Type: "env", Value: "my-env-platform"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(),
 	}
+	e.Platform.ResyncStatusFullConfig()
 
-	return environment
+	assert.Contains(t, e.collectConfigurationValues("configmap"), "my-cm-integration")
+	assert.Contains(t, e.collectConfigurationValues("secret"), "my-secret-platform")
+	assert.Contains(t, e.collectConfigurationValues("property"), "my-p-kit")
+	assert.Contains(t, e.collectConfigurationValues("env"), "my-env-integration")
 }
 
-func createNominalKnativeServiceTraitTest() (*Environment, *serving.Service) {
-	knativeService := &serving.Service{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: serving.ServiceSpec{},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationPairs(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "property", Value: "p1=integration"},
+					{Type: "property", Value: "p4=integration"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(knativeService),
-	}
-
-	return environment, knativeService
-}
-
-func createNominalCronJobTraitTest() (*Environment, *v1beta1.CronJob) {
-	cronJob := &v1beta1.CronJob{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: v1beta1.CronJobSpec{},
-	}
-
-	environment := &Environment{
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
+		IntegrationKit: &v1.IntegrationKit{
+			Spec: v1.IntegrationKitSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "property", Value: "p1=kit"},
+					{Type: "property", Value: "p2=kit"},
+				},
 			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+		},
+		Platform: &v1.IntegrationPlatform{
+			Spec: v1.IntegrationPlatformSpec{
+				Configuration: []v1.ConfigurationSpec{

Review Comment:
   ditto



##########
pkg/trait/trait_types_test.go:
##########
@@ -45,89 +38,79 @@ func TestMultilinePropertiesHandled(t *testing.T) {
 	assert.Equal(t, "prop = multi\\nline\n", cm.Data["application.properties"])
 }
 
-func createNominalDeploymentTraitTest() (*Environment, *appsv1.Deployment) {
-	deployment := &appsv1.Deployment{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: appsv1.DeploymentSpec{
-			Template: corev1.PodTemplateSpec{},
-		},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationValues(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-integration"},
+					{Type: "env", Value: "my-env-integration"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(deployment),
-	}
-
-	return environment, deployment
-}
-
-func createNominalMissingDeploymentTraitTest() *Environment {
-	environment := &Environment{
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
+		IntegrationKit: &v1.IntegrationKit{
+			Spec: v1.IntegrationKitSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-kit"},
+					{Type: "property", Value: "my-p-kit"},
+				},
 			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+		},
+		Platform: &v1.IntegrationPlatform{
+			Spec: v1.IntegrationPlatformSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "configmap", Value: "my-cm-platform"},
+					{Type: "secret", Value: "my-secret-platform"},
+					{Type: "property", Value: "my-p-platform"},
+					{Type: "env", Value: "my-env-platform"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(),
 	}
+	e.Platform.ResyncStatusFullConfig()
 
-	return environment
+	assert.Contains(t, e.collectConfigurationValues("configmap"), "my-cm-integration")
+	assert.Contains(t, e.collectConfigurationValues("secret"), "my-secret-platform")
+	assert.Contains(t, e.collectConfigurationValues("property"), "my-p-kit")
+	assert.Contains(t, e.collectConfigurationValues("env"), "my-env-integration")
 }
 
-func createNominalKnativeServiceTraitTest() (*Environment, *serving.Service) {
-	knativeService := &serving.Service{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: serving.ServiceSpec{},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationPairs(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{
+					{Type: "property", Value: "p1=integration"},
+					{Type: "property", Value: "p4=integration"},
+				},
 			},
 		},
-		Resources: kubernetes.NewCollection(knativeService),
-	}
-
-	return environment, knativeService
-}
-
-func createNominalCronJobTraitTest() (*Environment, *v1beta1.CronJob) {
-	cronJob := &v1beta1.CronJob{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: v1beta1.CronJobSpec{},
-	}
-
-	environment := &Environment{
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
+		IntegrationKit: &v1.IntegrationKit{
+			Spec: v1.IntegrationKitSpec{
+				Configuration: []v1.ConfigurationSpec{

Review Comment:
   ditto



##########
pkg/trait/trait_types_test.go:
##########
@@ -45,89 +38,79 @@ func TestMultilinePropertiesHandled(t *testing.T) {
 	assert.Equal(t, "prop = multi\\nline\n", cm.Data["application.properties"])
 }
 
-func createNominalDeploymentTraitTest() (*Environment, *appsv1.Deployment) {
-	deployment := &appsv1.Deployment{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "integration-name",
-		},
-		Spec: appsv1.DeploymentSpec{
-			Template: corev1.PodTemplateSpec{},
-		},
-	}
-
-	environment := &Environment{
+func TestCollectConfigurationValues(t *testing.T) {
+	e := Environment{
 		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name: "integration-name",
-			},
-			Status: v1.IntegrationStatus{
-				Phase: v1.IntegrationPhaseDeploying,
+			Spec: v1.IntegrationSpec{
+				Configuration: []v1.ConfigurationSpec{

Review Comment:
   This is deprecated. We should use related traits instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org