Skip to content

Commit

Permalink
fix race condition in ocis wrapper
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Oct 11, 2023
1 parent 88d6edd commit b33dbba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion changelog/unreleased/bump-reva.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 12 additions & 5 deletions tests/ociswrapper/cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"fmt"

"ociswrapper/common"
ocis "ociswrapper/ocis"
ocisConfig "ociswrapper/ocis/config"
Expand All @@ -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)
}
},
}

Expand All @@ -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())
},
}

Expand All @@ -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)
}
}

0 comments on commit b33dbba

Please sign in to comment.