@@ -158,7 +158,7 @@ func WriteOutput(w io.Writer, client *c8y.Client, cfg *config.Config, session *C
158158
159159 shell , isShell := utilities .ShellType .Parse (utilities .ShellBash , format )
160160 if isShell {
161- output := GetVariablesFromSession (session , client , cfg .AlwaysIncludePassword ())
161+ output := GetVariablesFromSession (session , cfg , client , cfg .AlwaysIncludePassword ())
162162 utilities .WriteShellVariables (w , output , shell )
163163 return nil
164164 }
@@ -175,7 +175,7 @@ func WriteOutput(w io.Writer, client *c8y.Client, cfg *config.Config, session *C
175175 }
176176 fmt .Fprintf (w , "%s\n " , out )
177177 case "env" , "dotenv" :
178- output := GetVariablesFromSession (session , client , cfg .AlwaysIncludePassword ())
178+ output := GetVariablesFromSession (session , cfg , client , cfg .AlwaysIncludePassword ())
179179 for k , v := range output {
180180 if v != "" {
181181 fmt .Fprintf (w , "%s=%s\n " , k , v )
@@ -188,7 +188,7 @@ func WriteOutput(w io.Writer, client *c8y.Client, cfg *config.Config, session *C
188188}
189189
190190// GetVariablesFromSession gets all the environment variables associated with the current session
191- func GetVariablesFromSession (session * CumulocitySession , client * c8y.Client , setPassword bool ) map [string ]interface {} {
191+ func GetVariablesFromSession (session * CumulocitySession , cfg * config. Config , client * c8y.Client , setPassword bool ) map [string ]interface {} {
192192 host := session .Host
193193 domain := session .GetDomain ()
194194 tenant := session .Tenant
@@ -227,6 +227,17 @@ func GetVariablesFromSession(session *CumulocitySession, client *c8y.Client, set
227227 "C8Y_SETTINGS_LOGIN_TYPE" : loginType ,
228228 }
229229
230+ cache := cfg .CachePassphraseVariables ()
231+ cfg .Logger .Debugf ("Cache passphrase: %v" , cache )
232+ if cache {
233+ if cfg .Passphrase != "" {
234+ output [config .EnvPassphrase ] = cfg .Passphrase
235+ }
236+ if cfg .SecretText != "" {
237+ output [config .EnvPassphraseText ] = cfg .SecretText
238+ }
239+ }
240+
230241 if loginType != c8y .AuthMethodOAuth2Internal {
231242 output ["C8Y_TOKEN" ] = ""
232243 }
@@ -240,13 +251,8 @@ func GetVariablesFromSession(session *CumulocitySession, client *c8y.Client, set
240251 return output
241252}
242253
243- func ShowClientEnvironmentVariables (cfg * config.Config , c8yclient * c8y.Client , shell utilities.ShellType ) {
244- output := cfg .GetEnvironmentVariables (c8yclient , cfg .AlwaysIncludePassword ())
245- utilities .WriteShellVariables (os .Stdout , output , shell )
246- }
247-
248254func ShowSessionEnvironmentVariables (session * CumulocitySession , cfg * config.Config , c8yclient * c8y.Client , shell utilities.ShellType ) {
249- output := GetVariablesFromSession (session , c8yclient , cfg .AlwaysIncludePassword ())
255+ output := GetVariablesFromSession (session , cfg , c8yclient , cfg .AlwaysIncludePassword ())
250256 utilities .WriteShellVariables (os .Stdout , output , shell )
251257}
252258
0 commit comments