Skip to content

Commit

Permalink
support trustedCerts for cloneGitRepo (#4909)
Browse files Browse the repository at this point in the history
* support trustedCerts for cloneGitRepo

* some more steps

* Update sap_com_0948.go

* remove warning for config value type

* updated description for certificateNames

* go generate artifacts

* variable order and space in "[]interface {}"
  • Loading branch information
tiloKo authored May 10, 2024
1 parent ff9b3d4 commit ac55ddf
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cmd/abapEnvironmentAssemblePackages_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/abapEnvironmentBuild_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/abapEnvironmentCheckoutBranch.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func runAbapEnvironmentCheckoutBranch(options *abapEnvironmentCheckoutBranchOpti
if errorGetInfo != nil {
log.Entry().WithError(errorGetInfo).Fatal("Parameters for the ABAP Connection not available")
}
connectionDetails.CertificateNames = options.CertificateNames

repositories := []abaputils.Repository{}
err = checkCheckoutBranchRepositoryConfiguration(*options)
Expand Down
33 changes: 22 additions & 11 deletions cmd/abapEnvironmentCheckoutBranch_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/abapEnvironmentCloneGitRepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions,
if errorGetInfo != nil {
return errors.Wrap(errorGetInfo, "Parameters for the ABAP Connection not available")
}
connectionDetails.CertificateNames = config.CertificateNames

log.Entry().Infof("Start cloning %v repositories", len(repositories))
for _, repo := range repositories {
Expand Down
33 changes: 22 additions & 11 deletions cmd/abapEnvironmentCloneGitRepo_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/abapEnvironmentCreateTag.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func runAbapEnvironmentCreateTag(config *abapEnvironmentCreateTagOptions, com ab
if errorGetInfo != nil {
return errors.Wrap(errorGetInfo, "Parameters for the ABAP Connection not available")
}
connectionDetails.CertificateNames = config.CertificateNames

backlog, errorPrepare := prepareBacklog(config)
if errorPrepare != nil {
Expand Down
41 changes: 26 additions & 15 deletions cmd/abapEnvironmentCreateTag_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/abapEnvironmentPullGitRepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func runAbapEnvironmentPullGitRepo(options *abapEnvironmentPullGitRepoOptions, c
if err != nil {
return errors.Wrap(err, "Parameters for the ABAP Connection not available")
}
connectionDetails.CertificateNames = options.CertificateNames

var repositories []abaputils.Repository
err = checkPullRepositoryConfiguration(*options)
Expand Down
11 changes: 11 additions & 0 deletions cmd/abapEnvironmentPullGitRepo_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions pkg/abaputils/abaputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,12 @@ type AbapMetadata struct {

// ConnectionDetailsHTTP contains fields for HTTP connections including the XCSRF token
type ConnectionDetailsHTTP struct {
Host string
User string `json:"user"`
Password string `json:"password"`
URL string `json:"url"`
XCsrfToken string `json:"xcsrftoken"`
Host string
User string `json:"user"`
Password string `json:"password"`
URL string `json:"url"`
XCsrfToken string `json:"xcsrftoken"`
CertificateNames []string `json:"-"`
}

// AbapError contains the error code and the error message for ABAP errors
Expand Down
1 change: 1 addition & 0 deletions pkg/abaputils/sap_com_0510.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ func (api *SAP_COM_0510) initialRequest() error {
CookieJar: cookieJar,
Username: api.con.User,
Password: api.con.Password,
TrustedCerts: api.con.CertificateNames,
})

headConnection := api.con
Expand Down
1 change: 1 addition & 0 deletions pkg/abaputils/sap_com_0948.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func (api *SAP_COM_0948) initialRequest() error {
CookieJar: cookieJar,
Username: api.con.User,
Password: api.con.Password,
TrustedCerts: api.con.CertificateNames,
})

// HEAD request to the root is not sufficient, as an unauthorized called is allowed to do so
Expand Down
12 changes: 11 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,17 @@ func merge(base, overlay map[string]interface{}, metadata StepData) map[string]i
for _, v := range metadata.Spec.Inputs.Parameters {
tVal := reflect.TypeOf(value).String()
if v.Name == key && tVal != v.Type {
log.Entry().Warn("config value provided for ", v.Name, " is of wrong type ", tVal, " should be of type ", v.Type)
if tVal == "[]interface {}" && v.Type == "[]string" {
//json Unmarshal genertes arrays of interface{} for string arrays
for _, interfaceValue := range value.([]interface{}) {
arrayValueType := reflect.TypeOf(interfaceValue).String()
if arrayValueType != "string" {
log.Entry().Warnf("config id %s should only contain strings but contains a %s", v.Name, arrayValueType)
}
}
} else {
log.Entry().Warnf("config value provided for %s is of wrong type %s should be of type %s", v.Name, tVal, v.Type)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/metadata/abapEnvironmentAssemblePackages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ spec:
- STEPS
- name: certificateNames
type: "[]string"
description: certificates for the backend system, this certificates needs to be stored in .pipeline/trustStore
description: "file names of trusted (self-signed) server certificates - need to be stored in .pipeline/trustStore"
mandatory: false
scope:
- PARAMETERS
Expand Down
2 changes: 1 addition & 1 deletion resources/metadata/abapEnvironmentBuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ spec:
- STEPS
- name: certificateNames
type: "[]string"
description: certificates for the backend system, this certificates needs to be stored in .pipeline/trustStore
description: "file names of trusted (self-signed) server certificates - need to be stored in .pipeline/trustStore"
mandatory: false
scope:
- PARAMETERS
Expand Down
9 changes: 9 additions & 0 deletions resources/metadata/abapEnvironmentCheckoutBranch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ spec:
- name: cloudFoundry/serviceKey
- name: cloudFoundry/serviceKeyName
- name: cfServiceKeyName
- name: certificateNames
type: "[]string"
description: "file names of trusted (self-signed) server certificates - need to be stored in .pipeline/trustStore"
mandatory: false
scope:
- PARAMETERS
- STAGES
- STEPS
- GENERAL
containers:
- name: cf
image: ppiper/cf-cli:v12
9 changes: 9 additions & 0 deletions resources/metadata/abapEnvironmentCloneGitRepo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ spec:
- name: cloudFoundry/serviceKey
- name: cloudFoundry/serviceKeyName
- name: cfServiceKey
- name: certificateNames
type: "[]string"
description: "file names of trusted (self-signed) server certificates - need to be stored in .pipeline/trustStore"
mandatory: false
scope:
- PARAMETERS
- STAGES
- STEPS
- GENERAL
containers:
- name: cf
image: ppiper/cf-cli:v12
Loading

0 comments on commit ac55ddf

Please sign in to comment.