@@ -61,7 +61,7 @@ func getRunServiceDirectoryCommand(operatorOpts *Options) *cobra.Command {
6161 cmd := & cobra.Command {
6262 Use : "servicedirectory [COMMAND] [OPTIONS]" ,
6363 Aliases : []string {"sd" , "google-service-directory" , "with-service-directory" },
64- Short : "Run the program with Google Service Directory" ,
64+ Short : "Run the program with Google Service Directory. " ,
6565 PreRunE : func (cmd * cobra.Command , args []string ) error {
6666 if err := parseServiceDirectoryCommand (sdFileOpts , opts , operatorOpts , cmd ); err != nil {
6767 return fmt .Errorf ("error while parsing service directory options: %w" , err )
@@ -92,7 +92,7 @@ func getRunServiceDirectoryCommand(operatorOpts *Options) *cobra.Command {
9292 RunE : func (_ * cobra.Command , _ []string ) error {
9393 return runWithServiceDirectory (operatorOpts , opts )
9494 },
95- Example : "servicedirectory --project-id my-project-id default-region us-east1" ,
95+ Example : "servicedirectory --project-id my-project-id -- default-region us-east1" ,
9696 }
9797
9898 // -----------------------------
@@ -103,9 +103,9 @@ func getRunServiceDirectoryCommand(operatorOpts *Options) *cobra.Command {
103103 "region/location where to register resources. Write auto to try to get it automatically." )
104104 cmd .Flags ().StringVar (& opts .ProjectID , "project-id" , "" ,
105105 "Google Cloud project ID. Write auto to try to get it automatically." )
106- cmd .Flags ().StringVar (& sdFileOpts .path , "options-path" , "" ,
106+ cmd .Flags ().StringVar (& sdFileOpts .path , "service-directory. options-path" , "" ,
107107 "path to the file containing service directory options." )
108- cmd .Flags ().StringVar (& sdFileOpts .k8s , "options-configmap" , func () string {
108+ cmd .Flags ().StringVar (& sdFileOpts .k8s , "service-directory. options-configmap" , func () string {
109109 if operatorOpts .RunningInK8s {
110110 return defaultServiceDirectoryConfigMapName
111111 }
@@ -185,6 +185,12 @@ func parseServiceDirectoryCommand(flagOpts *fileOrK8sResource, sdOpts *ServiceDi
185185}
186186
187187func runWithServiceDirectory (operatorOpts * Options , sdOpts * ServiceDirectoryOptions ) error {
188+ // TODO: when #81 is solved an merged this will be replaced
189+ // with zerolog
190+ l := ctrl .Log .WithName ("ServiceDirectory" )
191+ ctrl .SetLogger (zap .New (zap .UseDevMode (true )))
192+ l .Info ("starting..." )
193+
188194 ctx , canc := context .WithTimeout (context .Background (), 15 * time .Second )
189195 defer canc ()
190196
@@ -196,21 +202,15 @@ func runWithServiceDirectory(operatorOpts *Options, sdOpts *ServiceDirectoryOpti
196202
197203 defer cli .Close ()
198204
199- // TODO: when #81 is solved an merged this will be replaced
200- // with zerolog
201- l := ctrl .Log .WithName ("ServiceDirectory" )
202- ctrl .SetLogger (zap .New (zap .UseDevMode (true )))
203-
205+ // TODO: the context should be given by the run function, or explicitly
206+ // provide a context for each call. This will be fixed with the new API.
204207 sr := & sd.Handler {
205208 ProjectID : sdOpts .ProjectID ,
206209 DefaultRegion : sdOpts .DefaultRegion ,
207210 Log : l ,
208- Context : ctx ,
211+ Context : context . Background () ,
209212 Client : cli ,
210213 }
211214
212- // TODO: use the handler (in next commits)
213- _ = sr
214-
215- return nil
215+ return run (sr , operatorOpts )
216216}
0 commit comments