summaryrefslogtreecommitdiff
path: root/cmd/podmanV2/registry/registry.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podmanV2/registry/registry.go')
-rw-r--r--cmd/podmanV2/registry/registry.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/cmd/podmanV2/registry/registry.go b/cmd/podmanV2/registry/registry.go
index b0c11ba04..9c12b2456 100644
--- a/cmd/podmanV2/registry/registry.go
+++ b/cmd/podmanV2/registry/registry.go
@@ -1,6 +1,8 @@
package registry
import (
+ "context"
+
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/domain/infra"
@@ -20,8 +22,7 @@ var (
imageEngine entities.ImageEngine
containerEngine entities.ContainerEngine
- EngineOpts entities.EngineOptions
- GlobalFlags entities.EngineFlags
+ EngineOptions entities.EngineOptions
ExitCode = define.ExecErrorCodeGeneric
)
@@ -76,8 +77,8 @@ func ImageEngine() entities.ImageEngine {
// NewImageEngine is a wrapper for building an ImageEngine to be used for PreRunE functions
func NewImageEngine(cmd *cobra.Command, args []string) (entities.ImageEngine, error) {
if imageEngine == nil {
- EngineOpts.FlagSet = cmd.Flags()
- engine, err := infra.NewImageEngine(EngineOpts)
+ EngineOptions.FlagSet = cmd.Flags()
+ engine, err := infra.NewImageEngine(EngineOptions)
if err != nil {
return nil, err
}
@@ -93,8 +94,8 @@ func ContainerEngine() entities.ContainerEngine {
// NewContainerEngine is a wrapper for building an ContainerEngine to be used for PreRunE functions
func NewContainerEngine(cmd *cobra.Command, args []string) (entities.ContainerEngine, error) {
if containerEngine == nil {
- EngineOpts.FlagSet = cmd.Flags()
- engine, err := infra.NewContainerEngine(EngineOpts)
+ EngineOptions.FlagSet = cmd.Flags()
+ engine, err := infra.NewContainerEngine(EngineOptions)
if err != nil {
return nil, err
}
@@ -109,3 +110,18 @@ func SubCommandExists(cmd *cobra.Command, args []string) error {
}
return errors.Errorf("missing command '%[1]s COMMAND'\nTry '%[1]s --help' for more information.", cmd.CommandPath())
}
+
+type podmanContextKey string
+
+var podmanFactsKey = podmanContextKey("engineOptions")
+
+func NewOptions(ctx context.Context, facts *entities.EngineOptions) context.Context {
+ return context.WithValue(ctx, podmanFactsKey, facts)
+}
+
+func Options(cmd *cobra.Command) (*entities.EngineOptions, error) {
+ if f, ok := cmd.Context().Value(podmanFactsKey).(*entities.EngineOptions); ok {
+ return f, errors.New("Command Context ")
+ }
+ return nil, nil
+}