2021-12-09 13:54:18 +02:00
|
|
|
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"
|
2022-08-09 10:57:02 +02:00
|
|
|
"github.com/SAP/jenkins-library/pkg/piperutils"
|
2021-12-09 13:54:18 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type AakUtils interface {
|
|
|
|
command.ExecRunner
|
|
|
|
abapbuild.HTTPSendLoader
|
2022-08-09 10:57:02 +02:00
|
|
|
piperutils.FileUtils
|
2021-12-09 13:54:18 +02:00
|
|
|
ReadAddonDescriptor(FileName string) (abaputils.AddonDescriptor, error)
|
|
|
|
GetMaxRuntime() time.Duration
|
|
|
|
GetPollingInterval() time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
type AakBundle struct {
|
|
|
|
*command.Command
|
|
|
|
*piperhttp.Client
|
2022-08-09 10:57:02 +02:00
|
|
|
*piperutils.Files
|
2021-12-09 13:54:18 +02:00
|
|
|
maxRuntime time.Duration
|
|
|
|
pollingInterval time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bundle *AakBundle) GetMaxRuntime() time.Duration {
|
|
|
|
return bundle.maxRuntime
|
|
|
|
}
|
2022-08-09 18:02:57 +02:00
|
|
|
|
2021-12-09 13:54:18 +02:00
|
|
|
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{},
|
2022-08-09 18:02:57 +02:00
|
|
|
Files: &piperutils.Files{},
|
2021-12-09 13:54:18 +02:00
|
|
|
}
|
|
|
|
// Reroute command output to logging framework
|
|
|
|
utils.Stdout(log.Writer())
|
|
|
|
utils.Stderr(log.Writer())
|
|
|
|
return &utils
|
|
|
|
}
|