1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-04 04:07:16 +02:00

Refactor all instances of iFlow to be integrationFlow (#2992)

This commit is contained in:
Linda Siebert 2021-08-04 16:42:25 +02:00 committed by GitHub
parent bb3f8493ee
commit f9e052e4d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 70 additions and 70 deletions

View File

@ -111,7 +111,7 @@ func runIntegrationArtifactGetMplStatus(
}
if jsonResponse.Exists("d", "results", "0") {
mplStatus := jsonResponse.Path("d.results.0.Status").Data().(string)
commonPipelineEnvironment.custom.iFlowMplStatus = mplStatus
commonPipelineEnvironment.custom.integrationFlowMplStatus = mplStatus
//if error, then return immediately with the error details
if mplStatus == "FAILED" {
@ -160,7 +160,7 @@ func getIntegrationArtifactMPLError(commonPipelineEnvironment *integrationArtifa
return "", errors.Wrapf(readErr, "HTTP response body could not be read, response status code: %v", errorStatusResp.StatusCode)
}
mplErrorDetails := string(responseBody)
commonPipelineEnvironment.custom.iFlowMplError = mplErrorDetails
commonPipelineEnvironment.custom.integrationFlowMplError = mplErrorDetails
return mplErrorDetails, nil
}
if httpErr != nil {

View File

@ -23,8 +23,8 @@ type integrationArtifactGetMplStatusOptions struct {
type integrationArtifactGetMplStatusCommonPipelineEnvironment struct {
custom struct {
iFlowMplStatus string
iFlowMplError string
integrationFlowMplStatus string
integrationFlowMplError string
}
}
@ -34,8 +34,8 @@ func (p *integrationArtifactGetMplStatusCommonPipelineEnvironment) persist(path,
name string
value interface{}
}{
{category: "custom", name: "iFlowMplStatus", value: p.custom.iFlowMplStatus},
{category: "custom", name: "iFlowMplError", value: p.custom.iFlowMplError},
{category: "custom", name: "integrationFlowMplStatus", value: p.custom.integrationFlowMplStatus},
{category: "custom", name: "integrationFlowMplError", value: p.custom.integrationFlowMplError},
}
errCount := 0
@ -182,8 +182,8 @@ func integrationArtifactGetMplStatusMetadata() config.StepData {
Name: "commonPipelineEnvironment",
Type: "piperEnvironment",
Parameters: []map[string]interface{}{
{"Name": "custom/iFlowMplStatus"},
{"Name": "custom/iFlowMplError"},
{"Name": "custom/integrationFlowMplStatus"},
{"Name": "custom/integrationFlowMplError"},
},
},
},

View File

@ -44,7 +44,7 @@ func TestRunIntegrationArtifactGetMplStatus(t *testing.T) {
err := runIntegrationArtifactGetMplStatus(&config, nil, &httpClient, &seOut)
if assert.NoError(t, err) {
assert.EqualValues(t, seOut.custom.iFlowMplStatus, "COMPLETED")
assert.EqualValues(t, seOut.custom.integrationFlowMplStatus, "COMPLETED")
t.Run("check url", func(t *testing.T) {
assert.Equal(t, "https://demo/api/v1/MessageProcessingLogs?$filter=IntegrationArtifact/Id+eq+'flow1'+and+Status+ne+'DISCARDED'&$orderby=LogEnd+desc&$top=1", httpClient.URL)
@ -75,7 +75,7 @@ func TestRunIntegrationArtifactGetMplStatus(t *testing.T) {
seOut := integrationArtifactGetMplStatusCommonPipelineEnvironment{}
err := runIntegrationArtifactGetMplStatus(&config, nil, &httpClient, &seOut)
assert.EqualValues(t, seOut.custom.iFlowMplStatus, "")
assert.EqualValues(t, seOut.custom.integrationFlowMplStatus, "")
assert.EqualError(t, err, "HTTP GET request to https://demo/api/v1/MessageProcessingLogs?$filter=IntegrationArtifact/"+
"Id+eq+'flow1'+and+Status+ne+'DISCARDED'&$orderby=LogEnd+desc&$top=1 failed with error: "+
"Unable to get integration flow MPL status, Response Status code:400")
@ -89,7 +89,7 @@ func TestRunIntegrationArtifactGetMplStatus(t *testing.T) {
message, err := getIntegrationArtifactMPLError(&seOut, "1000111", &httpClient, "demo")
assert.NoError(t, err)
assert.NotNil(t, message)
assert.EqualValues(t, seOut.custom.iFlowMplError, "{\"message\": \"java.lang.IllegalStateException: No credentials for 'smtp' found\"}")
assert.EqualValues(t, seOut.custom.integrationFlowMplError, "{\"message\": \"java.lang.IllegalStateException: No credentials for 'smtp' found\"}")
})
}

View File

@ -106,7 +106,7 @@ func runIntegrationArtifactGetServiceEndpoint(config *integrationArtifactGetServ
if iflowID == config.IntegrationFlowID {
entryPoints := child.S("EntryPoints")
finalEndpoint := entryPoints.Path("results.0.Url").Data().(string)
commonPipelineEnvironment.custom.iFlowServiceEndpoint = finalEndpoint
commonPipelineEnvironment.custom.integrationFlowServiceEndpoint = finalEndpoint
return nil
}
}

View File

@ -23,7 +23,7 @@ type integrationArtifactGetServiceEndpointOptions struct {
type integrationArtifactGetServiceEndpointCommonPipelineEnvironment struct {
custom struct {
iFlowServiceEndpoint string
integrationFlowServiceEndpoint string
}
}
@ -33,7 +33,7 @@ func (p *integrationArtifactGetServiceEndpointCommonPipelineEnvironment) persist
name string
value interface{}
}{
{category: "custom", name: "iFlowServiceEndpoint", value: p.custom.iFlowServiceEndpoint},
{category: "custom", name: "integrationFlowServiceEndpoint", value: p.custom.integrationFlowServiceEndpoint},
}
errCount := 0
@ -180,7 +180,7 @@ func integrationArtifactGetServiceEndpointMetadata() config.StepData {
Name: "commonPipelineEnvironment",
Type: "piperEnvironment",
Parameters: []map[string]interface{}{
{"Name": "custom/iFlowServiceEndpoint"},
{"Name": "custom/integrationFlowServiceEndpoint"},
},
},
},

View File

@ -40,7 +40,7 @@ func TestRunIntegrationArtifactGetServiceEndpoint(t *testing.T) {
httpClient := httpMockCpis{CPIFunction: "IntegrationArtifactGetServiceEndpoint", ResponseBody: ``, TestType: "PositiveAndGetetIntegrationArtifactGetServiceResBody"}
seOut := integrationArtifactGetServiceEndpointCommonPipelineEnvironment{}
err := runIntegrationArtifactGetServiceEndpoint(&config, nil, &httpClient, &seOut)
assert.EqualValues(t, seOut.custom.iFlowServiceEndpoint, "https://demo.cfapps.sap.hana.ondemand.com/http/testwithcert")
assert.EqualValues(t, seOut.custom.integrationFlowServiceEndpoint, "https://demo.cfapps.sap.hana.ondemand.com/http/testwithcert")
if assert.NoError(t, err) {
@ -73,7 +73,7 @@ func TestRunIntegrationArtifactGetServiceEndpoint(t *testing.T) {
seOut := integrationArtifactGetServiceEndpointCommonPipelineEnvironment{}
err := runIntegrationArtifactGetServiceEndpoint(&config, nil, &httpClient, &seOut)
assert.EqualValues(t, seOut.custom.iFlowServiceEndpoint, "")
assert.EqualValues(t, seOut.custom.integrationFlowServiceEndpoint, "")
assert.EqualError(t, err, "HTTP GET request to https://demo/api/v1/ServiceEndpoints?$expand=EntryPoints failed with error: Unable to get integration flow service endpoint, Response Status code:400")
})

View File

@ -67,10 +67,10 @@ func integrationArtifactTriggerIntegrationTest(config integrationArtifactTrigger
func runIntegrationArtifactTriggerIntegrationTest(config *integrationArtifactTriggerIntegrationTestOptions, telemetryData *telemetry.CustomData, utils integrationArtifactTriggerIntegrationTestUtils, httpClient piperhttp.Sender) error {
var commonPipelineEnvironment integrationArtifactGetServiceEndpointCommonPipelineEnvironment
var serviceEndpointUrl string
if len(config.IFlowServiceEndpointURL) > 0 {
serviceEndpointUrl = config.IFlowServiceEndpointURL
if len(config.IntegrationFlowServiceEndpointURL) > 0 {
serviceEndpointUrl = config.IntegrationFlowServiceEndpointURL
} else {
serviceEndpointUrl = commonPipelineEnvironment.custom.iFlowServiceEndpoint
serviceEndpointUrl = commonPipelineEnvironment.custom.integrationFlowServiceEndpoint
if len(serviceEndpointUrl) == 0 {
log.SetErrorCategory(log.ErrorConfiguration)
return fmt.Errorf("IFlowServiceEndpointURL not set")
@ -122,7 +122,7 @@ func callIFlowURL(config *integrationArtifactTriggerIntegrationTestOptions, tele
httpMethod = "GET"
}
serviceKey, err := cpi.ReadCpiServiceKey(config.IFlowServiceKey)
serviceKey, err := cpi.ReadCpiServiceKey(config.IntegrationFlowServiceKey)
if err != nil {
return err
}

View File

@ -15,11 +15,11 @@ import (
)
type integrationArtifactTriggerIntegrationTestOptions struct {
IFlowServiceKey string `json:"iFlowServiceKey,omitempty"`
IntegrationFlowID string `json:"integrationFlowId,omitempty"`
IFlowServiceEndpointURL string `json:"iFlowServiceEndpointUrl,omitempty"`
ContentType string `json:"contentType,omitempty"`
MessageBodyPath string `json:"messageBodyPath,omitempty"`
IntegrationFlowServiceKey string `json:"integrationFlowServiceKey,omitempty"`
IntegrationFlowID string `json:"integrationFlowId,omitempty"`
IntegrationFlowServiceEndpointURL string `json:"integrationFlowServiceEndpointUrl,omitempty"`
ContentType string `json:"contentType,omitempty"`
MessageBodyPath string `json:"messageBodyPath,omitempty"`
}
// IntegrationArtifactTriggerIntegrationTestCommand Test the service endpoint of your iFlow
@ -51,7 +51,7 @@ func IntegrationArtifactTriggerIntegrationTestCommand() *cobra.Command {
log.SetErrorCategory(log.ErrorConfiguration)
return err
}
log.RegisterSecret(stepConfig.IFlowServiceKey)
log.RegisterSecret(stepConfig.IntegrationFlowServiceKey)
if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
@ -98,15 +98,15 @@ func IntegrationArtifactTriggerIntegrationTestCommand() *cobra.Command {
}
func addIntegrationArtifactTriggerIntegrationTestFlags(cmd *cobra.Command, stepConfig *integrationArtifactTriggerIntegrationTestOptions) {
cmd.Flags().StringVar(&stepConfig.IFlowServiceKey, "iFlowServiceKey", os.Getenv("PIPER_iFlowServiceKey"), "Service key JSON string to access the Process Integration Runtime service instance of plan 'integration-flow'")
cmd.Flags().StringVar(&stepConfig.IntegrationFlowServiceKey, "integrationFlowServiceKey", os.Getenv("PIPER_integrationFlowServiceKey"), "Service key JSON string to access the Process Integration Runtime service instance of plan 'integration-flow'")
cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact")
cmd.Flags().StringVar(&stepConfig.IFlowServiceEndpointURL, "iFlowServiceEndpointUrl", os.Getenv("PIPER_iFlowServiceEndpointUrl"), "Specifies the URL endpoint of the iFlow. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.")
cmd.Flags().StringVar(&stepConfig.IntegrationFlowServiceEndpointURL, "integrationFlowServiceEndpointUrl", os.Getenv("PIPER_integrationFlowServiceEndpointUrl"), "Specifies the URL endpoint of the iFlow. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.")
cmd.Flags().StringVar(&stepConfig.ContentType, "contentType", os.Getenv("PIPER_contentType"), "Specifies the content type of the file defined in messageBodyPath e.g. application/json")
cmd.Flags().StringVar(&stepConfig.MessageBodyPath, "messageBodyPath", os.Getenv("PIPER_messageBodyPath"), "Speficfies the relative file path to the message body.")
cmd.MarkFlagRequired("iFlowServiceKey")
cmd.MarkFlagRequired("integrationFlowServiceKey")
cmd.MarkFlagRequired("integrationFlowId")
cmd.MarkFlagRequired("iFlowServiceEndpointUrl")
cmd.MarkFlagRequired("integrationFlowServiceEndpointUrl")
}
// retrieve step metadata
@ -120,15 +120,15 @@ func integrationArtifactTriggerIntegrationTestMetadata() config.StepData {
Spec: config.StepSpec{
Inputs: config.StepInputs{
Secrets: []config.StepSecrets{
{Name: "iFlowServiceKeyCredentialsId", Description: "Jenkins secret text credential ID containing the service key to the Process Integration Runtime service instance of plan 'integration-flow'", Type: "jenkins"},
{Name: "integrationFlowServiceKeyCredentialsId", Description: "Jenkins secret text credential ID containing the service key to the Process Integration Runtime service instance of plan 'integration-flow'", Type: "jenkins"},
},
Parameters: []config.StepParameters{
{
Name: "iFlowServiceKey",
Name: "integrationFlowServiceKey",
ResourceRef: []config.ResourceReference{
{
Name: "iFlowServiceKeyCredentialsId",
Param: "iFlowServiceKey",
Name: "integrationFlowServiceKeyCredentialsId",
Param: "integrationFlowServiceKey",
Type: "secret",
},
},
@ -136,7 +136,7 @@ func integrationArtifactTriggerIntegrationTestMetadata() config.StepData {
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_iFlowServiceKey"),
Default: os.Getenv("PIPER_integrationFlowServiceKey"),
},
{
Name: "integrationFlowId",
@ -148,18 +148,18 @@ func integrationArtifactTriggerIntegrationTestMetadata() config.StepData {
Default: os.Getenv("PIPER_integrationFlowId"),
},
{
Name: "iFlowServiceEndpointUrl",
Name: "integrationFlowServiceEndpointUrl",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/iFlowServiceEndpoint",
Param: "custom/integrationFlowServiceEndpoint",
},
},
Scope: []string{"PARAMETERS"},
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_iFlowServiceEndpointUrl"),
Default: os.Getenv("PIPER_integrationFlowServiceEndpointUrl"),
},
{
Name: "contentType",

View File

@ -35,10 +35,10 @@ func TestRunIntegrationArtifactTriggerIntegrationTest(t *testing.T) {
}
}`
config := integrationArtifactTriggerIntegrationTestOptions{
IFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: "/file.txt",
ContentType: "",
IntegrationFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: "/file.txt",
ContentType: "",
}
utils := newIntegrationArtifactTriggerIntegrationTestTestsUtils()
@ -63,10 +63,10 @@ func TestRunIntegrationArtifactTriggerIntegrationTest(t *testing.T) {
}
}`
config := integrationArtifactTriggerIntegrationTestOptions{
IFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: "test.txt",
ContentType: "txt",
IntegrationFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: "test.txt",
ContentType: "txt",
}
utils := newIntegrationArtifactTriggerIntegrationTestTestsUtils()
@ -94,10 +94,10 @@ func TestRunIntegrationArtifactTriggerIntegrationTest(t *testing.T) {
}
}`
config := integrationArtifactTriggerIntegrationTestOptions{
IFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: filepath.Join(dir, "test.txt"),
ContentType: "txt",
IntegrationFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: filepath.Join(dir, "test.txt"),
ContentType: "txt",
}
utils := newIntegrationArtifactTriggerIntegrationTestTestsUtils()
@ -125,10 +125,10 @@ func TestRunIntegrationArtifactTriggerIntegrationTest(t *testing.T) {
}
}`
config := integrationArtifactTriggerIntegrationTestOptions{
IFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: "",
ContentType: "txt",
IntegrationFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: "",
ContentType: "txt",
}
utils := newIntegrationArtifactTriggerIntegrationTestTestsUtils()
@ -160,10 +160,10 @@ func TestRunIntegrationArtifactTriggerIntegrationTest(t *testing.T) {
}
}`
config := integrationArtifactTriggerIntegrationTestOptions{
IFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: filepath.Join(dir, "test.txt"),
ContentType: "txt",
IntegrationFlowServiceKey: iFlowServiceKey,
IntegrationFlowID: "CPI_IFlow_Call_using_Cert",
MessageBodyPath: filepath.Join(dir, "test.txt"),
ContentType: "txt",
}
utils := newIntegrationArtifactTriggerIntegrationTestTestsUtils()

View File

@ -22,7 +22,7 @@ Example for the use in a YAML configuration file (such as `.pipeline/config.yaml
steps:
<...>
integrationArtifactTriggerIntegrationTest:
iFlowCredentialsId: 'MY_IFLOW_SERVICE_KEY'
integrationFlowServiceKeyCredentialsId: 'MY_INTEGRATION_FLOW_SERVICE_KEY'
integrationFlowId: 'INTEGRATION_FLOW_ID'
contentType: 'text/plain'
messageBodyPath: 'myIntegrationsTest/testBody'

View File

@ -36,5 +36,5 @@ spec:
- name: commonPipelineEnvironment
type: piperEnvironment
params:
- name: custom/iFlowMplStatus
- name: custom/iFlowMplError
- name: custom/integrationFlowMplStatus
- name: custom/integrationFlowMplError

View File

@ -36,4 +36,4 @@ spec:
- name: commonPipelineEnvironment
type: piperEnvironment
params:
- name: custom/iFlowServiceEndpoint
- name: custom/integrationFlowServiceEndpoint

View File

@ -7,11 +7,11 @@ metadata:
spec:
inputs:
secrets:
- name: iFlowServiceKeyCredentialsId
- name: integrationFlowServiceKeyCredentialsId
description: Jenkins secret text credential ID containing the service key to the Process Integration Runtime service instance of plan 'integration-flow'
type: jenkins
params:
- name: iFlowServiceKey
- name: integrationFlowServiceKey
type: string
description: Service key JSON string to access the Process Integration Runtime service instance of plan 'integration-flow'
scope:
@ -19,9 +19,9 @@ spec:
mandatory: true
secret: true
resourceRef:
- name: iFlowServiceKeyCredentialsId
- name: integrationFlowServiceKeyCredentialsId
type: secret
param: iFlowServiceKey
param: integrationFlowServiceKey
- name: integrationFlowId
type: string
description: Specifies the ID of the Integration Flow artifact
@ -31,10 +31,10 @@ spec:
- STEPS
- GENERAL
mandatory: true
- name: iFlowServiceEndpointUrl
- name: integrationFlowServiceEndpointUrl
resourceRef:
- name: commonPipelineEnvironment
param: custom/iFlowServiceEndpoint
param: custom/integrationFlowServiceEndpoint
type: string
description: Specifies the URL endpoint of the iFlow. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.
scope:

View File

@ -5,7 +5,7 @@ import groovy.transform.Field
void call(Map parameters = [:]) {
List credentials = [
[type: 'token', id: 'iFlowServiceKeyCredentialsId', env: ['PIPER_iFlowServiceKey']]
[type: 'token', id: 'integrationFlowServiceKeyCredentialsId', env: ['PIPER_integrationFlowServiceKey']]
]
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials)
}