Files
kopia/repo/api_server_repository.go
Jarek Kowalski b60cac4860 fix(cli): fixed v0.18.0 failures using v0.17.0-generated config (#4255)
This was caused by the client using key derivation algorithm
from a config file (which did not have it when it was generated
using old version of Kopia).

Fixes #4254
2024-11-17 10:15:00 -08:00

38 lines
1.2 KiB
Go

package repo
import (
"context"
"github.com/pkg/errors"
)
// APIServerInfo is remote repository configuration stored in local configuration.
//
// NOTE: this structure is persistent on disk may be read/written using
// different versions of Kopia, so it must be backwards-compatible.
//
// Apply appropriate defaults when reading.
type APIServerInfo struct {
BaseURL string `json:"url"`
TrustedServerCertificateFingerprint string `json:"serverCertFingerprint"`
LocalCacheKeyDerivationAlgorithm string `json:"localCacheKeyDerivationAlgorithm,omitempty"`
}
// ConnectAPIServer sets up repository connection to a particular API server.
func ConnectAPIServer(ctx context.Context, configFile string, si *APIServerInfo, password string, opt *ConnectOptions) error {
lc := LocalConfig{
APIServer: si,
ClientOptions: opt.ClientOptions.ApplyDefaults(ctx, "API Server: "+si.BaseURL),
}
if err := setupCachingOptionsWithDefaults(ctx, configFile, &lc, &opt.CachingOptions, []byte(si.BaseURL)); err != nil {
return errors.Wrap(err, "unable to set up caching")
}
if err := lc.writeToFile(configFile); err != nil {
return errors.Wrap(err, "unable to write config file")
}
return verifyConnect(ctx, configFile, password)
}