Skip to content

Commit

Permalink
Merge pull request #3642 from wkloucek/fix-config-parsing-unsupervised
Browse files Browse the repository at this point in the history
fix ocis config parsing for subcommands
  • Loading branch information
wkloucek authored May 2, 2022
2 parents 6936a23 + 18e9661 commit 0bb8300
Show file tree
Hide file tree
Showing 29 changed files with 223 additions and 71 deletions.
9 changes: 5 additions & 4 deletions ocis/pkg/command/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func AccountsCommand(cfg *config.Config) *cli.Command {
Name: cfg.Accounts.Service.Name,
Usage: subcommandDescription(cfg.Accounts.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.Accounts.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Accounts),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func AuditCommand(cfg *config.Config) *cli.Command {
Name: "audit",
Usage: "start audit service",
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.Audit.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Audit),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/glauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func GLAuthCommand(cfg *config.Config) *cli.Command {
Name: cfg.GLAuth.Service.Name,
Usage: subcommandDescription(cfg.GLAuth.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.GLAuth.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.GLAuth),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func GraphCommand(cfg *config.Config) *cli.Command {
Name: cfg.Graph.Service.Name,
Usage: subcommandDescription(cfg.Graph.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.Graph.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Graph),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/graphexplorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func GraphExplorerCommand(cfg *config.Config) *cli.Command {
Name: cfg.GraphExplorer.Service.Name,
Usage: subcommandDescription(cfg.GraphExplorer.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.GraphExplorer.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.GraphExplorer),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/idm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func IDMCommand(cfg *config.Config) *cli.Command {
Name: "idm",
Usage: "idm extension commands",
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.IDM.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.IDM),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func IDPCommand(cfg *config.Config) *cli.Command {
Name: cfg.IDP.Service.Name,
Usage: subcommandDescription(cfg.IDP.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.IDP.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.IDP),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/natsserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func NatsServerCommand(cfg *config.Config) *cli.Command {
Name: "nats-server",
Usage: "start nats server",
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.Nats.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Nats),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func NotificationsCommand(cfg *config.Config) *cli.Command {
Name: "notifications",
Usage: "start notifications service",
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.Notifications.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Notifications),
}
Expand Down
14 changes: 11 additions & 3 deletions ocis/pkg/command/ocdav.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package command

import (
"fmt"

"github.com/owncloud/ocis/extensions/ocdav/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/parser"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
Expand All @@ -13,9 +16,14 @@ func OCDavCommand(cfg *config.Config) *cli.Command {
Name: "ocdav",
Usage: "start ocdav",
Category: "extensions",
// Before: func(ctx *cli.Context) error {
// return ParseStorageCommon(ctx, cfg)
// },
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.OCDav.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.OCDav(cfg.OCDav)
return handleOriginalAction(c, origCmd)
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/ocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func OCSCommand(cfg *config.Config) *cli.Command {
Name: cfg.OCS.Service.Name,
Usage: subcommandDescription(cfg.OCS.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.OCS.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.OCS),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func ProxyCommand(cfg *config.Config) *cli.Command {
Name: cfg.Proxy.Service.Name,
Usage: subcommandDescription(cfg.Proxy.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.Proxy.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Proxy),
}
Expand Down
9 changes: 5 additions & 4 deletions ocis/pkg/command/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func SettingsCommand(cfg *config.Config) *cli.Command {
Name: cfg.Settings.Service.Name,
Usage: subcommandDescription(cfg.Settings.Service.Name),
Category: "extensions",
Before: func(ctx *cli.Context) error {
err := parser.ParseConfig(cfg)
if err != nil {
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
return err
cfg.Settings.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Settings),
}
Expand Down
11 changes: 11 additions & 0 deletions ocis/pkg/command/storageappprovider.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package command

import (
"fmt"

"github.com/owncloud/ocis/extensions/appprovider/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/parser"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
Expand All @@ -13,6 +16,14 @@ func StorageAppProviderCommand(cfg *config.Config) *cli.Command {
Name: "storage-app-provider",
Usage: "start storage app-provider service",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.AppProvider.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.AppProvider(cfg.AppProvider)
return handleOriginalAction(c, origCmd)
Expand Down
11 changes: 11 additions & 0 deletions ocis/pkg/command/storageauthbasic.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package command

import (
"fmt"

"github.com/owncloud/ocis/extensions/auth-basic/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/parser"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
Expand All @@ -13,6 +16,14 @@ func StorageAuthBasicCommand(cfg *config.Config) *cli.Command {
Name: "storage-auth-basic",
Usage: "start storage auth-basic service",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.AuthBasic.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.AuthBasic(cfg.AuthBasic)
return handleOriginalAction(c, origCmd)
Expand Down
11 changes: 11 additions & 0 deletions ocis/pkg/command/storageauthbearer.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package command

import (
"fmt"

"github.com/owncloud/ocis/extensions/auth-bearer/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/parser"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
Expand All @@ -13,6 +16,14 @@ func StorageAuthBearerCommand(cfg *config.Config) *cli.Command {
Name: "storage-auth-bearer",
Usage: "Start storage auth-bearer service",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.AuthBearer.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.AuthBearer(cfg.AuthBearer)
return handleOriginalAction(c, origCmd)
Expand Down
11 changes: 11 additions & 0 deletions ocis/pkg/command/storageauthmachine.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package command

import (
"fmt"

"github.com/owncloud/ocis/extensions/auth-machine/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/parser"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
Expand All @@ -13,6 +16,14 @@ func StorageAuthMachineCommand(cfg *config.Config) *cli.Command {
Name: "storage-auth-machine",
Usage: "start storage auth-machine service",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.AuthMachine.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.AuthMachine(cfg.AuthMachine)
return handleOriginalAction(c, origCmd)
Expand Down
11 changes: 11 additions & 0 deletions ocis/pkg/command/storagefrontend.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package command

import (
"fmt"

"github.com/owncloud/ocis/extensions/frontend/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/parser"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
Expand All @@ -13,6 +16,14 @@ func StorageFrontendCommand(cfg *config.Config) *cli.Command {
Name: "storage-frontend",
Usage: "start storage frontend",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.Frontend.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Frontend(cfg.Frontend)
return handleOriginalAction(c, origCmd)
Expand Down
Loading

0 comments on commit 0bb8300

Please sign in to comment.