Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions cmd/cluster-config-operator-tests-ext/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://github.com/openshift-eng/openshift-tests-extension/blob/main/cmd/example
package main

import (
"context"
"fmt"
"os"

"github.com/spf13/cobra"
Expand All @@ -22,13 +22,20 @@ import (
)

func main() {
command := newOperatorTestCommand(context.Background())
code := cli.Run(command)
cmd, err := newOperatorTestCommand()
if err != nil {
klog.Fatal(err)
}

code := cli.Run(cmd)
os.Exit(code)
}

func newOperatorTestCommand(ctx context.Context) *cobra.Command {
registry := prepareOperatorTestsRegistry()
func newOperatorTestCommand() (*cobra.Command, error) {
registry, err := prepareOperatorTestsRegistry()
if err != nil {
return nil, fmt.Errorf("failed to prepare test registry: %w", err)
}

cmd := &cobra.Command{
Use: "cluster-config-operator-tests-ext",
Expand All @@ -49,18 +56,18 @@ func newOperatorTestCommand(ctx context.Context) *cobra.Command {

cmd.AddCommand(otecmd.DefaultExtensionCommands(registry)...)

return cmd
return cmd, nil
}

// prepareOperatorTestsRegistry creates the OTE registry for this operator.
//
// Note:
//
// This method must be called before adding the registry to the OTE framework.
func prepareOperatorTestsRegistry() *oteextension.Registry {
func prepareOperatorTestsRegistry() (*oteextension.Registry, error) {
registry := oteextension.NewRegistry()
extension := oteextension.NewExtension("openshift", "payload", "cluster-config-operator")

registry.Register(extension)
return registry
return registry, nil
}