Skip to content

Commit

Permalink
Fix manifest generation
Browse files Browse the repository at this point in the history
  • Loading branch information
danudey committed May 17, 2023
1 parent 922f606 commit f5ea15d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
12 changes: 5 additions & 7 deletions hack/release/pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@ func (r *ReleaseBuilder) collectGithubArtifacts(ver string) error {
if _, err := r.runner.Run("cp", []string{fmt.Sprintf("node/dist/calico-windows-%s.zip", ver), uploadDir}, nil); err != nil {
return err
}
if _, err := r.runner.Run("cp", []string{"calico/_site/scripts/install-calico-windows.ps1", uploadDir}, nil); err != nil {
if _, err := r.runner.Run("cp", []string{"node/dist/install-calico-windows.ps1", uploadDir}, nil); err != nil {
return err
}
if _, err := r.runner.Run("cp", []string{fmt.Sprintf("bin/tigera-operator-%s.tgz", ver), uploadDir}, nil); err != nil {
return err
}
if _, err := r.runner.Run("cp", []string{"manifests/ocp.tgz", ver, uploadDir}, nil); err != nil {
if _, err := r.runner.Run("cp", []string{"bin/ocp.tgz", uploadDir}, nil); err != nil {
return err
}

Expand Down Expand Up @@ -409,7 +409,7 @@ func (r *ReleaseBuilder) buildReleaseTar(ver string, targetDir string) error {
}

// Add in manifests directory generated from the docs.
if _, err := r.runner.Run("cp", []string{"-r", "calico/_site/manifests", releaseBase}, nil); err != nil {
if _, err := r.runner.Run("cp", []string{"-r", "manifests", releaseBase}, nil); err != nil {
return err
}

Expand Down Expand Up @@ -443,12 +443,10 @@ func (r *ReleaseBuilder) buildContainerImages(ver string) error {
)

for _, dir := range releaseDirs {
out, err := r.makeInDirectoryWithOutput(dir, "release-build", env...)
err := r.makeInDirectory(dir, "release-build", env...)
if err != nil {
logrus.Error(out)
return fmt.Errorf("Failed to build %s: %s", dir, err)
}
logrus.Info(out)
}
return nil
}
Expand Down Expand Up @@ -632,7 +630,7 @@ func (r *ReleaseBuilder) gitOrFail(args ...string) {
}

func (r *ReleaseBuilder) makeInDirectory(dir, target string, env ...string) error {
_, err := r.runner.Run("make", []string{"-C", dir, target}, env)
err := r.runner.RunNoCapture("make", []string{"-C", dir, target}, env)
return err
}

Expand Down
21 changes: 21 additions & 0 deletions hack/release/pkg/builder/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package builder
import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"strings"

Expand All @@ -14,8 +16,10 @@ type CommandRunner interface {
// Run takes the command to run, a list of args, and list of environment variables
// in the form A=B, and returns stdout / error.
Run(string, []string, []string) (string, error)
RunNoCapture(string, []string, []string) error

RunInDir(string, string, []string, []string) (string, error)
RunInDirNoCapture(string, string, []string, []string) error
}

// RealCommandRunner runs a command for real on the host.
Expand All @@ -39,6 +43,23 @@ func (r *RealCommandRunner) RunInDir(dir, name string, args []string, env []stri
return strings.TrimSpace(outb.String()), err
}

func (r *RealCommandRunner) RunInDirNoCapture(dir, name string, args []string, env []string) error {
cmd := exec.Command(name, args...)
if len(env) != 0 {
cmd.Env = env
}
cmd.Stdout = io.Writer(os.Stdout)
cmd.Stderr = io.Writer(os.Stderr)
cmd.Dir = dir
logrus.WithField("cmd", cmd.String()).Infof("Running %s command", name)
err := cmd.Run()
return err
}

func (r *RealCommandRunner) Run(name string, args []string, env []string) (string, error) {
return r.RunInDir("", name, args, env)
}

func (r *RealCommandRunner) RunNoCapture(name string, args []string, env []string) error {
return r.RunInDirNoCapture("", name, args, env)
}

0 comments on commit f5ea15d

Please sign in to comment.