Skip to content

Commit

Permalink
Set ServerInfo in repository/client.go
Browse files Browse the repository at this point in the history
  • Loading branch information
bathina2 committed May 6, 2024
1 parent 579ce31 commit 4e28125
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
37 changes: 19 additions & 18 deletions pkg/kopia/command/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,24 @@ func (s *RepositoryUtilsSuite) TestRepositoryConnectUtil(c *check.C) {
}

func (s *RepositoryUtilsSuite) TestRepositoryConnectServerUtil(c *check.C) {

cmd := RepositoryConnectServerCommand(RepositoryServerCommandArgs{
UserPassword: "testpass123",
ConfigFilePath: "/tmp/config.file",
LogDirectory: "/tmp/log.dir",
CacheDirectory: "/tmp/cache.dir",
Hostname: "test-hostname",
Username: "test-username",
ServerURL: "https://127.0.0.1:51515",
Fingerprint: "test-fingerprint",
ReadOnly: true,
CacheArgs: CacheArgs{
ContentCacheLimitMB: 0,
MetadataCacheLimitMB: 0,
},
})
c.Assert(cmd, check.DeepEquals, []string{"kopia",
cmd := func() []string {
return RepositoryConnectServerCommand(RepositoryServerCommandArgs{
UserPassword: "testpass123",
ConfigFilePath: "/tmp/config.file",
LogDirectory: "/tmp/log.dir",
CacheDirectory: "/tmp/cache.dir",
Hostname: "test-hostname",
Username: "test-username",
ServerURL: "https://127.0.0.1:51515",
Fingerprint: "test-fingerprint",
ReadOnly: true,
CacheArgs: CacheArgs{
ContentCacheLimitMB: 0,
MetadataCacheLimitMB: 0,
},
})
}
c.Assert(cmd(), check.DeepEquals, []string{"kopia",
"--log-level=error",
"--config-file=/tmp/config.file",
"--log-dir=/tmp/log.dir",
Expand All @@ -318,7 +319,7 @@ func (s *RepositoryUtilsSuite) TestRepositoryConnectServerUtil(c *check.C) {
defer cliArgs.UnRegisterKopiaRepositoryConnectServerArgs("--testflag")

// ensure they are set
c.Assert(cmd, check.DeepEquals, []string{"kopia",
c.Assert(cmd(), check.DeepEquals, []string{"kopia",
"--log-level=error",
"--config-file=/tmp/config.file",
"--log-dir=/tmp/log.dir",
Expand Down
12 changes: 6 additions & 6 deletions pkg/kopia/repository/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/pkg/errors"

"github.com/kanisterio/kanister/pkg/kopia"
cliArgs "github.com/kanisterio/kanister/pkg/kopia/cli/args"
"github.com/kanisterio/kanister/pkg/log"
"github.com/kanisterio/kanister/pkg/poll"
)
Expand Down Expand Up @@ -58,12 +59,11 @@ func ConnectToAPIServer(
TrustedServerCertificateFingerprint: fingerprint,
}

// TODO(@sirish): Uncomment the following code once APIServerInfo is extended (kopia 0.8 release)
// for k, v := range cliArgs.ExtraKopiaRepositoryConnectServerArgs() {
// if k == "--local-cache-key-derivation-algorithm" {
// serverInfo.LocalCahceKeyDerivationAlgorithm = v
// }
// }
for k, v := range cliArgs.ExtraKopiaRepositoryConnectServerArgs() {
if k == "--local-cache-key-derivation-algorithm" {
serverInfo.LocalCacheKeyDerivationAlgorithm = v
}
}

opts := &repo.ConnectOptions{
CachingOptions: content.CachingOptions{
Expand Down

0 comments on commit 4e28125

Please sign in to comment.