You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	Remove version from deploy step (#2978)
This commit is contained in:
		| @@ -72,7 +72,7 @@ func runIntegrationArtifactDeploy(config *integrationArtifactDeployOptions, tele | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	deployURL := fmt.Sprintf("%s/api/v1/DeployIntegrationDesigntimeArtifact?Id='%s'&Version='%s'", serviceKey.OAuth.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	deployURL := fmt.Sprintf("%s/api/v1/DeployIntegrationDesigntimeArtifact?Id='%s'&Version='%s'", serviceKey.OAuth.Host, config.IntegrationFlowID, "Active") | ||||
|  | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: serviceKey.OAuth.OAuthTokenProviderURL, Username: serviceKey.OAuth.ClientID, Password: serviceKey.OAuth.ClientSecret, Client: httpClient} | ||||
| 	token, err := cpi.CommonUtils.GetBearerToken(tokenParameters) | ||||
|   | ||||
| @@ -15,9 +15,8 @@ import ( | ||||
| ) | ||||
|  | ||||
| type integrationArtifactDeployOptions struct { | ||||
| 	APIServiceKey          string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID      string `json:"integrationFlowId,omitempty"` | ||||
| 	IntegrationFlowVersion string `json:"integrationFlowVersion,omitempty"` | ||||
| 	APIServiceKey     string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID string `json:"integrationFlowId,omitempty"` | ||||
| } | ||||
|  | ||||
| // IntegrationArtifactDeployCommand Deploy a CPI integration flow | ||||
| @@ -98,11 +97,9 @@ func IntegrationArtifactDeployCommand() *cobra.Command { | ||||
| func addIntegrationArtifactDeployFlags(cmd *cobra.Command, stepConfig *integrationArtifactDeployOptions) { | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIServiceKey, "apiServiceKey", os.Getenv("PIPER_apiServiceKey"), "Service key JSON string to access the Process Integration Runtime service instance of plan 'api'") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowVersion, "integrationFlowVersion", os.Getenv("PIPER_integrationFlowVersion"), "Specifies the version of the Integration Flow artifact") | ||||
|  | ||||
| 	cmd.MarkFlagRequired("apiServiceKey") | ||||
| 	cmd.MarkFlagRequired("integrationFlowId") | ||||
| 	cmd.MarkFlagRequired("integrationFlowVersion") | ||||
| } | ||||
|  | ||||
| // retrieve step metadata | ||||
| @@ -143,15 +140,6 @@ func integrationArtifactDeployMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_integrationFlowId"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "integrationFlowVersion", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "GENERAL", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_integrationFlowVersion"), | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
|   | ||||
| @@ -39,9 +39,8 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "flow1", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "", ResponseBody: ``, TestType: "PositiveAndDeployIntegrationDesigntimeArtifactResBody"} | ||||
| @@ -72,9 +71,8 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "flow1", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "FailIntegrationDesigntimeArtifactDeployment", ResponseBody: ``, TestType: "Negative"} | ||||
| @@ -84,7 +82,7 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 		if assert.Error(t, err) { | ||||
|  | ||||
| 			t.Run("check url", func(t *testing.T) { | ||||
| 				assert.Equal(t, "https://demo/api/v1/DeployIntegrationDesigntimeArtifact?Id='flow1'&Version='1.0.1'", httpClient.URL) | ||||
| 				assert.Equal(t, "https://demo/api/v1/DeployIntegrationDesigntimeArtifact?Id='flow1'&Version='Active'", httpClient.URL) | ||||
| 			}) | ||||
|  | ||||
| 			t.Run("check method", func(t *testing.T) { | ||||
| @@ -105,9 +103,8 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "flow1", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "", ResponseBody: ``, TestType: "NegativeAndDeployIntegrationDesigntimeArtifactResBody"} | ||||
| @@ -130,9 +127,8 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "flow1", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "GetIntegrationArtifactDeployStatus", Options: clientOptions, ResponseBody: ``, TestType: "PositiveAndDeployIntegrationDesigntimeArtifactResBody"} | ||||
| @@ -157,9 +153,8 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "flow1", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "GetIntegrationArtifactDeployErrorDetails", Options: clientOptions, ResponseBody: ``, TestType: "PositiveAndGetDeployedIntegrationDesigntimeArtifactErrorResBody"} | ||||
|   | ||||
| @@ -26,5 +26,4 @@ steps: | ||||
|   integrationArtifactDeploy: | ||||
|     cpiApiServiceKeyCredentialsId: 'MY_API_SERVICE_KEY' | ||||
|     integrationFlowId: 'MY_INTEGRATION_FLOW_NAME' | ||||
|     integrationFlowVersion: 'MY_INTEGRATION_FLOW_VERSION' | ||||
| ``` | ||||
|   | ||||
| @@ -418,7 +418,7 @@ func GetCPIFunctionNameByURLCheck(url, method, testType string) string { | ||||
|  | ||||
| 	case "https://demo/api/v1/IntegrationDesigntimeArtifacts": | ||||
| 		return GetFunctionNameByTestTypeAndMethod(method, testType) | ||||
| 	case "https://demo/api/v1/DeployIntegrationDesigntimeArtifact?Id='flow1'&Version='1.0.1'": | ||||
| 	case "https://demo/api/v1/DeployIntegrationDesigntimeArtifact?Id='flow1'&Version='Active'": | ||||
| 		return GetFunctionNameByTestTypeAndMethod(method, testType) | ||||
| 	case "https://demo/api/v1/IntegrationRuntimeArtifacts('flow1')": | ||||
| 		return "GetIntegrationArtifactDeployStatus" | ||||
|   | ||||
| @@ -31,12 +31,3 @@ spec: | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: integrationFlowVersion | ||||
|         type: string | ||||
|         description: Specifies the version of the Integration Flow artifact | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - GENERAL | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|   | ||||
		Reference in New Issue
	
	Block a user