From 444bebf7ce36257778606d85cdb7539f058cd9a8 Mon Sep 17 00:00:00 2001 From: Kerem Avci Date: Wed, 6 Feb 2019 23:48:09 +0300 Subject: [PATCH] Add support for disk limit and memory for push option Signed-off-by: Kerem Avci --- out/cloud_foundry.go | 11 ++++++++++- out/command.go | 2 ++ out/models.go | 6 +++++- out/outfakes/fake_paas.go | 12 ++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/out/cloud_foundry.go b/out/cloud_foundry.go index fc9d045..aed4ff2 100644 --- a/out/cloud_foundry.go +++ b/out/cloud_foundry.go @@ -10,7 +10,7 @@ import ( type PAAS interface { Login(api string, username string, password string, clientID string, clientSecret string, insecure bool) error Target(organization string, space string) error - PushApp(manifest string, path string, currentAppName string, vars map[string]interface{}, varsFiles []string, dockerUser string, showLogs bool, noStart bool) error + PushApp(manifest string, path string, currentAppName string, vars map[string]interface{}, varsFiles []string, dockerUser string, showLogs bool, noStart bool, diskLimit string, memory string) error } type CloudFoundry struct { @@ -50,6 +50,7 @@ func (cf *CloudFoundry) PushApp( dockerUser string, showLogs bool, noStart bool, + diskLimit string, memory string, ) error { args := []string{} @@ -77,6 +78,14 @@ func (cf *CloudFoundry) PushApp( args = append(args, "--docker-username", dockerUser) } + if diskLimit != "" { + args = append(args, "-k", diskLimit) + } + + if memory != "" { + args = append(args, "-m", memory) + } + if path != "" { stat, err := os.Stat(path) if err != nil { diff --git a/out/command.go b/out/command.go index 737197f..e1783df 100644 --- a/out/command.go +++ b/out/command.go @@ -58,6 +58,8 @@ func (command *Command) Run(request Request) (Response, error) { request.Params.DockerUsername, request.Params.ShowAppLog, request.Params.NoStart, + request.Params.DiskLimit, + request.Params.Memory, ) if err != nil { return Response{}, err diff --git a/out/models.go b/out/models.go index aa09655..0721015 100644 --- a/out/models.go +++ b/out/models.go @@ -1,6 +1,8 @@ package out -import "github.com/concourse/cf-resource" +import ( + "github.com/concourse/cf-resource" +) type Request struct { Source resource.Source `json:"source"` @@ -18,6 +20,8 @@ type Params struct { DockerPassword string `json:"docker_password"` ShowAppLog bool `json:"show_app_log"` NoStart bool `json:"no_start"` + DiskLimit string `json:"disk_limit"` + Memory string `json:"memory"` } type Response struct { diff --git a/out/outfakes/fake_paas.go b/out/outfakes/fake_paas.go index 3e9e17e..a119926 100644 --- a/out/outfakes/fake_paas.go +++ b/out/outfakes/fake_paas.go @@ -36,7 +36,7 @@ type FakePAAS struct { targetReturnsOnCall map[int]struct { result1 error } - PushAppStub func(manifest string, path string, currentAppName string, vars map[string]interface{}, varsFiles []string, dockerUser string, showLogs bool, noStart bool) error + PushAppStub func(manifest string, path string, currentAppName string, vars map[string]interface{}, varsFiles []string, dockerUser string, showLogs bool, noStart bool, diskLimit string, memory string,) error pushAppMutex sync.RWMutex pushAppArgsForCall []struct { manifest string @@ -47,6 +47,8 @@ type FakePAAS struct { dockerUser string showLogs bool noStart bool + diskLimit string + memory string } pushAppReturns struct { result1 error @@ -160,7 +162,7 @@ func (fake *FakePAAS) TargetReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakePAAS) PushApp(manifest string, path string, currentAppName string, vars map[string]interface{}, varsFiles []string, dockerUser string, showLogs bool, noStart bool) error { +func (fake *FakePAAS) PushApp(manifest string, path string, currentAppName string, vars map[string]interface{}, varsFiles []string, dockerUser string, showLogs bool, noStart bool, diskLimit string, memory string) error { var varsFilesCopy []string if varsFiles != nil { varsFilesCopy = make([]string, len(varsFiles)) @@ -177,11 +179,13 @@ func (fake *FakePAAS) PushApp(manifest string, path string, currentAppName strin dockerUser string showLogs bool noStart bool - }{manifest, path, currentAppName, vars, varsFilesCopy, dockerUser, showLogs, noStart}) + diskLimit string + memory string + }{manifest, path, currentAppName, vars, varsFilesCopy, dockerUser, showLogs, noStart, diskLimit,memory}) fake.recordInvocation("PushApp", []interface{}{manifest, path, currentAppName, vars, varsFilesCopy, dockerUser, showLogs, noStart}) fake.pushAppMutex.Unlock() if fake.PushAppStub != nil { - return fake.PushAppStub(manifest, path, currentAppName, vars, varsFiles, dockerUser, showLogs, noStart) + return fake.PushAppStub(manifest, path, currentAppName, vars, varsFiles, dockerUser, showLogs, noStart, diskLimit, memory) } if specificReturn { return ret.result1