Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to support usage in serverless backend development #1303

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Show credentials path when --credentials requested
  • Loading branch information
joshuaauerbachwatson committed Nov 11, 2022
commit 203c8dd3df673752becf3f0d9657953acdcb660e
3 changes: 2 additions & 1 deletion commands/serverless.go
Original file line number Diff line number Diff line change
@@ -381,8 +381,9 @@ func RunServerlessStatus(c *CmdConfig) error {
Auth string `json:auth`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshuaauerbachwatson can we also include the path to the credentials here ? It would be very useful when running the deployer tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddebarros I have added the path to the credentials output. To do this cleanly I added to the ServerlessService which in turn required regenerating the mocks. This led me to thinking whether we should expand unit tests to cover these paths, so I may do that also before requesting review again.

APIHost string `json:apihost`
Namespace string `json:namespace`
Path string `json:path`
}
toShow := showCreds{Auth: auth, APIHost: creds.APIHost, Namespace: creds.Namespace}
toShow := showCreds{Auth: auth, APIHost: creds.APIHost, Namespace: creds.Namespace, Path: sls.CredentialsPath()}
credsOutput, err := json.MarshalIndent(toShow, "", " ")
if err != nil {
return err
14 changes: 14 additions & 0 deletions do/mocks/ServerlessService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions do/serverless.go
Original file line number Diff line number Diff line change
@@ -222,6 +222,7 @@ type ServerlessService interface {
ReadProject(*ServerlessProject, []string) (ServerlessOutput, error)
WriteProject(ServerlessProject) (string, error)
SetEffectiveCredentials(auth string, apihost string)
CredentialsPath() string
}

type serverlessService struct {
@@ -1213,6 +1214,11 @@ func (s *serverlessService) WriteCredentials(creds ServerlessCredentials) error
return os.WriteFile(credsPath, bytes, 0600)
}

// CredentialsPath simply returns the directory path where credentials are stored
func (s *serverlessService) CredentialsPath() string {
return s.credsDir
}

// ReadCredentials reads the current serverless credentials from the appropriate 'creds' diretory
func (s *serverlessService) ReadCredentials() (ServerlessCredentials, error) {
creds := ServerlessCredentials{}