Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OCI image build #1666

Merged
merged 2 commits into from
Apr 29, 2022
Merged

Fix OCI image build #1666

merged 2 commits into from
Apr 29, 2022

Conversation

dsimansk
Copy link
Contributor

Description

Changes

  • Fix OCI image build

Reference

Related to #257

/cc @rhuss

@knative-prow knative-prow bot requested a review from rhuss April 28, 2022 12:24
@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 28, 2022
${EXTERNAL_LD_FLAGS:-}"
}

build_flags "$@"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhuss I went with the following call here, but I don't removing the functions completely.

@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #1666 (eabdde8) into main (fef2f69) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1666   +/-   ##
=======================================
  Coverage   79.49%   79.49%           
=======================================
  Files         171      171           
  Lines       12969    12969           
=======================================
  Hits        10310    10310           
  Misses       1941     1941           
  Partials      718      718           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fef2f69...eabdde8. Read the comment docs.

hack/build-flags.sh Outdated Show resolved Hide resolved
hack/build-flags.sh Outdated Show resolved Hide resolved
# Use vYYYYMMDD-<hash>-local for the version string, if not passed.
[[ -z "${version}" ]] && version="v${BUILD_TAG}-local"
# Env var exported by hack/build-flags.sh
local ld_flags="${KN_BUILD_LD_FLAGS:-}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An empty default doesn't work well because then you would have a -ldflags without value to the option which will very likely lead to an error. IMO you could directly use KN_BUILD_FLAGS and commit ld_flags.

Or use something like

Suggested change
local ld_flags="${KN_BUILD_LD_FLAGS:-}"
local ld_flags="-ldflags ${KN_BUILD_LD_FLAGS:-}"

and then just add $ld_flags below, that should also then work with an empty env var.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposal doesn't work smoothly with our date value and quoting. On the other hand I've tested with great success that empty flags from KN_BUILD_LD_FLAGS doesn't break the build or produce any error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so let's go with the original approach if this is no problem.

/approve
/lgtm


export GO111MODULE=on
export CGO_ENABLED=0
echo "🚧 🐧 Building for Linux (amd64)"
GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-amd64 ./cmd/...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-amd64 ./cmd/...
GOOS=linux GOARCH=amd64 go build -mod=vendor ${ld_flags} -o ./kn-linux-amd64 ./cmd/...

basedir=$(basedir)
ld_flags="$(build_flags $basedir)"
# Env var exported by hack/build-flags.sh
local ld_flags="${KN_BUILD_LD_FLAGS:-}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment below on how to deal with an empty default.

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 29, 2022
@knative-prow
Copy link

knative-prow bot commented Apr 29, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, rhuss

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhuss
Copy link
Contributor

rhuss commented Apr 29, 2022

/retest

1 similar comment
@dsimansk
Copy link
Contributor Author

/retest

@knative-prow knative-prow bot merged commit bcd18d3 into knative:main Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants