kubetest2-kops: get KOPS_BASE_URL in non-periodic jobs

Otherwise we're not using the version we just built
This commit is contained in:
justinsb 2021-10-14 10:26:28 -04:00
parent d90885e7b8
commit 7eda9a41c5
2 changed files with 23 additions and 1 deletions

View File

@ -18,7 +18,10 @@ package builder
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"sigs.k8s.io/kubetest2/pkg/exec"
)
@ -39,5 +42,21 @@ func (b *BuildOptions) Build() error {
)
cmd.SetDir(b.KopsRoot)
exec.InheritOutput(cmd)
return cmd.Run()
if err := cmd.Run(); err != nil {
return err
}
// Write some meta files so that other tooling can know e.g. KOPS_BASE_URL
metaDir := filepath.Join(b.KopsRoot, ".kubetest2")
if err := os.MkdirAll(metaDir, 0755); err != nil {
return fmt.Errorf("failed to Mkdir(%q): %w", metaDir, err)
}
p := filepath.Join(metaDir, "kops-base-url")
kopsBaseURL := strings.Replace(b.StageLocation, "gs://", "https://storage.googleapis.com/", 1)
if err := ioutil.WriteFile(p, []byte(kopsBaseURL), 0644); err != nil {
return fmt.Errorf("failed to WriteFile(%q): %w", p, err)
}
return nil
}

View File

@ -108,6 +108,9 @@ function kops-acquire-latest() {
fi
$KUBETEST2 --build
KOPS="${REPO_ROOT}/.bazelbuild/dist/linux/amd64/kops"
KOPS_BASE_URL=$(cat "${REPO_ROOT}/.kubetest2/kops-base-url")
export KOPS_BASE_URL
echo "KOPS_BASE_URL=$KOPS_BASE_URL"
fi
}