mirror of https://github.com/harness/drone.git
[Config] Ensure time related config elements are of type `time.Duration` (#813)
parent
00a69152d7
commit
07a088bb8c
|
@ -14,6 +14,8 @@
|
|||
|
||||
package blob
|
||||
|
||||
import "time"
|
||||
|
||||
type Provider string
|
||||
|
||||
const (
|
||||
|
@ -26,5 +28,5 @@ type Config struct {
|
|||
Bucket string
|
||||
KeyPath string
|
||||
TargetPrincipal string
|
||||
ImpersonationLifetime int
|
||||
ImpersonationLifetime time.Duration
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func NewGCSStore(cfg Config) (Store, error) {
|
|||
ts, err := impersonate.CredentialsTokenSource(context.Background(), impersonate.CredentialsConfig{
|
||||
TargetPrincipal: cfg.TargetPrincipal,
|
||||
Scopes: []string{defaultScope}, // Required field
|
||||
Lifetime: time.Duration(cfg.ImpersonationLifetime) * time.Hour,
|
||||
Lifetime: cfg.ImpersonationLifetime,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to impersonate the client service account %s : %w", cfg.TargetPrincipal, err)
|
||||
|
|
|
@ -46,7 +46,7 @@ func ProvideLastCommitCache(
|
|||
redisClient redis.UniversalClient,
|
||||
repoProvider *GoGitRepoProvider,
|
||||
) cache.Cache[CommitEntryKey, *types.Commit] {
|
||||
cacheDuration := time.Duration(config.Git.LastCommitCache.DurationSeconds) * time.Second
|
||||
cacheDuration := config.Git.LastCommitCache.Duration
|
||||
|
||||
if config.Git.LastCommitCache.Mode == ModeNone || cacheDuration < time.Second {
|
||||
return NoLastCommitCache(repoProvider)
|
||||
|
|
|
@ -28,8 +28,8 @@ type LastCommitCache struct {
|
|||
// Mode determines where the cache will be. Valid values are "inmemory" (default), "redis" or "none".
|
||||
Mode string `envconfig:"GITNESS_GIT_LAST_COMMIT_CACHE_MODE" default:"inmemory"`
|
||||
|
||||
// DurationSeconds defines cache duration in seconds of last commit, default=12h.
|
||||
DurationSeconds int `envconfig:"GITNESS_GIT_LAST_COMMIT_CACHE_SECONDS" default:"43200"`
|
||||
// Duration defines cache duration of last commit.
|
||||
Duration time.Duration `envconfig:"GITNESS_GIT_LAST_COMMIT_CACHE_DURATION" default:"12h"`
|
||||
}
|
||||
|
||||
// Git defines the git configuration parameters.
|
||||
|
@ -159,7 +159,7 @@ type Config struct {
|
|||
// Email ID of the google service account that needs to be impersonated
|
||||
TargetPrincipal string `envconfig:"GITNESS_BLOBSTORE_TARGET_PRINCIPAL" default:""`
|
||||
|
||||
ImpersonationLifetime int `envconfig:"GITNESS_BLOBSTORE_IMPERSONATION_LIFETIME" default:"12"`
|
||||
ImpersonationLifetime time.Duration `envconfig:"GITNESS_BLOBSTORE_IMPERSONATION_LIFETIME" default:"12h"`
|
||||
}
|
||||
|
||||
// Token defines token configuration parameters.
|
||||
|
|
Loading…
Reference in New Issue