@@ -2,6 +2,12 @@ package gitreceive
22
33import (
44 "strings"
5+ "time"
6+ )
7+
8+ const (
9+ builderPodTick = 100
10+ objectStorageTick = 500
511)
612
713type Config struct {
@@ -11,15 +17,19 @@ type Config struct {
1117 RegistryHost string `envconfig:"DEIS_REGISTRY_SERVICE_HOST" required:"true"`
1218 RegistryPort string `envconfig:"DEIS_REGISTRY_SERVICE_PORT" required:"true"`
1319
14- GitHome string `envconfig:"GIT_HOME" required:"true"`
15- SSHConnection string `envconfig:"SSH_CONNECTION" required:"true"`
16- SSHOriginalCommand string `envconfig:"SSH_ORIGINAL_COMMAND" required:"true"`
17- Repository string `envconfig:"REPOSITORY" required:"true"`
18- Username string `envconfig:"USERNAME" required:"true"`
19- Fingerprint string `envconfig:"FINGERPRINT" required:"true"`
20- PodNamespace string `envconfig:"POD_NAMESPACE" required:"true"`
21- StorageRegion string `envconfig:"STORAGE_REGION" default:"us-east-1"`
22- Debug bool `envconfig:"DEBUG" default:"false"`
20+ GitHome string `envconfig:"GIT_HOME" required:"true"`
21+ SSHConnection string `envconfig:"SSH_CONNECTION" required:"true"`
22+ SSHOriginalCommand string `envconfig:"SSH_ORIGINAL_COMMAND" required:"true"`
23+ Repository string `envconfig:"REPOSITORY" required:"true"`
24+ Username string `envconfig:"USERNAME" required:"true"`
25+ Fingerprint string `envconfig:"FINGERPRINT" required:"true"`
26+ PodNamespace string `envconfig:"POD_NAMESPACE" required:"true"`
27+ StorageRegion string `envconfig:"STORAGE_REGION" default:"us-east-1"`
28+ Debug bool `envconfig:"DEBUG" default:"false"`
29+ BuilderPodTickDurationMSec int `envconfig:"BUILDER_POD_TICK_DURATION" default:"100"`
30+ BuilderPodWaitDurationMSec int `envconfig:"BUILDER_POD_WAIT_DURATION" default:"300000"` // 5 minutes
31+ ObjectStorageTickDurationMSec int `envconfing:"OBJECT_STORAGE_TICK_DURATION" default:"500"`
32+ ObjectStorageWaitDurationMSec int `envconfig:"OBJECT_STORAGE_WAIT_DURATION" default:"300000"` // 5 minutes
2333}
2434
2535func (c Config ) App () string {
@@ -29,3 +39,45 @@ func (c Config) App() string {
2939 }
3040 return c .Repository [0 :li ]
3141}
42+
43+ // BuilderPodTickDuration returns the size of the interval used to check for
44+ // the end of the execution of a Pod building an application
45+ func (c Config ) BuilderPodTickDuration () time.Duration {
46+ return time .Duration (time .Duration (c .BuilderPodTickDurationMSec ) * time .Millisecond )
47+ }
48+
49+ // BuilderPodWaitDuration returns the maximum time to wait for the end
50+ // of the execution of a Pod building an application
51+ func (c Config ) BuilderPodWaitDuration () time.Duration {
52+ return time .Duration (time .Duration (c .BuilderPodWaitDurationMSec ) * time .Millisecond )
53+ }
54+
55+ // ObjectStorageTickDuration returns the size of the interval used to check for
56+ // the end of an operation that involves the object storage
57+ func (c Config ) ObjectStorageTickDuration () time.Duration {
58+ return time .Duration (time .Duration (c .ObjectStorageTickDurationMSec ) * time .Millisecond )
59+ }
60+
61+ // ObjectStorageWaitDuration returns the maximum time to wait for the end of an
62+ // operation that involves the object storage
63+ func (c Config ) ObjectStorageWaitDuration () time.Duration {
64+ return time .Duration (time .Duration (c .ObjectStorageWaitDurationMSec ) * time .Millisecond )
65+ }
66+
67+ // CheckDurations checks if ticks for builder and object storage are not bigger
68+ // than the maximum duration. In case of this it will set the tick to the default
69+ func (c * Config ) CheckDurations () {
70+ if c .BuilderPodTickDurationMSec >= c .BuilderPodWaitDurationMSec {
71+ c .BuilderPodTickDurationMSec = builderPodTick
72+ }
73+ if c .BuilderPodTickDurationMSec < builderPodTick {
74+ c .BuilderPodTickDurationMSec = builderPodTick
75+ }
76+
77+ if c .ObjectStorageTickDurationMSec >= c .ObjectStorageWaitDurationMSec {
78+ c .ObjectStorageTickDurationMSec = objectStorageTick
79+ }
80+ if c .ObjectStorageTickDurationMSec < objectStorageTick {
81+ c .ObjectStorageTickDurationMSec = objectStorageTick
82+ }
83+ }
0 commit comments