@@ -16,6 +16,7 @@ package main
1616import (
1717 "bytes"
1818 "context"
19+ "crypto/tls"
1920 "encoding/json"
2021 "flag"
2122 "fmt"
8687 noProxy = flag .String (noProxyArg , unsetProxyArgValue , "Addresses that should ignore the proxy." )
8788 publishLogs = flag .String ("publish_logs" , "true" , "Whether to publish component logs to the object store" )
8889 cacheDisabledFlag = flag .Bool ("cache_disabled" , false , "Disable cache globally." )
89-
90- caCertPath = flag .String ("ca_cert_path" , "" , "The path to the CA certificate to trust on connections to the ML pipeline API server and metadata server." )
90+ //todo: retrieve exact wording
91+ mlPipelineServiceTLSEnabled = flag .Bool ("ml_pipeline_tls_enabled" , false , "add wording here" )
92+ metadataTLSEnabled = flag .Bool ("metadata_tls_enabled" , false , " add wording" )
93+ caCertPath = flag .String ("ca_cert_path" , "" , "The path to the CA certificate to trust on connections to the ML pipeline API server and metadata server." )
9194)
9295
9396// func RootDAG(pipelineName string, runID string, component *pipelinespec.ComponentSpec, task *pipelinespec.PipelineTaskSpec, mlmd *metadata.Client) (*Execution, error) {
@@ -177,11 +180,14 @@ func drive() (err error) {
177180 if err != nil {
178181 return err
179182 }
180- client , err := newMlmdClient ()
181- if err != nil {
182- return err
183+ var tlsCfg * tls.Config
184+ if * metadataTLSEnabled {
185+ tlsCfg , err = util .GetTLSConfig (* caCertPath )
186+ if err != nil {
187+ return err
188+ }
183189 }
184- tlsCfg , err := util . GetTLSConfig ( * caCertPath )
190+ client , err := newMlmdClient ( tlsCfg )
185191 if err != nil {
186192 return err
187193 }
@@ -190,23 +196,25 @@ func drive() (err error) {
190196 return err
191197 }
192198 options := driver.Options {
193- PipelineName : * pipelineName ,
194- RunID : * runID ,
195- RunName : * runName ,
196- RunDisplayName : * runDisplayName ,
197- Namespace : namespace ,
198- Component : componentSpec ,
199- Task : taskSpec ,
200- DAGExecutionID : * dagExecutionID ,
201- IterationIndex : * iterationIndex ,
202- PipelineLogLevel : * logLevel ,
203- PublishLogs : * publishLogs ,
204- CacheDisabled : * cacheDisabledFlag ,
205- DriverType : * driverType ,
206- TaskName : * taskName ,
207- MLMDServerAddress : * mlmdServerAddress ,
208- MLMDServerPort : * mlmdServerPort ,
209- CaCertPath : * caCertPath ,
199+ PipelineName : * pipelineName ,
200+ RunID : * runID ,
201+ RunName : * runName ,
202+ RunDisplayName : * runDisplayName ,
203+ Namespace : namespace ,
204+ Component : componentSpec ,
205+ Task : taskSpec ,
206+ DAGExecutionID : * dagExecutionID ,
207+ IterationIndex : * iterationIndex ,
208+ PipelineLogLevel : * logLevel ,
209+ PublishLogs : * publishLogs ,
210+ CacheDisabled : * cacheDisabledFlag ,
211+ DriverType : * driverType ,
212+ TaskName : * taskName ,
213+ MLMDServerAddress : * mlmdServerAddress ,
214+ MLMDServerPort : * mlmdServerPort ,
215+ MLPipelineTLSEnabled : * mlPipelineServiceTLSEnabled ,
216+ MLMDTLSEnabled : * metadataTLSEnabled ,
217+ CaCertPath : * caCertPath ,
210218 }
211219 var execution * driver.Execution
212220 var driverErr error
@@ -339,15 +347,11 @@ func writeFile(path string, data []byte) (err error) {
339347 return os .WriteFile (path , data , 0o644 )
340348}
341349
342- func newMlmdClient () (* metadata.Client , error ) {
350+ func newMlmdClient (tlsCfg * tls. Config ) (* metadata.Client , error ) {
343351 mlmdConfig := metadata .DefaultConfig ()
344352 if * mlmdServerAddress != "" && * mlmdServerPort != "" {
345353 mlmdConfig .Address = * mlmdServerAddress
346354 mlmdConfig .Port = * mlmdServerPort
347355 }
348- tlsConfig , err := util .GetTLSConfig (* caCertPath )
349- if err != nil {
350- return nil , err
351- }
352- return metadata .NewClient (mlmdConfig .Address , mlmdConfig .Port , tlsConfig )
356+ return metadata .NewClient (mlmdConfig .Address , mlmdConfig .Port , tlsCfg )
353357}
0 commit comments