MCPcopy
hub / github.com/operator-framework/operator-sdk / NewPartialTestContext

Function NewPartialTestContext

internal/testutils/utils.go:64–82  ·  view source on GitHub ↗

NewPartialTestContext returns a TestContext containing a partial kubebuilder TestContext. This object needs to be populated with GVK information. The underlying TestContext is created directly rather than through a constructor so cluster-based setup is skipped.

(binaryName, dir string, env ...string)

Source from the content-addressed store, hash-verified

62// This object needs to be populated with GVK information. The underlying TestContext is
63// created directly rather than through a constructor so cluster-based setup is skipped.
64func NewPartialTestContext(binaryName, dir string, env ...string) (tc TestContext, err error) {
65 cc := &kbtestutils.CmdContext{
66 Env: env,
67 }
68 if cc.Dir, err = filepath.Abs(dir); err != nil {
69 return tc, err
70 }
71 projectName := strings.ToLower(filepath.Base(dir))
72
73 return TestContext{
74 TestContext: &kbtestutils.TestContext{
75 CmdContext: cc,
76 BinaryName: binaryName,
77 ImageName: makeImageName(projectName),
78 },
79 ProjectName: projectName,
80 BundleImageName: makeBundleImageName(projectName),
81 }, nil
82}
83
84func makeImageName(projectName string) string {
85 return fmt.Sprintf("quay.io/example/%s:v0.0.1", projectName)

Callers 1

NewSampleContextFunction · 0.92

Calls 2

makeImageNameFunction · 0.85
makeBundleImageNameFunction · 0.85

Tested by

no test coverage detected