Skip to content

Commit

Permalink
fix: remove duplicate image pull
Browse files Browse the repository at this point in the history
  • Loading branch information
chzar committed Sep 20, 2024
1 parent 56e99e2 commit a73365d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/kind/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func createKindCluster(registry bool, extraMountHostPath string, extraMountConta
}
if registry {
fmt.Println("💽 Installing local registry...")
if err := pullLocalRegistryImage(dcli); err != nil {
return fmt.Errorf("%w", err)
}
if err := createLocalRegistry(dcli); err != nil {
return fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -144,11 +147,7 @@ func checkDocker() (*dclient.Client, error) {
return dcli, nil
}

func createLocalRegistry(dcli *dclient.Client) error {
if err := deleteContainerRegistry(dcli); err != nil {
return fmt.Errorf("failed to delete local registry: %w", err)
}

func pullLocalRegistryImage(dcli *dclient.Client) error {
ctx := context.Background()
iorc, err := dcli.ImagePull(ctx, "docker.io/library/registry:2", image.PullOptions{})
if err != nil {
Expand All @@ -166,8 +165,15 @@ func createLocalRegistry(dcli *dclient.Client) error {
if err := scanner.Err(); err != nil {
return fmt.Errorf("failed to read image pull response: %w", err)
}
return nil
}

func createLocalRegistry(dcli *dclient.Client) error {
if err := deleteContainerRegistry(dcli); err != nil {
return fmt.Errorf("failed to delete local registry: %w", err)
}

resp, err := dcli.ContainerCreate(ctx, &container.Config{
resp, err := dcli.ContainerCreate(context.Background(), &container.Config{
Image: "registry:2",
}, &container.HostConfig{
RestartPolicy: container.RestartPolicy{
Expand Down

0 comments on commit a73365d

Please sign in to comment.