Skip to content

Commit

Permalink
immich-go appears to retain/cache an API key
Browse files Browse the repository at this point in the history
Fixes #211
  • Loading branch information
simulot committed Apr 1, 2024
1 parent 6634a2a commit 159e381
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
24 changes: 14 additions & 10 deletions cmd/shared.go
Expand Up @@ -105,12 +105,14 @@ func (app *SharedFlags) Start(ctx context.Context) error {

// If the client isn't yet initialized
if app.Immich == nil {
conf, err := configuration.Read(app.ConfigurationFile)
confExist := err == nil
if confExist && app.Server == "" && app.Key == "" && app.API == "" {
app.Server = conf.ServerURL
app.Key = conf.APIKey
app.API = conf.APIURL
if app.Server == "" && app.API == "" && app.Key == "" {
conf, err := configuration.Read(app.ConfigurationFile)
confExist := err == nil
if confExist && app.Server == "" && app.Key == "" && app.API == "" {
app.Server = conf.ServerURL
app.Key = conf.APIKey
app.API = conf.APIURL
}
}

switch {
Expand All @@ -125,10 +127,12 @@ func (app *SharedFlags) Start(ctx context.Context) error {
}

// Connection details are saved into the configuration file
conf.ServerURL = app.Server
conf.APIKey = app.Key
conf.APIURL = app.API
err = conf.Write(app.ConfigurationFile)
conf := configuration.Configuration{
ServerURL: app.Server,
APIKey: app.Key,
APIURL: app.API,
}
err := conf.Write(app.ConfigurationFile)
if err != nil {
err = fmt.Errorf("can't write into the configuration file: %w", err)
joinedErr = errors.Join(joinedErr, err)
Expand Down
16 changes: 6 additions & 10 deletions docs/releases.md
@@ -1,17 +1,13 @@
# Release notes

## Release 0.13.1

### Improvement: [#195](https://github.com/simulot/immich-go/issues/195) Rethink the user interactions with the CLI application #195

#### Use Bubble Tea library to provide a modern TUI (Terminal User Interface)


### API KEY self provisioning
When the server and the API keys aren't given on the command line, immich-go ask the user if he wants to get a key from a server, and saves it the configuration file.
## Release 0.13.0

### Fix [#199](https://github.com/simulot/immich-go/issues/199)
### Fix [[#211](https://github.com/simulot/immich-go/issues/211)] immich-go appears to retain/cache an API key
Fix the logic for retaining the credential:

When given, the credentials are saved into the configuration file.
When not given, the credential are read from the configuration file if possible.

## Release 0.13.0

### Improvement: [#189](https://github.com/simulot/immich-go/issues/189) Use a configuration file to store server's address and its API key
Expand Down

0 comments on commit 159e381

Please sign in to comment.