@@ -46,7 +46,8 @@ func Execute(ctx context.Context, version string) {
46
46
rootCmd .PersistentFlags ().BoolP ("verbose" , "v" , false , "verbose output" )
47
47
rootCmd .PersistentFlags ().BoolVarP (& input .noOutput , "quiet" , "q" , false , "disable logging of output from steps" )
48
48
rootCmd .PersistentFlags ().BoolVarP (& input .dryrun , "dryrun" , "n" , false , "dryrun mode" )
49
- rootCmd .PersistentFlags ().StringVarP (& input .envfile , "env-file" , "" , ".env" , "environment file to read" )
49
+ rootCmd .PersistentFlags ().StringVarP (& input .secretfile , "secret-file" , "" , "" , "file with list of secrets to read from" )
50
+ rootCmd .PersistentFlags ().StringVarP (& input .envfile , "env-file" , "" , ".env" , "environment file to read and use as env in the containers" )
50
51
rootCmd .SetArgs (args ())
51
52
52
53
if err := rootCmd .Execute (); err != nil {
@@ -92,16 +93,29 @@ func setupLogging(cmd *cobra.Command, args []string) {
92
93
}
93
94
}
94
95
96
+ func readEnvs (path string , envs map [string ]string ) bool {
97
+ if _ , err := os .Stat (path ); err == nil {
98
+ env , err := godotenv .Read (path )
99
+ if err != nil {
100
+ log .Fatalf ("Error loading from %s: %v" , path , err )
101
+ }
102
+ for k , v := range env {
103
+ envs [k ] = v
104
+ }
105
+ return true
106
+ }
107
+ return false
108
+ }
109
+
95
110
func newRunCommand (ctx context.Context , input * Input ) func (* cobra.Command , []string ) error {
96
111
return func (cmd * cobra.Command , args []string ) error {
97
- envfile := input .Envfile ()
98
- if _ , err := os .Stat (envfile ); err == nil {
99
- log .Debugf ("Loading environment from %s" , envfile )
100
- err := godotenv .Load (envfile )
101
- if err != nil {
102
- log .Fatalf ("Error loading environment from %s: %v" , envfile , err )
103
- }
104
- }
112
+ log .Debugf ("Loading environment from %s" , input .Envfile ())
113
+ envs := make (map [string ]string )
114
+ _ = readEnvs (input .Envfile (), envs )
115
+
116
+ log .Debugf ("Loading secrets from %s" , input .Secretfile ())
117
+ secrets := newSecrets (input .secrets )
118
+ _ = readEnvs (input .Secretfile (), secrets )
105
119
106
120
planner , err := model .NewWorkflowPlanner (input .WorkflowsPath ())
107
121
if err != nil {
@@ -149,7 +163,8 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
149
163
Workdir : input .Workdir (),
150
164
BindWorkdir : input .bindWorkdir ,
151
165
LogOutput : ! input .noOutput ,
152
- Secrets : newSecrets (input .secrets ),
166
+ Env : envs ,
167
+ Secrets : secrets ,
153
168
Platforms : input .newPlatforms (),
154
169
}
155
170
runner , err := runner .New (config )
0 commit comments