Skip to content

oci: introduce WithSpecFromFile combinator#2479

Merged
dmcgowan merged 1 commit intocontainerd:masterfrom
stevvooe:with-file-combinator
Jul 27, 2018
Merged

oci: introduce WithSpecFromFile combinator#2479
dmcgowan merged 1 commit intocontainerd:masterfrom
stevvooe:with-file-combinator

Conversation

@stevvooe
Copy link
Copy Markdown
Member

We introduce a WithSpecFromFile option combinator to allow creation
simpler creation of OCI specs from a file name. Often used as the first
option in a SpecOpts slice, it simplifies choosing between a local
file and the built-in default.

The code in ctr run has been updated to use the new option, with out
changing the order of operations or functionality present there.

Signed-off-by: Stephen Day [email protected]

@mlaventure
Copy link
Copy Markdown
Contributor

missing some windows counterpart and other linter errors:

oci\spec.go:41:1:warning: exported function ApplyOpts should have comment or be unexported (golint)
oci\spec_opts.go:58:10:warning: undeclared name: populateDefaultSpec (staticcheck)
cmd\ctr\commands\run\run_windows.go:79:13:warning: unused struct field undeclared name: loadSpec (structcheck)
oci\spec_opts.go:58:10:warning: unused struct field undeclared name: populateDefaultSpec (structcheck)
cmd\ctr\commands\run\run_windows.go:79:13:warning: undeclared name: loadSpec (unconvert)
oci\spec_opts.go:58:10:warning: undeclared name: populateDefaultSpec (unconvert)
oci\spec_opts.go:58:10:warning: undeclared name: populateDefaultSpec (unused)
cmd\ctr\commands\run\run_windows.go:79:13:warning: unused variable or constant undeclared name: loadSpec (varcheck)
oci\spec_opts.go:58:10:warning: unused variable or constant undeclared name: populateDefaultSpec (varcheck)

@stevvooe stevvooe force-pushed the with-file-combinator branch from dc1af14 to a09fcd2 Compare July 19, 2018 20:57
Comment thread cmd/ctr/commands/run/run_unix.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps containerd.WithSpec could be made to tolerate a nil for the first argument (in which case it initialises the spec ptr internally with a zero val struct). Saves an, incredibly minor, bit of faff for the caller in these cases.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did explore this, but you'd have to pass in a pointer to the pointer to make this work with nil.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I misread spec as being an actual Spec, but of course its a Opt thing which consumes s in a deferred way. Sorry for the noise.

@stevvooe
Copy link
Copy Markdown
Member Author

Waiting on fix for protobuf output.

@stevvooe stevvooe force-pushed the with-file-combinator branch from a09fcd2 to 4412287 Compare July 26, 2018 22:45
We introduce a WithSpecFromFile option combinator to allow creation
simpler creation of OCI specs from a file name. Often used as the first
option in a `SpecOpts` slice, it simplifies choosing between a local
file and the built-in default.

The code in `ctr run` has been updated to use the new option, with out
changing the order of operations or functionality present there.

Signed-off-by: Stephen Day <[email protected]>
@stevvooe stevvooe force-pushed the with-file-combinator branch from 4412287 to 2a1bd74 Compare July 27, 2018 21:25
@codecov-io
Copy link
Copy Markdown

codecov-io commented Jul 27, 2018

Codecov Report

Merging #2479 into master will increase coverage by 0.26%.
The diff coverage is 75.75%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2479      +/-   ##
=========================================
+ Coverage   44.74%     45%   +0.26%     
=========================================
  Files          93      93              
  Lines        9559    9583      +24     
=========================================
+ Hits         4277    4313      +36     
+ Misses       4589    4575      -14     
- Partials      693     695       +2
Flag Coverage Δ
#linux 49.04% <76.92%> (+0.08%) ⬆️
#windows 41.41% <75.86%> (+0.37%) ⬆️
Impacted Files Coverage Δ
oci/spec_windows.go 100% <100%> (+100%) ⬆️
oci/spec_opts.go 65.06% <66.66%> (+0.44%) ⬆️
oci/spec_unix.go 98.4% <75%> (ø) ⬆️
oci/spec.go 60% <85.71%> (+20%) ⬆️

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 985920c...2a1bd74. Read the comment docs.

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

1 similar comment
@dmcgowan
Copy link
Copy Markdown
Member

LGTM

@dmcgowan dmcgowan merged commit 2ebfba5 into containerd:master Jul 27, 2018
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.

6 participants