fix ocis config parsing for subcommands

This commit is contained in:
Willy Kloucek
2022-05-02 12:02:09 +02:00
parent c878adbd8b
commit 18e9661a24
29 changed files with 223 additions and 71 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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"
)
@@ -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)

View File

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

View File

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

View File

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

View File

@@ -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"
)
@@ -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)

View File

@@ -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"
)
@@ -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)

View File

@@ -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"
)
@@ -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)

View File

@@ -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"
)
@@ -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)

View File

@@ -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"
)
@@ -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)

View File

@@ -1,8 +1,11 @@
package command
import (
"fmt"
"github.com/owncloud/ocis/extensions/gateway/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"
)
@@ -13,10 +16,14 @@ func StorageGatewayCommand(cfg *config.Config) *cli.Command {
Name: "storage-gateway",
Usage: "start storage gateway",
Category: "extensions",
//Flags: flagset.GatewayWithConfig(cfg.Storage),
// 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.Gateway.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Gateway(cfg.Gateway)
return handleOriginalAction(c, origCmd)

View File

@@ -1,8 +1,11 @@
package command
import (
"fmt"
"github.com/owncloud/ocis/extensions/group/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"
)
@@ -13,6 +16,14 @@ func StorageGroupProviderCommand(cfg *config.Config) *cli.Command {
Name: "storage-groupprovider",
Usage: "start storage groupprovider service",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.Group.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Groups(cfg.Group)
return handleOriginalAction(c, origCmd)

View File

@@ -1,8 +1,11 @@
package command
import (
"fmt"
"github.com/owncloud/ocis/extensions/storage-metadata/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"
)
@@ -13,6 +16,14 @@ func StorageMetadataCommand(cfg *config.Config) *cli.Command {
Name: "storage-metadata",
Usage: "start storage and data service for metadata",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.StorageMetadata.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.StorageMetadata(cfg.StorageMetadata)
return handleOriginalAction(c, origCmd)

View File

@@ -1,8 +1,11 @@
package command
import (
"fmt"
"github.com/owncloud/ocis/extensions/storage-publiclink/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"
)
@@ -13,6 +16,14 @@ func StoragePublicLinkCommand(cfg *config.Config) *cli.Command {
Name: "storage-public-link",
Usage: "start storage public link storage",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.StoragePublicLink.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.StoragePublicLink(cfg.StoragePublicLink)
return handleOriginalAction(c, origCmd)

View File

@@ -1,8 +1,11 @@
package command
import (
"fmt"
"github.com/owncloud/ocis/extensions/storage-shares/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"
)
@@ -13,6 +16,14 @@ func StorageSharesCommand(cfg *config.Config) *cli.Command {
Name: "storage-shares",
Usage: "start storage and data provider for shares jail",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.StorageShares.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.StorageShares(cfg.StorageShares)
return handleOriginalAction(c, origCmd)

View File

@@ -1,8 +1,11 @@
package command
import (
"fmt"
"github.com/owncloud/ocis/extensions/sharing/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"
)
@@ -13,6 +16,14 @@ func StorageSharingCommand(cfg *config.Config) *cli.Command {
Name: "storage-sharing",
Usage: "start storage sharing service",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.Sharing.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Sharing(cfg.Sharing)
return handleOriginalAction(c, origCmd)

View File

@@ -1,8 +1,11 @@
package command
import (
"fmt"
"github.com/owncloud/ocis/extensions/user/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"
)
@@ -13,6 +16,14 @@ func StorageUserProviderCommand(cfg *config.Config) *cli.Command {
Name: "storage-userprovider",
Usage: "start storage userprovider service",
Category: "extensions",
Before: func(c *cli.Context) error {
if err := parser.ParseConfig(cfg); err != nil {
fmt.Printf("%v", err)
return err
}
cfg.StorageUsers.Commons = cfg.Commons
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.User(cfg.User)
return handleOriginalAction(c, origCmd)

View File

@@ -17,12 +17,13 @@ func StoreCommand(cfg *config.Config) *cli.Command {
Name: cfg.Store.Service.Name,
Usage: subcommandDescription(cfg.Store.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.Store.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Store),
}

View File

@@ -16,12 +16,13 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command {
Name: cfg.Thumbnails.Service.Name,
Usage: subcommandDescription(cfg.Thumbnails.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.Thumbnails.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Thumbnails),
}

View File

@@ -16,12 +16,13 @@ func WebCommand(cfg *config.Config) *cli.Command {
Name: cfg.Web.Service.Name,
Usage: subcommandDescription(cfg.Web.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.Web.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.Web),
}

View File

@@ -17,12 +17,13 @@ func WebDAVCommand(cfg *config.Config) *cli.Command {
Name: cfg.WebDAV.Service.Name,
Usage: subcommandDescription(cfg.WebDAV.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.WebDAV.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.WebDAV),
}