@@ -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 }
@@ -184,6 +184,12 @@ func parseServiceDirectoryCommand(flagOpts *fileOrK8sResource, sdOpts *ServiceDi
184184}
185185
186186func runWithServiceDirectory (operatorOpts * Options , sdOpts * ServiceDirectoryOptions ) error {
187+ // TODO: when #81 is solved an merged this will be replaced
188+ // with zerolog
189+ l := ctrl .Log .WithName ("ServiceDirectory" )
190+ ctrl .SetLogger (zap .New (zap .UseDevMode (true )))
191+ l .Info ("starting..." )
192+
187193 ctx , canc := context .WithTimeout (context .Background (), 15 * time .Second )
188194 defer canc ()
189195
@@ -195,21 +201,15 @@ func runWithServiceDirectory(operatorOpts *Options, sdOpts *ServiceDirectoryOpti
195201
196202 defer cli .Close ()
197203
198- // TODO: when #81 is solved an merged this will be replaced
199- // with zerolog
200- l := ctrl .Log .WithName ("ServiceDirectory" )
201- ctrl .SetLogger (zap .New (zap .UseDevMode (true )))
202-
204+ // TODO: the context should be given by the run function, or explicitly
205+ // provide a context for each call. This will be fixed with the new API.
203206 sr := & sd.Handler {
204207 ProjectID : sdOpts .ProjectID ,
205208 DefaultRegion : sdOpts .DefaultRegion ,
206209 Log : l ,
207- Context : ctx ,
210+ Context : context . Background () ,
208211 Client : cli ,
209212 }
210213
211- // TODO: use the handler (in next commits)
212- _ = sr
213-
214- return nil
214+ return run (sr , operatorOpts )
215215}
0 commit comments