You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: buildkit.go
    path of file: ./repos/devspace/pkg/devspace/build/builder/buildkit
    
    the code of the file until where you have to start completion: package buildkit

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"math/rand"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"time"

	"github.com/loft-sh/devspace/pkg/devspace/pipeline/env"
	"mvdan.cc/sh/v3/expand"

	devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
	command2 "github.com/loft-sh/utils/pkg/command"

	cli
    
func (b *Builder) ShouldRebuild(ctx devspacecontext.Context, forceRebuild bool) (bool, error) {
	// Check if image is present in local registry
	imageCache, _ := ctx.Config().LocalCache().GetImageCache(b.helper.ImageConf.Name)
	imageName := imageCache.ResolveImage() + ":" + imageCache.Tag
	rebuild, err := b.helper.ShouldRebuild(ctx, forceRebuild)

	// Check if image is present in local docker daemon
	if !rebuild && err == nil && b.helper.ImageConf.BuildKit.InCluster == nil {
		if b.skipPushOnLocalKubernetes && ctx.KubeClient() != nil && kubectl.IsLocalKubernetes(ctx.KubeClient()) {
			dockerClient, err := dockerpkg.NewClientWithMinikube(ctx.Context(), ctx.KubeClient(), b.helper.ImageConf.BuildKit.PreferMinikube == nil || *b.helper.ImageConf.BuildKit.PreferMinikube, ctx.Log())
			if err != nil {
				return false, err
			}

			found, err := b.helper.IsImageAvailableLocally(ctx, dockerClient)
			if !found && err == nil {
				ctx.Log().Infof("Rebuild image %s because it was not found in local docker daemon", imageName)
				return true, nil
			}
		}
	}

	return rebuild, err
}