@@ -49,7 +49,7 @@ func Exec(ctx context.Context, args Args) error {
4949 }
5050 logrus .Infof ("credentials file written to %s\n " , credsPath )
5151
52- if err := WriteEnvToFile ("GOOGLE_APPLICATION_CREDENTIALS" , credsPath ); err != nil {
52+ if err := WriteOutputToFile ("GOOGLE_APPLICATION_CREDENTIALS" , credsPath ); err != nil {
5353 return err
5454 }
5555
@@ -68,7 +68,7 @@ func Exec(ctx context.Context, args Args) error {
6868
6969 logrus .Infof ("access token retrieved successfully\n " )
7070
71- if err := WriteEnvToFile ("GCLOUD_ACCESS_TOKEN" , accessToken ); err != nil {
71+ if err := WriteSecretOutputToFile ("GCLOUD_ACCESS_TOKEN" , accessToken ); err != nil {
7272 return err
7373 }
7474
@@ -98,7 +98,23 @@ func VerifyEnv(args Args) error {
9898 return nil
9999}
100100
101- func WriteEnvToFile (key , value string ) error {
101+ func WriteOutputToFile (key , value string ) error {
102+ outputFile , err := os .OpenFile (os .Getenv ("DRONE_OUTPUT" ), os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0644 )
103+ if err != nil {
104+ return fmt .Errorf ("failed to open output file: %w" , err )
105+ }
106+
107+ defer outputFile .Close ()
108+
109+ _ , err = fmt .Fprintf (outputFile , "%s=%s\n " , key , value )
110+ if err != nil {
111+ return fmt .Errorf ("failed to write to env: %w" , err )
112+ }
113+
114+ return nil
115+ }
116+
117+ func WriteSecretOutputToFile (key , value string ) error {
102118 outputFile , err := os .OpenFile (os .Getenv ("HARNESS_OUTPUT_SECRET_FILE" ), os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0644 )
103119 if err != nil {
104120 return fmt .Errorf ("failed to open output file: %w" , err )
0 commit comments