Skip to content

Commit

Permalink
Switch to --platform=windows/amd64:10.0.17763.2300 format, drop --osv…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
imjasonh committed Dec 14, 2021
1 parent 62f5e85 commit 3cadee0
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 20 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ jobs:
# cribbed from https://gist.github.com/Syeberman/39d81b1e17d091be5657ecd6fbff0753
eval $(go env | sed -r 's/^(set )?(\w+)=("?)(.*)\3$/\2="\4"/gm')
OSVERSION=""
PLATFORM=${GOOS}/${GOARCH}
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
OSVERSION="10.0.17763.2300"
PLATFORM=${PLATFORM}:${OSVERSION}
export KO_DEFAULTBASEIMAGE=mcr.microsoft.com/windows/nanoserver:1809
fi
echo platform is ${GOOS}/${GOARCH}
echo platform is ${PLATFORM}
# Build and run the ko binary, which should be runnable.
docker run $(go run ./ publish ./ --platform=${GOOS}/${GOARCH} --osversion=${OSVERSION} --preserve-import-paths) version
docker run $(go run ./ publish ./ --platform=${PLATFORM} --osversion=${OSVERSION} --preserve-import-paths) version
# Build and run the test/ binary, which should log "Hello there" served from KO_DATA_PATH
testimg=$(go run ./ publish ./test --platform=${GOOS}/${GOARCH} --preserve-import-paths)
testimg=$(go run ./ publish ./test --platform=${PLATFORM} --preserve-import-paths)
docker run ${testimg} --wait=false 2>&1 | grep "Hello there"
# Check that symlinks in kodata are chased.
Expand All @@ -60,5 +61,5 @@ jobs:
ldflags:
- "-X main.version=${{ github.sha }}"
EOF
docker run $(go run ./ publish ./test/ --platform=${GOOS}/${GOARCH}) --wait=false 2>&1 | grep "${{ github.sha }}"
docker run $(go run ./ publish ./test/ --platform=${PLATFORM}) --wait=false 2>&1 | grep "${{ github.sha }}"
1 change: 0 additions & 1 deletion doc/ko_apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ ko apply -f FILENAME [flags]
-L, --local Load into images to local docker daemon.
-n, --namespace string If present, the namespace scope for this CLI request (DEPRECATED)
--oci-layout-path string Path to save the OCI image layout of the built images
--osversion string Which OS version to use when selecting a platform-specific base.
--password string Password for basic authentication to the API server (DEPRECATED)
--platform string Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
Expand Down
1 change: 0 additions & 1 deletion doc/ko_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ ko build IMPORTPATH... [flags]
-j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS)
-L, --local Load into images to local docker daemon.
--oci-layout-path string Path to save the OCI image layout of the built images
--osversion string Which OS version to use when selecting a platform-specific base.
--platform string Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
--push Push images to KO_DOCKER_REPO (default true)
Expand Down
1 change: 0 additions & 1 deletion doc/ko_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ ko create -f FILENAME [flags]
-L, --local Load into images to local docker daemon.
-n, --namespace string If present, the namespace scope for this CLI request (DEPRECATED)
--oci-layout-path string Path to save the OCI image layout of the built images
--osversion string Which OS version to use when selecting a platform-specific base.
--password string Password for basic authentication to the API server (DEPRECATED)
--platform string Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
Expand Down
1 change: 0 additions & 1 deletion doc/ko_resolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ko resolve -f FILENAME [flags]
-j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS)
-L, --local Load into images to local docker daemon.
--oci-layout-path string Path to save the OCI image layout of the built images
--osversion string Which OS version to use when selecting a platform-specific base.
--platform string Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
--push Push images to KO_DOCKER_REPO (default true)
Expand Down
1 change: 0 additions & 1 deletion doc/ko_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ ko run IMPORTPATH [flags]
-j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS)
-L, --local Load into images to local docker daemon.
--oci-layout-path string Path to save the OCI image layout of the built images
--osversion string Which OS version to use when selecting a platform-specific base.
--platform string Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
--push Push images to KO_DOCKER_REPO (default true)
Expand Down
10 changes: 7 additions & 3 deletions pkg/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ func getBaseImage(bo *options.BuildOptions) build.GetBase {
// image.
multiplatform := bo.Platform == "all" || strings.Contains(bo.Platform, ",")
if bo.Platform != "" && !multiplatform {
p := v1.Platform{
OSVersion: bo.OSVersion,
var p v1.Platform

parts := strings.Split(bo.Platform, ":")
if len(parts) == 2 {
p.OSVersion = parts[1]
}
parts := strings.Split(bo.Platform, "/")

parts = strings.Split(parts[0], "/")
if len(parts) > 0 {
p.OS = parts[0]
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/commands/options/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type BuildOptions struct {
ConcurrentBuilds int
DisableOptimizations bool
SBOM string
Platform, OSVersion string
Platform string
Labels []string
// UserAgent enables overriding the default value of the `User-Agent` HTTP
// request header used when retrieving the base image.
Expand All @@ -78,8 +78,6 @@ func AddBuildOptions(cmd *cobra.Command, bo *BuildOptions) {
"The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, go.version-m).")
cmd.Flags().StringVar(&bo.Platform, "platform", "",
"Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*")
cmd.Flags().StringVar(&bo.OSVersion, "osversion", "",
"Which OS version to use when selecting a platform-specific base.")
cmd.Flags().StringSliceVar(&bo.Labels, "image-label", []string{},
"Which labels (key=value) to add to the image.")
bo.Trimpath = true
Expand Down
4 changes: 0 additions & 4 deletions pkg/commands/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ func gobuildOptions(bo *options.BuildOptions) ([]build.Option, error) {
}
}

if multiplatform := bo.Platform == "all" || strings.Contains(bo.Platform, ","); multiplatform && bo.OSVersion != "" {
return nil, fmt.Errorf("cannot use --osversion with --platform=all or multiple platforms")
}

opts := []build.Option{
build.WithBaseImages(getBaseImage(bo)),
build.WithPlatforms(bo.Platform),
Expand Down

0 comments on commit 3cadee0

Please sign in to comment.