Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce v1alpha2.Operator.TargetCatalog which will later replace Ta…
…rgetName TargetCatalog can contain several component-paths, allowing the user to set the namespace to which the catalog will be copied. Changes to be committed: modified: pkg/api/v1alpha2/types_config.go new file: pkg/api/v1alpha2/types_config_test.go modified: pkg/cli/mirror/fbc_operators.go modified: pkg/cli/mirror/fbc_operators_test.go modified: pkg/cli/mirror/manifests.go
- Loading branch information
Showing
5 changed files
with
164 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package v1alpha2 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGetUniqueName(t *testing.T) { | ||
type spec struct { | ||
desc string | ||
ref Operator | ||
exp string | ||
expError string | ||
} | ||
|
||
specs := []spec{ | ||
{ | ||
desc: "simple flow", | ||
ref: Operator{ | ||
Catalog: "registry.redhat.io/redhat/redhat-operator-index:v4.12", | ||
IncludeConfig: IncludeConfig{ | ||
Packages: []IncludePackage{ | ||
{ | ||
Name: "aws-load-balancer-operator", | ||
}, | ||
}, | ||
}, | ||
}, | ||
exp: "registry.redhat.io/redhat/redhat-operator-index:v4.12", | ||
expError: "", | ||
}, | ||
{ | ||
desc: "simple flow with targetCatalog", | ||
ref: Operator{ | ||
Catalog: "registry.redhat.io/redhat/redhat-operator-index:v4.12", | ||
TargetCatalog: "def/redhat-operator-index", | ||
IncludeConfig: IncludeConfig{ | ||
Packages: []IncludePackage{ | ||
{ | ||
Name: "aws-load-balancer-operator", | ||
}, | ||
}, | ||
}, | ||
}, | ||
exp: "registry.redhat.io/def/redhat-operator-index:v4.12", | ||
expError: "", | ||
}, | ||
{ | ||
desc: "OCI FBC flow", | ||
ref: Operator{ | ||
Catalog: "oci:///home/myuser/random/folder/redhat-operator-index:v4.12", | ||
TargetCatalog: "def/redhat-operator-index", | ||
IncludeConfig: IncludeConfig{ | ||
Packages: []IncludePackage{ | ||
{ | ||
Name: "aws-load-balancer-operator", | ||
}, | ||
}, | ||
}, | ||
}, | ||
exp: "def/redhat-operator-index:v4.12", | ||
expError: "", | ||
}, | ||
} | ||
|
||
for _, s := range specs { | ||
t.Run(s.desc, func(t *testing.T) { | ||
un, err := s.ref.GetUniqueName() | ||
if s.expError != "" { | ||
require.EqualError(t, err, s.expError) | ||
} else { | ||
require.NoError(t, err) | ||
require.Equal(t, s.exp, un) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters