1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/abap/aakaas/aakUtils.go
rosemarieB e6c5c8a72f
Abap refactoring (#3340)
* Update abapAddonAssemblyKitReleasePackages.go

* add error handling for initAAKaaS

* runtime to config, url.QueryEscape, check return body

* Update abapAddonAssemblyKitCheckCVs_test.go

* add log entrys for testing

* correct yaml

* change unmarshal logic

* Update abapAddonAssemblyKitCheckPV_test.go

* adding utils functionality

* Update bfw_test.go

* reset CheckPV

* reset CheckCVs

* reset ReserveNextPackages

* set back CheckPV and CheckCVs

* moving mock

* renaming

* renaming

* moving mocking to checkCVs test

* fixing unittests

* trying mock with comment

* referencing unittest to mockfile

* Update abapAddonAssemblyKitCheckCVs.go

* Update cmd/abapAddonAssemblyKitCheckPV.go

Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>

* Update cmd/abapAddonAssemblyKitReleasePackages.go

Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>

* Update cmd/abapAddonAssemblyKitPublishTargetVector.go

Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>

* Update cmd/abapAddonAssemblyKitReserveNextPackages.go

Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>

* fixing unittests

* fixing mock comment

Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>
2021-12-09 12:54:18 +01:00

62 lines
1.6 KiB
Go

package aakaas
import (
"time"
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"
)
type AakUtils interface {
command.ExecRunner
abapbuild.HTTPSendLoader
ReadAddonDescriptor(FileName string) (abaputils.AddonDescriptor, error)
GetMaxRuntime() time.Duration
GetPollingInterval() time.Duration
}
type AakBundle struct {
*command.Command
*piperhttp.Client
maxRuntime time.Duration
pollingInterval time.Duration
}
func (bundle *AakBundle) GetMaxRuntime() time.Duration {
return bundle.maxRuntime
}
func (bundle *AakBundle) GetPollingInterval() time.Duration {
return bundle.pollingInterval
}
func (bundle *AakBundle) ReadAddonDescriptor(FileName string) (abaputils.AddonDescriptor, error) {
return abaputils.ReadAddonDescriptor(FileName)
}
func NewAakBundleWithTime(maxRuntime time.Duration, pollingInterval time.Duration) AakUtils {
utils := AakBundle{
Command: &command.Command{},
Client: &piperhttp.Client{},
maxRuntime: maxRuntime * time.Minute,
pollingInterval: pollingInterval * time.Second,
}
// Reroute command output to logging framework
utils.Stdout(log.Writer())
utils.Stderr(log.Writer())
return &utils
}
func NewAakBundle() AakUtils {
utils := AakBundle{
Command: &command.Command{},
Client: &piperhttp.Client{},
}
// Reroute command output to logging framework
utils.Stdout(log.Writer())
utils.Stderr(log.Writer())
return &utils
}