From b33dbba5253ebcda77f129f34a06933de8c92189 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 11 Oct 2023 11:55:24 +0200 Subject: [PATCH] fix race condition in ocis wrapper Signed-off-by: jkoberg --- changelog/unreleased/bump-reva.md | 1 - tests/ociswrapper/cmd/cmd.go | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/changelog/unreleased/bump-reva.md b/changelog/unreleased/bump-reva.md index d7fe68be6..5751ff4e1 100644 --- a/changelog/unreleased/bump-reva.md +++ b/changelog/unreleased/bump-reva.md @@ -7,4 +7,3 @@ https://github.com/owncloud/ocis/pull/6427 https://github.com/owncloud/ocis/pull/7178 https://github.com/owncloud/ocis/pull/7217 https://github.com/owncloud/ocis/pull/7410 -https://github.com/owncloud/ocis/pull/7460 diff --git a/tests/ociswrapper/cmd/cmd.go b/tests/ociswrapper/cmd/cmd.go index 66fc1d6c7..cb060c2fb 100644 --- a/tests/ociswrapper/cmd/cmd.go +++ b/tests/ociswrapper/cmd/cmd.go @@ -1,6 +1,8 @@ package cmd import ( + "fmt" + "ociswrapper/common" ocis "ociswrapper/ocis" ocisConfig "ociswrapper/ocis/config" @@ -14,7 +16,9 @@ var rootCmd = &cobra.Command{ Use: "ociswrapper", Short: "ociswrapper is a wrapper for oCIS server", Run: func(cmd *cobra.Command, args []string) { - cmd.Help() + if err := cmd.Help(); err != nil { + fmt.Printf("error executing help command: %v\n", err) + } }, } @@ -25,15 +29,15 @@ func serveCmd() *cobra.Command { Run: func(cmd *cobra.Command, args []string) { common.Wg.Add(2) - go ocis.Start(nil) - go wrapper.Start(cmd.Flag("port").Value.String()) - // set configs ocisConfig.Set("bin", cmd.Flag("bin").Value.String()) ocisConfig.Set("url", cmd.Flag("url").Value.String()) ocisConfig.Set("retry", cmd.Flag("retry").Value.String()) ocisConfig.Set("adminUsername", cmd.Flag("admin-username").Value.String()) ocisConfig.Set("adminPassword", cmd.Flag("admin-password").Value.String()) + + go ocis.Start(nil) + go wrapper.Start(cmd.Flag("port").Value.String()) }, } @@ -49,9 +53,12 @@ func serveCmd() *cobra.Command { return serveCmd } +// Execute executes the command func Execute() { rootCmd.CompletionOptions.DisableDefaultCmd = true rootCmd.AddCommand(serveCmd()) - rootCmd.Execute() + if err := rootCmd.Execute(); err != nil { + fmt.Printf("error executing command: %v\n", err) + } }