-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement internal Juju secrets add, update, and remove functionality
This commit introduces several changes to the Juju client in the `internal/juju/client.go` file. It includes the implementation of methods for adding, updating, and removing secrets. Additionally, Furthermore, the commit includes changes to the `secret.go` file, introducing new types for managinng secrets. It also includes changes to the `interfaces.go` file, defining new interfaces for the Juju client API. Add secretURI to UpdateSecret Add secretURI to DeleteSecret Add AutoPrunt to UpdateSecret schema Add SecretId to ReadSecret func instead of name. Add lost Asserts. Add secretNotFoundError Extract mocks creation into separate suite. Introduce typedError(err) usage in ClientAPI funcs. Add renaming to UpdateSecret Use struct raather than pointer for Output structures. Introcue NewName in Update input struct. Use pointers in all places in structs where the parameter is not neccessary.
- Loading branch information
Showing
8 changed files
with
589 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// Licensed under the Apache License, Version 2.0, see LICENCE file for details. | ||
|
||
package juju | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
"go.uber.org/mock/gomock" | ||
) | ||
|
||
type JujuSuite struct { | ||
suite.Suite | ||
|
||
testModelName string | ||
|
||
mockConnection *MockConnection | ||
mockSharedClient *MockSharedClient | ||
} | ||
|
||
func (s *JujuSuite) setupMocks(t *testing.T) *gomock.Controller { | ||
s.testModelName = "test-secret-model" | ||
|
||
ctlr := gomock.NewController(t) | ||
|
||
s.mockConnection = NewMockConnection(ctlr) | ||
s.mockConnection.EXPECT().Close().Return(nil).AnyTimes() | ||
|
||
log := func(msg string, additionalFields ...map[string]interface{}) { | ||
s.T().Logf("logging from shared client %q, %+v", msg, additionalFields) | ||
} | ||
s.mockSharedClient = NewMockSharedClient(ctlr) | ||
s.mockSharedClient.EXPECT().Debugf(gomock.Any(), gomock.Any()).Do(log).AnyTimes() | ||
s.mockSharedClient.EXPECT().Errorf(gomock.Any(), gomock.Any()).Do(log).AnyTimes() | ||
s.mockSharedClient.EXPECT().Tracef(gomock.Any(), gomock.Any()).Do(log).AnyTimes() | ||
s.mockSharedClient.EXPECT().JujuLogger().Return(&jujuLoggerShim{}).AnyTimes() | ||
s.mockSharedClient.EXPECT().GetConnection(&s.testModelName).Return(s.mockConnection, nil).AnyTimes() | ||
|
||
return ctlr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.