Files
kopia/cli/command_repository_connect_server.go
Jarek Kowalski be4b897579 Support for remote repository (#427)
Support for remote content repository where all contents and
manifests are fetched over HTTP(S) instead of locally
manipulating blob storage

* server: implement content and manifest access APIs
* apiclient: moved Kopia API client to separate package
* content: exposed content.ValidatePrefix()
* manifest: added JSON serialization attributes to EntryMetadata
* repo: changed repo.Open() to return Repository instead of *DirectRepository
* repo: added apiServerRepository
* cli: added 'kopia repository connect server'
  This sets up repository connection via the API server instead of
  directly-manipulated storage.
* server: add support for specifying a list of usernames/password via --htpasswd-file
* tests: added API server repository E2E test
* server: only return manifests (policies and snapshots) belonging to authenticated user
2020-05-02 21:41:49 -07:00

43 lines
1.1 KiB
Go

package cli
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/repo"
)
var (
connectAPIServerCommand = connectCommand.Command("server", "Connect to a repository API Server.")
connectAPIServerURL = connectAPIServerCommand.Flag("url", "Server URL").Required().String()
connectAPIServerCertFingerprint = connectAPIServerCommand.Flag("server-cert-fingerprint", "Server certificate fingerprint").String()
)
func runConnectAPIServerCommand(ctx context.Context) error {
password, err := getPasswordFromFlags(ctx, false, false)
if err != nil {
return errors.Wrap(err, "getting password")
}
as := &repo.APIServerInfo{
BaseURL: *connectAPIServerURL,
TrustedServerCertificateFingerprint: *connectAPIServerCertFingerprint,
}
configFile := repositoryConfigFileName()
if err := repo.ConnectAPIServer(ctx, configFile, as, password, connectOptions()); err != nil {
return err
}
printStderr("Connected to repository API Server.\n")
maybeInitializeUpdateCheck(ctx)
return nil
}
func init() {
connectAPIServerCommand.Action(noRepositoryAction(runConnectAPIServerCommand))
}