Merge branch 'master' into 11454-wb-federated-search
[arvados.git] / services / keepstore / deprecated.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package main
6
7 import (
8         "flag"
9         "time"
10
11         "git.curoverse.com/arvados.git/sdk/go/arvados"
12 )
13
14 type deprecatedOptions struct {
15         flagSerializeIO     bool
16         flagReadonly        bool
17         neverDelete         bool
18         signatureTTLSeconds int
19 }
20
21 var deprecated = deprecatedOptions{
22         neverDelete:         !theConfig.EnableDelete,
23         signatureTTLSeconds: int(theConfig.BlobSignatureTTL.Duration() / time.Second),
24 }
25
26 func (depr *deprecatedOptions) beforeFlagParse(cfg *Config) {
27         flag.StringVar(&cfg.Listen, "listen", cfg.Listen, "see Listen configuration")
28         flag.IntVar(&cfg.MaxBuffers, "max-buffers", cfg.MaxBuffers, "see MaxBuffers configuration")
29         flag.IntVar(&cfg.MaxRequests, "max-requests", cfg.MaxRequests, "see MaxRequests configuration")
30         flag.BoolVar(&depr.neverDelete, "never-delete", depr.neverDelete, "see EnableDelete configuration")
31         flag.BoolVar(&cfg.RequireSignatures, "enforce-permissions", cfg.RequireSignatures, "see RequireSignatures configuration")
32         flag.StringVar(&cfg.BlobSigningKeyFile, "permission-key-file", cfg.BlobSigningKeyFile, "see BlobSigningKey`File` configuration")
33         flag.StringVar(&cfg.BlobSigningKeyFile, "blob-signing-key-file", cfg.BlobSigningKeyFile, "see BlobSigningKey`File` configuration")
34         flag.StringVar(&cfg.SystemAuthTokenFile, "data-manager-token-file", cfg.SystemAuthTokenFile, "see SystemAuthToken`File` configuration")
35         flag.IntVar(&depr.signatureTTLSeconds, "permission-ttl", depr.signatureTTLSeconds, "signature TTL in seconds; see BlobSignatureTTL configuration")
36         flag.IntVar(&depr.signatureTTLSeconds, "blob-signature-ttl", depr.signatureTTLSeconds, "signature TTL in seconds; see BlobSignatureTTL configuration")
37         flag.Var(&cfg.TrashLifetime, "trash-lifetime", "see TrashLifetime configuration")
38         flag.BoolVar(&depr.flagSerializeIO, "serialize", depr.flagSerializeIO, "serialize read and write operations on the following volumes.")
39         flag.BoolVar(&depr.flagReadonly, "readonly", depr.flagReadonly, "do not write, delete, or touch anything on the following volumes.")
40         flag.StringVar(&cfg.PIDFile, "pid", cfg.PIDFile, "see `PIDFile` configuration")
41         flag.Var(&cfg.TrashCheckInterval, "trash-check-interval", "see TrashCheckInterval configuration")
42 }
43
44 func (depr *deprecatedOptions) afterFlagParse(cfg *Config) {
45         cfg.BlobSignatureTTL = arvados.Duration(depr.signatureTTLSeconds) * arvados.Duration(time.Second)
46         cfg.EnableDelete = !depr.neverDelete
47 }