Skip to content

Commit 289a337

Browse files
committed
cli(cloudmap): use run to start the program
This commit uses the `run` function in the `run` command to start the program using Cloud Map as service registry. Signed-off-by: Elis Lulja <elulja@cisco.com>
1 parent 8e12c93 commit 289a337

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

pkg/command/run/cloud_map.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func getRunCloudMapCommand(operatorOpts *Options) *cobra.Command {
6060
// -----------------------------
6161

6262
cmd := &cobra.Command{
63-
Use: "cloudmap [COMMAND] [OPTIONS]",
63+
Use: "cloudmap [OPTIONS]",
6464
Aliases: []string{"cm", "aws-cloud-map", "with-cloud-map"},
6565
Short: "Run the program with AWS Cloud Map",
6666
PreRunE: func(cmd *cobra.Command, args []string) error {
@@ -118,9 +118,9 @@ func getRunCloudMapCommand(operatorOpts *Options) *cobra.Command {
118118
return ""
119119
}(),
120120
"name of the Kubernetes config map containing settings.")
121-
cmd.Flags().StringVar(&credsOpts.path, "credentials-path", "",
121+
cmd.Flags().StringVar(&credsOpts.path, "cloud-map.credentials-path", "",
122122
"path to the credentials file.")
123-
cmd.Flags().StringVar(&credsOpts.k8s, "credentials-secret", func() string {
123+
cmd.Flags().StringVar(&credsOpts.k8s, "cloud-map.credentials-secret", func() string {
124124
if operatorOpts.RunningInK8s {
125125
return defaultCloudMapCredentialsSecretName
126126
}
@@ -179,6 +179,12 @@ func parseCloudMapCommand(flagOpts *fileOrK8sResource, cmOpts *CloudMapOptions,
179179
}
180180

181181
func runWithCloudMap(operatorOpts *Options, cmOpts *CloudMapOptions) error {
182+
// TODO: when #81 is solved an merged this will be replaced
183+
// with zerolog
184+
l := ctrl.Log.WithName("CloudMap")
185+
ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
186+
l.Info("starting...")
187+
182188
ctx, canc := context.WithTimeout(context.Background(), 15*time.Second)
183189
defer canc()
184190
const tempPath = "/tmp/cnwan-operator-aws-credentials"
@@ -196,15 +202,8 @@ func runWithCloudMap(operatorOpts *Options, cmOpts *CloudMapOptions) error {
196202
return fmt.Errorf("error while trying to load AWS configuration: %w", err)
197203
}
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-
204-
servreg := cloudmap.NewHandler(ctx, servicediscovery.NewFromConfig(cfg), l)
205-
206-
// TODO: use the handler (in next commits)
207-
_ = servreg
208-
209-
return nil
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
207+
servreg := cloudmap.NewHandler(context.Background(), servicediscovery.NewFromConfig(cfg), l)
208+
return run(servreg, operatorOpts)
210209
}

0 commit comments

Comments
 (0)