Skip to content
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: 2 Check Product Version #2037

Merged
merged 79 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
54f92e2
adding my steps
rosemarieB Jul 30, 2020
1e8e716
messy step
rosemarieB Jul 30, 2020
bc18dba
Update abapEnvironmentAssembly.go
rosemarieB Jul 30, 2020
d5a705a
clean up
rosemarieB Jul 31, 2020
5c92d0e
Merge https://github.com/SAP/jenkins-library
rosemarieB Jul 31, 2020
43e4fa2
change yaml
rosemarieB Aug 5, 2020
2e8578c
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 5, 2020
49bb4fe
corrections
rosemarieB Aug 5, 2020
4f3d261
Update cloudFoundryDeploy.go
rosemarieB Aug 5, 2020
512346c
update
rosemarieB Aug 5, 2020
cbddd5d
delete simulation step
rosemarieB Aug 5, 2020
26fd7ae
remove simulate
rosemarieB Aug 5, 2020
c2243fa
Update PiperGoUtils.groovy
rosemarieB Aug 5, 2020
4c745ca
Update PiperGoUtils.groovy
rosemarieB Aug 5, 2020
ebce730
Merge branch 'master' into master
rosemarieB Aug 5, 2020
ec058bd
Update CommonStepsTest.groovy
rosemarieB Aug 5, 2020
213e84e
Merge branch 'master' of https://github.com/rosemarieB/jenkins-library
rosemarieB Aug 5, 2020
2538d45
add docu
rosemarieB Aug 5, 2020
1639efe
Update abapEnvironmentAssembly.md
rosemarieB Aug 5, 2020
ab0cfd1
Merge branch 'master' into master
DanielMieg Aug 6, 2020
007464e
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 7, 2020
0f780ea
changes due to PR
rosemarieB Aug 7, 2020
26c4449
Update .gitignore
rosemarieB Aug 7, 2020
6c58d1d
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 12, 2020
ab25fd5
b
rosemarieB Aug 12, 2020
5b2940a
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 13, 2020
0b0dd65
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 14, 2020
67d2a36
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 14, 2020
418bf91
CV list
rosemarieB Aug 14, 2020
e036eca
Update abapEnvironmentAssembly.go
rosemarieB Aug 17, 2020
245c97a
testing with simulation
rosemarieB Aug 17, 2020
38cf92e
Update abapEnvironmentAssembly.go
rosemarieB Aug 17, 2020
36e530a
remove simulation
rosemarieB Aug 17, 2020
088e792
renaming
rosemarieB Aug 17, 2020
7b5dcc7
Update mkdocs.yml
rosemarieB Aug 17, 2020
5597f5a
moving service key to yaml and fixing code climate
rosemarieB Aug 19, 2020
28fe073
Update abapEnvironmentAssemblePackages.go
rosemarieB Aug 20, 2020
3ff90f6
Update abapEnvironmentAssemblePackages.go
rosemarieB Aug 20, 2020
7ba8022
Update abapEnvironmentAssemblePackages.go
rosemarieB Aug 20, 2020
d520ef3
Update abapEnvironmentAssemblePackages.go
rosemarieB Aug 21, 2020
fba6c89
change input
rosemarieB Aug 21, 2020
dfb5b18
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 21, 2020
af8c0c6
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 21, 2020
2a7c3a2
Update abapEnvironmentAssemblePackages.go
rosemarieB Aug 21, 2020
3f45f0a
change json tag
rosemarieB Aug 24, 2020
3b89360
fixed error handling
rosemarieB Aug 24, 2020
c178bcd
documentation
rosemarieB Aug 25, 2020
51982a5
Update abapEnvironmentAssemblePackages.md
rosemarieB Aug 25, 2020
d8127c6
Update abapEnvironmentAssemblePackages.md
rosemarieB Aug 25, 2020
cc1b19e
fixing code climate issues
rosemarieB Aug 25, 2020
6716eeb
fixing code climate issues
rosemarieB Aug 25, 2020
2a14922
Update abapEnvironmentAssemblePackages.yaml
rosemarieB Aug 25, 2020
065f751
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 25, 2020
d738cdd
fixing code climate issues
rosemarieB Aug 25, 2020
72767d8
Update abapEnvironmentAssemblePackages.yaml
rosemarieB Aug 25, 2020
488251d
adding unittests
rosemarieB Aug 25, 2020
1df3690
adding unittests and improved logging
rosemarieB Aug 25, 2020
afb8eb6
yaml -> json
rosemarieB Aug 26, 2020
4afce97
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 26, 2020
f5e75e7
change scope of cfServiceKeyName
rosemarieB Aug 26, 2020
a34056b
Merge branch 'master' into master
CCFenner Aug 26, 2020
26d53fe
correct indentation
CCFenner Aug 26, 2020
86a4488
Update CommonStepsTest.groovy
CCFenner Aug 26, 2020
9c64c2c
maintain correct step order
CCFenner Aug 26, 2020
d64f89e
Merge https://github.com/SAP/jenkins-library
rosemarieB Aug 27, 2020
73f1099
Merge https://github.com/SAP/jenkins-library
rosemarieB Sep 2, 2020
b91c80b
Merge https://github.com/SAP/jenkins-library
rosemarieB Sep 3, 2020
39ec367
Merge remote-tracking branch 'upstream/master'
tiloKo Sep 14, 2020
e1a8a8b
Merge remote-tracking branch 'upstream/master'
tiloKo Sep 17, 2020
15f08f4
AAKaaS CheckPV step
tiloKo Sep 17, 2020
a15d533
AAKaaS CheckPV step #2
tiloKo Sep 17, 2020
fd6867e
AAKaaS CheckPV step #3
tiloKo Sep 17, 2020
eb2c3e6
AAKaaS CheckPV step #4
tiloKo Sep 17, 2020
850e612
AAKaaS CheckPV step #5
tiloKo Sep 17, 2020
ddf118a
Update resources/metadata/abapAddonAssemblyKitCheckCVs.yaml
tiloKo Sep 17, 2020
1a57e2e
Update resources/metadata/abapAddonAssemblyKitCheckPV.yaml
tiloKo Sep 17, 2020
87099a5
Update resources/metadata/abapAddonAssemblyKitCheckPV.yaml
tiloKo Sep 17, 2020
c25adac
Update resources/metadata/abapAddonAssemblyKitCheckCVs.yaml
tiloKo Sep 17, 2020
21f82ca
AAKaaS CheckPV step #6
tiloKo Sep 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions cmd/abapAddonAssemblyKitCheckCVs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func runAbapAddonAssemblyKitCheckCVs(config *abapAddonAssemblyKitCheckCVsOptions
conn.InitAAKaaS(config.AbapAddonAssemblyKitEndpoint, config.Username, config.Password, client)

for i := range addonDescriptor.Repositories {
var c cv
var c componentVersion
c.initCV(addonDescriptor.Repositories[i], *conn)
err := c.validate()
if err != nil {
Expand All @@ -60,40 +60,40 @@ func combineYAMLRepositoriesWithCPEProduct(addonDescriptor abaputils.AddonDescri
return addonDescriptorFromCPE
}

func (c *cv) initCV(repo abaputils.Repository, conn abapbuild.Connector) {
func (c *componentVersion) 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) {
func (c *componentVersion) copyFieldsToRepo(initialRepo *abaputils.Repository) {
initialRepo.Version = c.Version
initialRepo.SpLevel = c.SpLevel
initialRepo.PatchLevel = c.PatchLevel
}

func (c *cv) validate() error {
func (c *componentVersion) 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
var jCV jsonComponentVersion
json.Unmarshal(body, &jCV)
c.Name = jCV.CV.Name
c.Version = jCV.CV.Version
c.SpLevel = jCV.CV.SpLevel
c.PatchLevel = jCV.CV.PatchLevel
c.Name = jCV.ComponentVersion.Name
c.Version = jCV.ComponentVersion.Version
c.SpLevel = jCV.ComponentVersion.SpLevel
c.PatchLevel = jCV.ComponentVersion.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 jsonComponentVersion struct {
ComponentVersion *componentVersion `json:"d"`
}

type cv struct {
type componentVersion struct {
abapbuild.Connector
Name string `json:"Name"`
VersionYAML string
Expand Down
4 changes: 2 additions & 2 deletions cmd/abapAddonAssemblyKitCheckCVs_generated.go

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

8 changes: 4 additions & 4 deletions cmd/abapAddonAssemblyKitCheckCVs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestInitCV(t *testing.T) {
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
}
var c cv
var c componentVersion
c.initCV(repo, *conn)
assert.Equal(t, "/DRNMSPC/COMP01", c.Name)
assert.Equal(t, "1.2.3", c.VersionYAML)
Expand All @@ -89,7 +89,7 @@ func TestValidateCV(t *testing.T) {
conn.Client = &abaputils.ClientMock{
Body: responseCheckCVs,
}
c := cv{
c := componentVersion{
Connector: *conn,
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
Expand All @@ -108,7 +108,7 @@ func TestValidateCV(t *testing.T) {
Body: "ErrorBody",
Error: errors.New("Validation failed"),
}
c := cv{
c := componentVersion{
Connector: *conn,
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
Expand All @@ -127,7 +127,7 @@ func TestCopyFieldsCV(t *testing.T) {
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
}
var c cv
var c componentVersion
c.Version = "0001"
c.SpLevel = "0002"
c.PatchLevel = "0003"
Expand Down
96 changes: 96 additions & 0 deletions cmd/abapAddonAssemblyKitCheckPV.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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 abapAddonAssemblyKitCheckPV(config abapAddonAssemblyKitCheckPVOptions, telemetryData *telemetry.CustomData, cpe *abapAddonAssemblyKitCheckPVCommonPipelineEnvironment) {
// 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 := runAbapAddonAssemblyKitCheckPV(&config, telemetryData, &client, cpe, abaputils.ReadAddonDescriptor)
if err != nil {
log.Entry().WithError(err).Fatal("step execution failed")
}
}

func runAbapAddonAssemblyKitCheckPV(config *abapAddonAssemblyKitCheckPVOptions, telemetryData *telemetry.CustomData, client piperhttp.Sender,
cpe *abapAddonAssemblyKitCheckPVCommonPipelineEnvironment, readAdoDescriptor abaputils.ReadAddonDescriptorType) error {
var addonDescriptorFromCPE abaputils.AddonDescriptor
json.Unmarshal([]byte(config.AddonDescriptor), &addonDescriptorFromCPE)
addonDescriptor, err := readAdoDescriptor(config.AddonDescriptorFileName)
addonDescriptor = combineYAMLRepositoriesWithCPEProduct(addonDescriptor, addonDescriptorFromCPE)
if err != nil {
return err
}
conn := new(abapbuild.Connector)
conn.InitAAKaaS(config.AbapAddonAssemblyKitEndpoint, config.Username, config.Password, client)

var p productVersion
p.init(addonDescriptor, *conn)
err = p.validate()
if err != nil {
return err
}
p.copyFieldsToRepo(&addonDescriptor)
log.Entry().Info("Write the resolved version to the CommonPipelineEnvironment")
toCPE, _ := json.Marshal(addonDescriptor)
cpe.abap.addonDescriptor = string(toCPE)
return nil
}

func (p *productVersion) init(desc abaputils.AddonDescriptor, conn abapbuild.Connector) {
p.Connector = conn
p.Name = desc.AddonProduct
p.VersionYAML = desc.AddonVersionYAML
}

func (p *productVersion) copyFieldsToRepo(initialAddonDescriptor *abaputils.AddonDescriptor) {
initialAddonDescriptor.AddonVersion = p.Version
initialAddonDescriptor.AddonSpsLevel = p.SpsLevel
initialAddonDescriptor.AddonPatchLevel = p.PatchLevel
}

func (p *productVersion) validate() error {
log.Entry().Infof("Validate product %s version %s and resolve version", p.Name, p.VersionYAML)
appendum := "/odata/aas_ocs_package/ValidateProductVersion?Name='" + p.Name + "'&Version='" + p.VersionYAML + "'"
body, err := p.Connector.Get(appendum)
if err != nil {
return err
}
var jPV jsonProductVersion
json.Unmarshal(body, &jPV)
p.Name = jPV.ProductVersion.Name
p.Version = jPV.ProductVersion.Version
p.SpsLevel = jPV.ProductVersion.SpsLevel
p.PatchLevel = jPV.ProductVersion.PatchLevel
log.Entry().Infof("Resolved version %s, spslevel %s, patchlevel %s", p.Version, p.SpsLevel, p.PatchLevel)
return nil
}

type jsonProductVersion struct {
ProductVersion *productVersion `json:"d"`
}

type productVersion struct {
abapbuild.Connector
Name string `json:"Name"`
VersionYAML string
Version string `json:"Version"`
SpsLevel string `json:"SpsLevel"`
PatchLevel string `json:"PatchLevel"`
TargetVectorID string
}
186 changes: 186 additions & 0 deletions cmd/abapAddonAssemblyKitCheckPV_generated.go

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

Loading