Skip to content

Commit

Permalink
fix: Don't write eKuiper file if file doesn't already exist
Browse files Browse the repository at this point in the history
fixes edgexfoundry#3786

Signed-off-by: lenny <[email protected]>
  • Loading branch information
lenny committed Oct 27, 2021
1 parent 75c4221 commit 18365c5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/security/secretstore/secure-messagebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package secretstore

import (
"errors"
"fmt"
"os"
"text/template"
Expand Down Expand Up @@ -101,6 +102,14 @@ func ConfigureSecureMessageBus(secureMessageBus config.SecureMessageBusInfo, red
}

func configureKuiperForSecureMessageBus(credentials UserPasswordPair, fileType string, fileTemplate string, path string, lc logger.LoggingClient) error {
// This capability depends on the eKuiper file existing, which depends on the version of eKuiper installed.
// If the file doesn't exist, then the eKuiper version installed doesn't use it, so skip the injection.
_, err := os.Stat(path)
if err != nil && errors.Is(err, os.ErrNotExist) {
lc.Infof("eKuiper file %s doesn't exist, skipping Secure MessageBus credentials injection", path)
return nil
}

tmpl, err := template.New("eKuiper").Parse(fileTemplate)
if err != nil {
return fmt.Errorf("failed to parse eKuiper %s template: %w", fileType, err)
Expand Down

0 comments on commit 18365c5

Please sign in to comment.