Skip to content

Commit

Permalink
Added steps to clean up temp files created
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranjith Gopal committed May 27, 2024
1 parent 01f10d5 commit 891adb9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/scalers/cassandra_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,23 @@ func (s *cassandraScaler) GetQueryResult(ctx context.Context) (int64, error) {

// Close closes the Cassandra session connection.
func (s *cassandraScaler) Close(_ context.Context) error {
// clean up any temporary files
if strings.TrimSpace(s.metadata.cert) != "" {
if err := os.Remove(s.metadata.cert); err != nil {
return err
}
}
if strings.TrimSpace(s.metadata.key) != "" {
if err := os.Remove(s.metadata.key); err != nil {
return err
}
}
if strings.TrimSpace(s.metadata.ca) != "" {
if err := os.Remove(s.metadata.ca); err != nil {
return err
}
}

if s.session != nil {
s.session.Close()
}
Expand Down

0 comments on commit 891adb9

Please sign in to comment.