Remove legacy client-manager platform path
This commit is contained in:
@@ -2,10 +2,8 @@ package service
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
@@ -307,14 +305,7 @@ func (builder *DockerDistributionBuilder) BuildWithProgress(input domain.Distrib
|
||||
if len(binary) == 0 {
|
||||
return nil, validationError("platform builder produced an empty distribution executable")
|
||||
}
|
||||
if input.ComponentKind == domain.DistributionComponentRun {
|
||||
return binary, nil
|
||||
}
|
||||
configPayload, err := os.ReadFile(filepath.Join(outputDir, "config.yaml"))
|
||||
if err != nil {
|
||||
return nil, validationError("platform builder did not produce client-manager configuration")
|
||||
}
|
||||
return packageClientManagerDistribution(input.PackageFormat, outputName, binary, configPayload)
|
||||
return binary, nil
|
||||
}
|
||||
|
||||
// prepareRunSource implements the source phase of a Jenkins-style build. A
|
||||
@@ -519,36 +510,8 @@ EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$COMPONENT_KIND" != "client-manager" ]; then
|
||||
printf 'unsupported component kind\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
case "$REPOSITORY_URL" in
|
||||
https://*) ;;
|
||||
*) printf 'client-manager repository must use https\n' >&2; exit 2 ;;
|
||||
esac
|
||||
cd /workspace/build
|
||||
progress 24 'git_sync: fetching client-manager source'
|
||||
git init --quiet
|
||||
git remote add origin "$REPOSITORY_URL"
|
||||
git fetch --quiet --depth 1 origin "$SOURCE_REVISION"
|
||||
git checkout --quiet --detach FETCH_HEAD
|
||||
progress 36 'env_check: writing client-manager configuration'
|
||||
{
|
||||
printf 'server_url: "%s"\n' "$PLATFORM_URL"
|
||||
printf 'server_instance_id: "%s"\n' "$SERVER_INSTANCE_ID"
|
||||
printf 'scum_client_credential: "%s"\n' "$auth_key"
|
||||
printf 'scum_client_name: "%s"\n' "$PROFILE_KEY"
|
||||
printf 'scum_client_version: "platform-build"\n'
|
||||
printf 'scum_client_machine_label: "managed-client"\n'
|
||||
printf 'ftp_provider: 3\n'
|
||||
} > config.yaml
|
||||
progress 52 'deps_download: downloading Go modules'
|
||||
go mod download
|
||||
progress 76 'build_compile: compiling client-manager executable'
|
||||
go build -trimpath -ldflags '-s -w' -o "/workspace/output/$OUTPUT_FILENAME" .
|
||||
cp config.yaml /workspace/output/config.yaml
|
||||
progress 88 'package_finalize: client-manager package inputs written'
|
||||
printf 'unsupported component kind\n' >&2
|
||||
exit 2
|
||||
`
|
||||
|
||||
func (builder *DockerDistributionBuilder) containerArgs(input domain.DistributionBuildInput, sourceDir string, inputDir string, buildDir string, outputDir string, goBuildCacheDir string, goModCacheDir string, outputName string) []string {
|
||||
@@ -588,71 +551,6 @@ func (builder *DockerDistributionBuilder) containerArgs(input domain.Distributio
|
||||
}
|
||||
}
|
||||
|
||||
func packageClientManagerDistribution(packageFormat string, outputName string, binary []byte, configPayload []byte) ([]byte, error) {
|
||||
switch packageFormat {
|
||||
case "zip":
|
||||
return zipDistributionFiles(outputName, binary, configPayload)
|
||||
case "tar.gz":
|
||||
return tarGzipDistributionFiles(outputName, binary, configPayload)
|
||||
default:
|
||||
return nil, validationError("platform builder received an unsupported client-manager package format")
|
||||
}
|
||||
}
|
||||
|
||||
func zipDistributionFiles(outputName string, binary []byte, configPayload []byte) ([]byte, error) {
|
||||
var buffer bytes.Buffer
|
||||
writer := zip.NewWriter(&buffer)
|
||||
files := []struct {
|
||||
name string
|
||||
mode os.FileMode
|
||||
payload []byte
|
||||
}{{outputName, 0o755, binary}, {"config.yaml", 0o600, configPayload}}
|
||||
for _, file := range files {
|
||||
header := &zip.FileHeader{Name: file.name, Method: zip.Deflate}
|
||||
header.SetMode(file.mode)
|
||||
header.SetModTime(time.Date(1980, time.January, 1, 0, 0, 0, 0, time.UTC))
|
||||
entry, err := writer.CreateHeader(header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := entry.Write(file.payload); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err := writer.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
func tarGzipDistributionFiles(outputName string, binary []byte, configPayload []byte) ([]byte, error) {
|
||||
var buffer bytes.Buffer
|
||||
gzipWriter := gzip.NewWriter(&buffer)
|
||||
gzipWriter.Header.ModTime = time.Unix(0, 0).UTC()
|
||||
tarWriter := tar.NewWriter(gzipWriter)
|
||||
files := []struct {
|
||||
name string
|
||||
mode int64
|
||||
payload []byte
|
||||
}{{outputName, 0o755, binary}, {"config.yaml", 0o600, configPayload}}
|
||||
for _, file := range files {
|
||||
header := &tar.Header{Name: file.name, Mode: file.mode, Size: int64(len(file.payload)), ModTime: time.Unix(0, 0).UTC()}
|
||||
if err := tarWriter.WriteHeader(header); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := tarWriter.Write(file.payload); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err := tarWriter.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := gzipWriter.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
// safeBuilderFailure keeps host paths and secret values out of reported build
|
||||
// failures.
|
||||
func safeBuilderFailure(output []byte, sensitiveValues ...string) string {
|
||||
|
||||
Reference in New Issue
Block a user