-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AAKaaS:1 check Component Versions #2023
Merged
Merged
Changes from 73 commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
54f92e2
adding my steps
rosemarieB 1e8e716
messy step
rosemarieB bc18dba
Update abapEnvironmentAssembly.go
rosemarieB d5a705a
clean up
rosemarieB 5c92d0e
Merge https://github.com/SAP/jenkins-library
rosemarieB 43e4fa2
change yaml
rosemarieB 2e8578c
Merge https://github.com/SAP/jenkins-library
rosemarieB 49bb4fe
corrections
rosemarieB 4f3d261
Update cloudFoundryDeploy.go
rosemarieB 512346c
update
rosemarieB cbddd5d
delete simulation step
rosemarieB 26fd7ae
remove simulate
rosemarieB c2243fa
Update PiperGoUtils.groovy
rosemarieB 4c745ca
Update PiperGoUtils.groovy
rosemarieB ebce730
Merge branch 'master' into master
rosemarieB ec058bd
Update CommonStepsTest.groovy
rosemarieB 213e84e
Merge branch 'master' of https://github.com/rosemarieB/jenkins-library
rosemarieB 2538d45
add docu
rosemarieB 1639efe
Update abapEnvironmentAssembly.md
rosemarieB ab0cfd1
Merge branch 'master' into master
DanielMieg 007464e
Merge https://github.com/SAP/jenkins-library
rosemarieB 0f780ea
changes due to PR
rosemarieB 26c4449
Update .gitignore
rosemarieB 6c58d1d
Merge https://github.com/SAP/jenkins-library
rosemarieB ab25fd5
b
rosemarieB 5b2940a
Merge https://github.com/SAP/jenkins-library
rosemarieB 0b0dd65
Merge https://github.com/SAP/jenkins-library
rosemarieB 67d2a36
Merge https://github.com/SAP/jenkins-library
rosemarieB 418bf91
CV list
rosemarieB e036eca
Update abapEnvironmentAssembly.go
rosemarieB 245c97a
testing with simulation
rosemarieB 38cf92e
Update abapEnvironmentAssembly.go
rosemarieB 36e530a
remove simulation
rosemarieB 088e792
renaming
rosemarieB 7b5dcc7
Update mkdocs.yml
rosemarieB 5597f5a
moving service key to yaml and fixing code climate
rosemarieB 28fe073
Update abapEnvironmentAssemblePackages.go
rosemarieB 3ff90f6
Update abapEnvironmentAssemblePackages.go
rosemarieB 7ba8022
Update abapEnvironmentAssemblePackages.go
rosemarieB d520ef3
Update abapEnvironmentAssemblePackages.go
rosemarieB fba6c89
change input
rosemarieB dfb5b18
Merge https://github.com/SAP/jenkins-library
rosemarieB af8c0c6
Merge https://github.com/SAP/jenkins-library
rosemarieB 2a7c3a2
Update abapEnvironmentAssemblePackages.go
rosemarieB 3f45f0a
change json tag
rosemarieB 3b89360
fixed error handling
rosemarieB c178bcd
documentation
rosemarieB 51982a5
Update abapEnvironmentAssemblePackages.md
rosemarieB d8127c6
Update abapEnvironmentAssemblePackages.md
rosemarieB cc1b19e
fixing code climate issues
rosemarieB 6716eeb
fixing code climate issues
rosemarieB 2a14922
Update abapEnvironmentAssemblePackages.yaml
rosemarieB 065f751
Merge https://github.com/SAP/jenkins-library
rosemarieB d738cdd
fixing code climate issues
rosemarieB 72767d8
Update abapEnvironmentAssemblePackages.yaml
rosemarieB 488251d
adding unittests
rosemarieB 1df3690
adding unittests and improved logging
rosemarieB afb8eb6
yaml -> json
rosemarieB 4afce97
Merge https://github.com/SAP/jenkins-library
rosemarieB f5e75e7
change scope of cfServiceKeyName
rosemarieB a34056b
Merge branch 'master' into master
CCFenner 26d53fe
correct indentation
CCFenner 86a4488
Update CommonStepsTest.groovy
CCFenner 9c64c2c
maintain correct step order
CCFenner d64f89e
Merge https://github.com/SAP/jenkins-library
rosemarieB 73f1099
Merge https://github.com/SAP/jenkins-library
rosemarieB b91c80b
Merge https://github.com/SAP/jenkins-library
rosemarieB 39ec367
Merge remote-tracking branch 'upstream/master'
tiloKo eecc0d2
AAKaaS CheckCV step
tiloKo b3147e1
AAKaaS CheckCV step #2
tiloKo 46fa5eb
AAKaaS CheckCV step #3
tiloKo 3a922ba
AAKaaS CheckCV step #4
tiloKo 79e3a5d
Merge branch 'master' into AAKaaS_1_checkCVs
DanielMieg 33186bc
AAKaaS CheckCV step #5
tiloKo 1096962
Merge branch 'master' into AAKaaS_1_checkCVs
tiloKo f65390c
AAKaaS CheckCV step #6
tiloKo 8e30add
Merge branch 'AAKaaS_1_checkCVs' of github.com:rosemarieB/jenkins-lib…
tiloKo 65d31de
AAKaaS CheckCV step #7
tiloKo bdda68f
AAKaaS CheckCV step #8
tiloKo fda0639
Merge branch 'master' into AAKaaS_1_checkCVs
DanielMieg 8421197
AAKaaS CheckCV step #9
tiloKo 4ca1f7d
AAKaaS CheckCV step #10
tiloKo 35fcafa
AAKaaS CheckCV step #11
tiloKo 2e160ef
Merge branch 'master' into AAKaaS_1_checkCVs
tiloKo 411ba10
AAKaaS CheckCV step #12
tiloKo dd41c3e
AAKaaS CheckCV step #13
tiloKo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package cmd | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
abapbuild "github.com/SAP/jenkins-library/pkg/abap/build" | ||
"github.com/SAP/jenkins-library/pkg/abaputils" | ||
"github.com/SAP/jenkins-library/pkg/command" | ||
piperhttp "github.com/SAP/jenkins-library/pkg/http" | ||
"github.com/SAP/jenkins-library/pkg/log" | ||
"github.com/SAP/jenkins-library/pkg/telemetry" | ||
) | ||
|
||
func abapAddonAssemblyKitCheckCVs(config abapAddonAssemblyKitCheckCVsOptions, telemetryData *telemetry.CustomData, cpe *abapAddonAssemblyKitCheckCVsCommonPipelineEnvironment) { | ||
// for command execution use Command | ||
c := command.Command{} | ||
// reroute command output to logging framework | ||
c.Stdout(log.Writer()) | ||
c.Stderr(log.Writer()) | ||
|
||
client := piperhttp.Client{} | ||
|
||
// error situations should stop execution through log.Entry().Fatal() call which leads to an os.Exit(1) in the end | ||
err := runAbapAddonAssemblyKitCheckCVs(&config, telemetryData, &client, cpe, abaputils.ReadAddonDescriptor) | ||
if err != nil { | ||
log.Entry().WithError(err).Fatal("step execution failed") | ||
} | ||
} | ||
|
||
func runAbapAddonAssemblyKitCheckCVs(config *abapAddonAssemblyKitCheckCVsOptions, telemetryData *telemetry.CustomData, client piperhttp.Sender, | ||
cpe *abapAddonAssemblyKitCheckCVsCommonPipelineEnvironment, readAdoDescriptor abaputils.ReadAddonDescriptorType) error { | ||
var addonDescriptorFromCPE abaputils.AddonDescriptor | ||
json.Unmarshal([]byte(config.AddonDescriptor), &addonDescriptorFromCPE) | ||
addonDescriptor, err := readAdoDescriptor(config.AddonDescriptorFileName) | ||
if err != nil { | ||
return err | ||
} | ||
addonDescriptor = combineYAMLRepositoriesWithCPEProduct(addonDescriptor, addonDescriptorFromCPE) | ||
conn := new(abapbuild.Connector) | ||
conn.InitAAKaaS(config.AbapAddonAssemblyKitEndpoint, config.Username, config.Password, client) | ||
|
||
for i := range addonDescriptor.Repositories { | ||
var c cv | ||
c.initCV(addonDescriptor.Repositories[i], *conn) | ||
err := c.validate() | ||
if err != nil { | ||
return err | ||
} | ||
c.copyFieldsToRepo(&addonDescriptor.Repositories[i]) | ||
} | ||
log.Entry().Info("Write the resolved versions to the CommonPipelineEnvironment") | ||
toCPE, _ := json.Marshal(addonDescriptor) | ||
cpe.abap.addonDescriptor = string(toCPE) | ||
return nil | ||
} | ||
|
||
//take the product part from CPE and the repositories part from the YAML file | ||
func combineYAMLRepositoriesWithCPEProduct(addonDescriptor abaputils.AddonDescriptor, addonDescriptorFromCPE abaputils.AddonDescriptor) abaputils.AddonDescriptor { | ||
addonDescriptorFromCPE.Repositories = addonDescriptor.Repositories | ||
return addonDescriptorFromCPE | ||
} | ||
|
||
func (c *cv) initCV(repo abaputils.Repository, conn abapbuild.Connector) { | ||
c.Connector = conn | ||
c.Name = repo.Name | ||
c.VersionYAML = repo.VersionYAML | ||
} | ||
|
||
func (c *cv) copyFieldsToRepo(initialRepo *abaputils.Repository) { | ||
initialRepo.Version = c.Version | ||
initialRepo.SpLevel = c.SpLevel | ||
initialRepo.PatchLevel = c.PatchLevel | ||
} | ||
|
||
func (c *cv) validate() error { | ||
log.Entry().Infof("Validate component %s version %s and resolve version", c.Name, c.VersionYAML) | ||
appendum := "/odata/aas_ocs_package/ValidateComponentVersion?Name='" + c.Name + "'&Version='" + c.VersionYAML + "'" | ||
body, err := c.Connector.Get(appendum) | ||
if err != nil { | ||
return err | ||
} | ||
var jCV jsonCV | ||
json.Unmarshal(body, &jCV) | ||
c.Name = jCV.CV.Name | ||
c.Version = jCV.CV.Version | ||
c.SpLevel = jCV.CV.SpLevel | ||
c.PatchLevel = jCV.CV.PatchLevel | ||
log.Entry().Infof("Resolved version %s, splevel %s, patchlevel %s", c.Version, c.SpLevel, c.PatchLevel) | ||
return nil | ||
} | ||
|
||
type jsonCV struct { | ||
CV *cv `json:"d"` | ||
} | ||
|
||
type cv struct { | ||
abapbuild.Connector | ||
Name string `json:"Name"` | ||
VersionYAML string | ||
Version string `json:"Version"` | ||
SpLevel string `json:"SpLevel"` | ||
PatchLevel string `json:"PatchLevel"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAbapAddonAssemblyKitCheckCVsCommand(t *testing.T) { | ||
|
||
testCmd := AbapAddonAssemblyKitCheckCVsCommand() | ||
|
||
// only high level testing performed - details are tested in step generation procedure | ||
assert.Equal(t, "abapAddonAssemblyKitCheckCVs", testCmd.Use, "command name incorrect") | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth extracting
cv
and it's functions also to theabap
package?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: what does
cv
stand for?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cv is the acronym for "(software)component version" which are the (more or less) independent deployable units of an ABAP system.
Honestly I'm new to go and do not know where to place the coding best. As far as I got the cv struct is only used in this step without reuse in any of the others - that's why I have not extracted it. Anyway what I read so far about recommended directory structure I was a bit surprised there is no "internal" package. So what's the suggestion in this case? Should it be extracted even if there is only on step using it?