mirror of
https://github.com/kopia/kopia.git
synced 2026-01-21 21:07:51 -05:00
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
40 lines
889 B
Go
40 lines
889 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/kopia/kopia/internal/apiclient"
|
|
"github.com/kopia/kopia/internal/serverapi"
|
|
)
|
|
|
|
var (
|
|
serverStartUploadCommand = serverCommands.Command("upload", "Trigger upload for one or more sources")
|
|
)
|
|
|
|
func init() {
|
|
serverStartUploadCommand.Action(serverAction(runServerStartUpload))
|
|
}
|
|
|
|
func runServerStartUpload(ctx context.Context, cli *apiclient.KopiaAPIClient) error {
|
|
return triggerActionOnMatchingSources(ctx, cli, "sources/upload")
|
|
}
|
|
|
|
func triggerActionOnMatchingSources(ctx context.Context, cli *apiclient.KopiaAPIClient, path string) error {
|
|
var resp serverapi.MultipleSourceActionResponse
|
|
|
|
if err := cli.Post(ctx, path, &serverapi.Empty{}, &resp); err != nil {
|
|
return err
|
|
}
|
|
|
|
for src, resp := range resp.Sources {
|
|
if resp.Success {
|
|
fmt.Println("SUCCESS", src)
|
|
} else {
|
|
fmt.Println("FAILED", src)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|