Skip to content

Commit

Permalink
set opt to cleanup build containers
Browse files Browse the repository at this point in the history
  • Loading branch information
xadhatter committed Oct 19, 2023
1 parent 944cf5b commit 18e94f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ func (cfg *Config) Setup() {
log.Info("Fox needs a place to store the KubeFox Component images it will build, normally")
log.Info("this is a remote container registry. However, if you only want to use KubeFox")
log.Info("locally with Kind you can skip this step.")
kindOnly := utils.YesNoPrompt("Are you only using KubeFox locally?", false)
kindOnly := utils.YesNoPrompt("Are you only using KubeFox with local Kind cluster?", false)
if kindOnly {
cfg.ContainerRegistry.Address = LocalRegistry
cfg.ContainerRegistry.Token = ""
cfg.Kind.ClusterName = utils.NamePrompt("Kind cluster", "kind", true)
cfg.Kind.ClusterName = utils.NamePrompt("Kind cluster name", "kind", true)
cfg.Kind.AlwaysLoad = true
cfg.done()
return
Expand Down
7 changes: 4 additions & 3 deletions internal/repo/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ func (r *repo) BuildComp(compDirName string) string {
gitCommit := r.GetCompCommit(compDirName)
gitRef := r.GetRefName()
regAuth := r.GetRegAuth()
localReg := strings.HasPrefix(r.cfg.ContainerRegistry.Address, config.LocalRegistry)

if !(r.cfg.Flags.ForceBuild || r.cfg.Flags.NoCache) {
if !(r.cfg.Flags.ForceBuild || r.cfg.Flags.NoCache || localReg) {
if di, err := r.docker.DistributionInspect(context.Background(), img, regAuth); err != nil {
log.Verbose("%s", err)
} else {
Expand Down Expand Up @@ -81,6 +82,7 @@ func (r *repo) BuildComp(compDirName string) string {
buildResp, err := r.docker.ImageBuild(context.Background(), dfi, types.ImageBuildOptions{
Dockerfile: injectedDockerfile,
NoCache: r.cfg.Flags.NoCache,
Remove: true,
Tags: []string{img},
Labels: labels,
BuildArgs: map[string]*string{
Expand All @@ -95,7 +97,6 @@ func (r *repo) BuildComp(compDirName string) string {
}
logResp(buildResp.Body)

localReg := strings.HasPrefix(r.cfg.ContainerRegistry.Address, config.LocalRegistry)
if localReg {
log.Verbose("Local registry is set, container image push will be skipped.")
}
Expand Down Expand Up @@ -146,7 +147,7 @@ func (r *repo) KindLoad(img string) {

if out, err := cmd.CombinedOutput(); err != nil {
log.Error("%s", strings.TrimSpace(string(out)))
log.Error("Error loading component image into Kind: %v", err)
log.Fatal("Error loading component image into Kind: %v", err)
} else {
log.Verbose("%s", strings.TrimSpace(string(out)))
}
Expand Down

0 comments on commit 18e94f8

Please sign in to comment.