blob: 34b4f7ce85fb50078ad7d75014b4ca40df99be7f [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
import (
"time"
"github.com/maruel/subcommands"
"go.chromium.org/luci/auth"
"go.chromium.org/luci/auth/client/authcli"
)
const (
// The exit code emitted from an upload command when it fails due to a
// transient GCS error.
exitTransientError = 3
// The size in bytes at which files will be read and written to GCS.
chunkSize = 100 * 1024 * 1024
// A list of the objects that need their TTL refreshed.
objsToRefreshTTLTxt = "objs_to_refresh_ttl.txt"
// The number of days since the CustomTime of an object after which the
// TTL should be refreshed. This is an arbitrary value chosen to avoid
// refreshing the TTL of frequently deduplicated objects repeatedly over
// a short time period.
daysSinceCustomTime = 10
// Timeout for every file upload.
perFileUploadTimeout = 8 * time.Minute
// Metadata keys.
googleReservedFileMtime = "goog-reserved-file-mtime"
)
type commonFlags struct {
subcommands.CommandRunBase
authFlags authcli.Flags
parsedAuthOpts auth.Options
}
func (c *commonFlags) Init(authOpts auth.Options) {
c.authFlags = authcli.Flags{}
c.authFlags.Register(&c.Flags, authOpts)
}
func (c *commonFlags) Parse() error {
var err error
c.parsedAuthOpts, err = c.authFlags.Options()
if err != nil {
return err
}
return nil
}