Skip to content

Commit

Permalink
Merge pull request #376 from yue9944882/chore/refactor-build-aa-serve…
Browse files Browse the repository at this point in the history
…r-test-env

Chore: Compile aa server using gexec.Build
  • Loading branch information
k8s-ci-robot authored Jul 12, 2019
2 parents 6b1f1b2 + 72c99ed commit c8758f7
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions pkg/test/suite/aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"net/http"
"os"
"os/exec"
"path/filepath"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"strconv"
"time"
Expand Down Expand Up @@ -76,19 +75,12 @@ func (e *Environment) initAPIAggregationEnvironment() (err error) {

func (e *Environment) buildAggregatedAPIServer() (err error) {
// Compiling aggregated apiserver binary
binName := "aggregated-apiserver"
binPath := filepath.Join(e.KubeAPIServerEnvironment.ControlPlane.APIServer.CertDir, binName)
cmd := exec.Command("go",
append(
append(
[]string{"build", "-o", binPath}, e.AggregatedAPIServerBuildArgs...),
"../../../cmd/apiserver/main.go")...)
cmd.Env = os.Environ()
if err := cmd.Run(); err != nil {
compiledPath, err := gexec.Build("../../../cmd/apiserver/main.go")
if err != nil {
return err
}

e.AggregatedAPIServerBinaryPath = binPath
e.AggregatedAPIServerBinaryPath = compiledPath
e.AggregatedAPIServerSecurePort = 443
e.AggregatedAPIServerInsecurePort = 8080
e.AggregatedAPIServerFlags = []string{
Expand Down Expand Up @@ -199,5 +191,6 @@ func (e *Environment) StopLocalAggregatedAPIServer() (err error) {
return fmt.Errorf("port %v didn't released: %v", e.AggregatedAPIServerSecurePort, err)
}
}
gexec.CleanupBuildArtifacts()
return nil
}

0 comments on commit c8758f7

Please sign in to comment.