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

Switch build target from main.go to a package. #8342

Merged
merged 2 commits into from
Oct 12, 2023
Merged

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Sep 12, 2023

Proposed Changes

This changes the way go embeds versions in the binary. Today, Grype can't determine which k3s version is used in k3s itself because it's built with the file. Here's what a scan looks like:

NAME                   INSTALLED  FIXED-IN  TYPE       VULNERABILITY        SEVERITY
github.com/k3s-io/k3s  (devel)    1.24.17   go-module  GHSA-m4hf-6vgr-75r2  High

If you make this switch, the scanner can correctly determine the version instead of (devel).

Types of Changes

Bugfix

Verification

Build k3s and scan it.

Testing

Linked Issues

User-Facing Change


Further Comments

@brandond
Copy link
Contributor

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

In order to reduce the size of the build container, builds are run without access to the full contents of the .git dir. This prevents golang from being able to determine VCS stamps. We should probably add -buildvcs=false since we're injecting the versions and commits by hand anyway.

cc @dereknola

@dereknola
Copy link
Contributor

👀 I am in support of building without the VCS.

@brandond
Copy link
Contributor

@dlorenc are you up for adding that build flag to this PR?

dlorenc and others added 2 commits October 9, 2023 13:35
This changes the way go embeds versions in the binary. Today, Grype
can't determine which k3s version is used in k3s itself because it's built
with the file. Here's what a scan looks like:

```
NAME                   INSTALLED  FIXED-IN  TYPE       VULNERABILITY        SEVERITY
github.com/k3s-io/k3s  (devel)    1.24.17   go-module  GHSA-m4hf-6vgr-75r2  High
```

If you make this switch, the scanner can correctly determine the version instead of (devel).

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (dface01) 19.55% compared to head (8ee3607) 51.18%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #8342       +/-   ##
===========================================
+ Coverage   19.55%   51.18%   +31.62%     
===========================================
  Files          84      144       +60     
  Lines        7904    14964     +7060     
===========================================
+ Hits         1546     7660     +6114     
+ Misses       6123     6093       -30     
- Partials      235     1211      +976     
Flag Coverage Δ
e2etests 48.51% <ø> (?)
inttests 44.34% <ø> (?)
unittests 19.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 120 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brandond brandond merged commit 3d25e9f into k3s-io:master Oct 12, 2023
15 checks passed
brandond pushed a commit to brandond/k3s that referenced this pull request Oct 12, 2023
* Switch build target from main.go to a package.
* Dont build with vcs

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 3d25e9f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit to brandond/k3s that referenced this pull request Oct 12, 2023
* Switch build target from main.go to a package.
* Dont build with vcs

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 3d25e9f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit to brandond/k3s that referenced this pull request Oct 12, 2023
* Switch build target from main.go to a package.
* Dont build with vcs

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 3d25e9f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit to brandond/k3s that referenced this pull request Oct 13, 2023
* Switch build target from main.go to a package.
* Dont build with vcs

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 3d25e9f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit that referenced this pull request Oct 13, 2023
* Switch build target from main.go to a package.
* Dont build with vcs

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 3d25e9f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit that referenced this pull request Oct 13, 2023
* Switch build target from main.go to a package.
* Dont build with vcs

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 3d25e9f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit that referenced this pull request Oct 13, 2023
* Switch build target from main.go to a package.
* Dont build with vcs

Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 3d25e9f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants