Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate build/pull tool for index rm #374

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions cmd/opm/index/delete.go
@@ -1,7 +1,6 @@
package index

import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -37,7 +36,9 @@ func newIndexDeleteCmd() *cobra.Command {
logrus.Panic("Failed to set required `operators` flag for `index delete`")
}
indexCmd.Flags().StringP("binary-image", "i", "", "container image for on-image `opm` command")
indexCmd.Flags().StringP("container-tool", "c", "podman", "tool to interact with container images (save, build, etc.). One of: [none, docker, podman]")
indexCmd.Flags().StringP("container-tool", "c", "", "tool to interact with container images (save, build, etc.). One of: [none, docker, podman]")
indexCmd.Flags().StringP("build-tool", "u", "", "tool to build container images. One of: [docker, podman]. Defaults to podman. Overrides part of container-tool.")
indexCmd.Flags().StringP("pull-tool", "p", "", "tool to pull container images. One of: [none, docker, podman]. Defaults to none. Overrides part of container-tool.")
indexCmd.Flags().StringP("tag", "t", "", "custom tag for container image being built")
indexCmd.Flags().Bool("permissive", false, "allow registry load errors")

Expand Down Expand Up @@ -75,15 +76,11 @@ func runIndexDeleteCmdFunc(cmd *cobra.Command, args []string) error {
return err
}

containerTool, err := cmd.Flags().GetString("container-tool")
pullTool, buildTool, err := getContainerTools(cmd)
if err != nil {
return err
}

if containerTool == "none" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we have a lot of conversations around non-tool. I couldn't keep track of what's going on there, Is there any reason we are removing the check here? Thanks.

otherwise lgtm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept of that check was just moved into the existing private method getContainerTools(), which I'm reusing the logic for:

https://github.com/operator-framework/operator-registry/blob/master/cmd/opm/index/add.go#L162

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, nice. Thanks

/lgtm
/hold
waiting for a second review

return fmt.Errorf("none is not a valid container-tool for index add")
}

tag, err := cmd.Flags().GetString("tag")
if err != nil {
return err
Expand All @@ -98,7 +95,10 @@ func runIndexDeleteCmdFunc(cmd *cobra.Command, args []string) error {

logger.Info("building the index")

indexDeleter := indexer.NewIndexDeleter(containertools.NewContainerTool(containerTool, containertools.PodmanTool), logger)
indexDeleter := indexer.NewIndexDeleter(
containertools.NewContainerTool(buildTool, containertools.PodmanTool),
containertools.NewContainerTool(pullTool, containertools.NoneTool),
logger)

request := indexer.DeleteFromIndexRequest{
Generate: generate,
Expand Down
10 changes: 5 additions & 5 deletions pkg/lib/indexer/interfaces.go
Expand Up @@ -35,14 +35,14 @@ type IndexDeleter interface {
}

// NewIndexDeleter is a constructor that returns an IndexDeleter
func NewIndexDeleter(containerTool containertools.ContainerTool, logger *logrus.Entry) IndexDeleter {
func NewIndexDeleter(buildTool, pullTool containertools.ContainerTool, logger *logrus.Entry) IndexDeleter {
return ImageIndexer{
DockerfileGenerator: containertools.NewDockerfileGenerator(logger),
CommandRunner: containertools.NewCommandRunner(containerTool, logger),
LabelReader: containertools.NewLabelReader(containerTool, logger),
CommandRunner: containertools.NewCommandRunner(buildTool, logger),
LabelReader: containertools.NewLabelReader(pullTool, logger),
RegistryDeleter: registry.NewRegistryDeleter(logger),
BuildTool: containerTool,
PullTool: containerTool,
BuildTool: buildTool,
PullTool: pullTool,
Logger: logger,
}
}
Expand Down