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