mirror of
https://github.com/imjasonh/kontain.me
synced 2026-07-19 07:09:18 +00:00
add cmd/mirror, revert cmd/api changes
This commit is contained in:
parent
57955884c2
commit
340ca89f5a
9 changed files with 256 additions and 31 deletions
|
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/google/uuid"
|
||||
"github.com/imjasonh/kontain.me/pkg/run"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/google"
|
||||
gcb "google.golang.org/api/cloudbuild/v1"
|
||||
"google.golang.org/api/option"
|
||||
)
|
||||
|
|
@ -283,32 +282,11 @@ func (s *server) fetchAndBuild(src, tok string, req *gcb.Build) error {
|
|||
s.error.Printf("Closing GCS log: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
ts, err := google.DefaultTokenSource(context.Background(), "https://www.googleapis.com/auth/cloud-platform")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("google.DefaultTokenSource: %v", err)
|
||||
}
|
||||
tok, err := ts.Token()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("credentials.Token: %v", err)
|
||||
}
|
||||
|
||||
for _, cmd := range []string{
|
||||
fmt.Sprintf("mkdir -p /tmp/layers"),
|
||||
fmt.Sprintf("chown -R %d:%d %s", os.Geteuid(), os.Getgid(), src),
|
||||
fmt.Sprintf("chown -R %d:%d /tmp/layers", os.Geteuid(), os.Getgid()),
|
||||
fmt.Sprintf("curl -fsSL %s | tar xz -C %s", source, src),
|
||||
fmt.Sprintf(`
|
||||
mkdir -p ~/.docker/ && cat > ~/.docker/config.json << EOF
|
||||
{
|
||||
"auths": {
|
||||
"gcr.io": {
|
||||
"username": "oauth2accesstoken",
|
||||
"password": "%s"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF`, tok.AccessToken),
|
||||
fmt.Sprintf("wget -qO- %s | tar xz -C %s", source, src),
|
||||
fmt.Sprintf("/lifecycle/detector -app=%s -group=/tmp/layers/group.toml -plan=/tmp/layers/plan.toml", src),
|
||||
fmt.Sprintf("/lifecycle/analyzer -layers=/tmp/layers -helpers=false -group=/tmp/layers/group.toml %s", image),
|
||||
fmt.Sprintf("/lifecycle/builder -layers=/tmp/layers -app=%s -group=/tmp/layers/group.toml -plan=/tmp/layers/plan.toml", src),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue