1
0
mirror of https://github.com/coreos/ignition.git synced 2026-02-07 03:47:55 +01:00
Commit Graph

50 Commits

Author SHA1 Message Date
yasminvalim
de452c404c fix: Handle unchecked error returns across the codebase and other linter issues
The linter found staticcheck and errorcheck issues.  Deferred statements now  use join  to combine any new error with an existing one, preventing error information from being lost. Other minor error checks, like for printing text  and flushing data have also been addressed.
2025-07-28 19:12:25 -03:00
Sohan Kunkerkar
548c250ce7 *: fix gosimple warnings
Fixes part of https://github.com/coreos/ignition/issues/1121
2020-12-07 18:14:58 -05:00
Andrew Jeddeloh
eea4ec6b4f vendor: switch to coreos/vcontext
Switch from ajeddeloh/vcontext to coreos/vcontext since the repo has
moved.
2019-05-29 13:26:14 -07:00
Andrew Jeddeloh
9f6ea4f114 config/validate: add tests for duplicate checking 2019-05-24 14:00:14 -07:00
Andrew Jeddeloh
fb80d911aa config/validate: add test for validation 2019-05-24 11:28:28 -07:00
Andrew Jeddeloh
f39477bcfb config/validate: check for unused keys 2019-05-24 11:28:28 -07:00
Andrew Jeddeloh
3048e395b7 config/validate: replace old validation with vcontext 2019-05-24 11:28:28 -07:00
Stephen Lowrie
bb6182a393 *: bump import path
Bumps the import path to be `github.com/coreos/ignition/v2`, this is
required to be able to import the v2 of Ignition alongside v0 in other
repositories.
2019-04-09 12:40:08 -05:00
Andrew Jeddeloh
ca84f7ee8e *: stablize spec 3.0.0
Make 3.0.0-experimental into 3.0.0.
2019-03-25 14:38:23 -07:00
Andrew Jeddeloh
8336146c7e config/types: de-pointer config.ignition.replace
Make this not a pointer, make source a pointer instead.
2019-03-25 10:42:01 -07:00
Andrew Jeddeloh
cd90b7b45e config: replace config appending with merging
Replace the old Append() function with Merge(). Merging will merge
duplicate entries in lists or, in the case of files/dirs/links across
those lists.
2019-03-25 10:39:44 -07:00
Andrew Jeddeloh
999b6c1709 config: rework schema for better merging
Rework the schema to have all leaf fields be pointer except keys and all
interior nodes not be pointers.

This allows child configs to distinguish between an unspecified field
and a field specified as the go zero value.

This includes making storage.files.contents a normal (non pointer)
struct but making all of its members pointers. Similarly,
storage.files.{user,group} are no longer pointers but
storage.files.{user,group}.name are now pointers.

Finally, convert validation logic to use report.AddOnError() and friends
where appropriate.
2019-03-21 11:00:01 -07:00
Andrew Jeddeloh
df27af3d4a config/validate: allow dups on some fields
Certain fields it makes sense to allow duplicates, like ones where there
are args being passed to a utility program. Allow exempting lists for
duplicate checking and exempt file appends, raid options and fs creation
options.
2019-03-19 11:55:34 -07:00
Andrew Jeddeloh
d7f0a55418 config/validate_test: add tests for detecting dups
Add tests to check the duplicate detection.
2019-03-19 11:55:34 -07:00
Andrew Jeddeloh
01c01db41f config/validate: validate no duplicates exist
Check that no duplicates exist in the config's lists. Check that
files/link/dirs don't have duplicates across lists

There is a special case here: lists of strings implicitly use the string
as its Key(). This is just a shortcut, we can drop it later if we need
to in favor of explicit Key() functions.
2019-03-19 11:54:17 -07:00
Andrew Jeddeloh
de4ba6e504 config: refactor
- config package should have a Parse() function that accepts any
 supported version of the config
 - each version package (i.e. config/v3_0_experimental) should only
 accept configs of that version
 - In the future translation code should be its own subpackage to each
 config version package (i.e. under config/vX_Y/translate)
 - In the future the config package should handle calling the
 translation code explicitly instead of each version package. This
 removes the need to vendor more than 1 version if that's all you need.
2019-03-15 14:24:16 -07:00
Andrew Jeddeloh
5fd51005bf exec/*: rework files and filesystems
- Remove filesystem names, make path be the mount path to use in the
 initramfs
 - Simplify symlink handling now that everything is under /sysroot
 - Update unit tests
2019-02-22 10:39:22 -08:00
Andrew Jeddeloh
4009252cf7 validate/report: add helpers to cut verbosity
Create Add{Error,Warning,Info,Deprecated}() functions to wrap errors and
add the appropriate entries.
2019-02-21 12:53:54 -08:00
Andrew Jeddeloh
19ab524149 config: replace go4's errorutil with own impl
go4.org's errorutil doesn't handle tabs correctly. It also takes a
io.Reader which meant we had to constantly wrap our byte slices. Replace
it with our own implementation that accepts a []byte and replaces tabs
with spaces.
2019-02-15 13:27:18 -08:00
Andrew Jeddeloh
b50fb6557d config: rip out all v1, v2.x configs 2019-01-08 11:40:33 -08:00
Andrew Jeddeloh
a94595af25 config: replace v2_4 with v3_0_exp 2019-01-03 12:53:25 -08:00
Andrew Jeddeloh
49d4c7277d *: switch packages to use new experimental package 2018-11-27 13:56:03 -08:00
Derek Gonyeo
9860289067 config: add highlight to reports from calling validate functions
Highlights (the source snippet of where a report comes from) weren't
being added to reports that came from Validate or ValidateFoo functions.
2018-03-21 12:00:48 -07:00
Derek Gonyeo
bb678ecfac config: modify v2_3_exp/types to use errors from config/shared/errors
config/validate/validate_test.go depends on errors from
config/v2_3_experimental/types, so also update that to use the new error
values.
2018-03-20 10:14:09 -07:00
Euan Kemp
2699886b1b config/errors: move under 'shared'
Since more than just errors are shared between multiple config versions,
let's collect all the things under 'shared'
2018-03-20 00:02:56 -07:00
Euan Kemp
3a05240202 config/*: add systemd install section warning
This adds a warning to all config versions for an enabled unit with no
install section.

In general, any unit that has contents, is enabled, but has no install
section is useless.
It's unlikely a user intends to ever write such a unit, even if
technically the install section could be in a drop-in.

To avoid duplication, this also introduces a new 'shared' package under
'config'
2018-03-20 00:02:56 -07:00
Euan Kemp
bdc7403dc6 util: move validate function to 'validate' package
Having 'util' import 'validate' makes it very easy to hit import cycles,
e.g. if you try to use a 'util' helper function in validate or validate
tests.

Validation seems like it fits better in the validate package anyways.
2018-03-20 00:02:56 -07:00
Derek Gonyeo
511a2430ef config/validate: test fixup for new package location
The location of the latest package has changed. Update the test in
config/validate to point to the new location.
2018-03-08 16:03:11 -08:00
Derek Gonyeo
ab34ef755b config: accept 2.2.0 and 2.3.0-experimental, refuse 2.2.0-experimental
Make the necessary changes to config package to accept 2.2.0 and
2.3.0-experimental configs, and to error out on 2.2.0-experimental
configs.
2018-02-06 14:44:43 -08:00
Andrew Jeddeloh
d952891290 config/validate: add tests line/col info
Add tests to ensure line/col info are generated properly, especially
with embedded structs and Validate<NAME>() functions.
2017-09-19 15:39:07 -07:00
Andrew Jeddeloh
944b5bb701 config/validate: move astnode into its own package
This is needed to prevent cyclic dependencies for tests.
2017-09-19 15:39:07 -07:00
Andrew Jeddeloh
5e92b68a1c config/validate: report better line/col info
When Ignition switched to using a json schema the validation logic
changed slightly to allow Validate<FieldName>() functions to be called
as well. Ignition did not try to get the corrosponding ast node for that
field. This lets Ignition try to get the corrosponding ast node.
2017-09-19 15:39:07 -07:00
Andrew Jeddeloh
a63367df6c validate: add option to omit unused keys warnings
Add option to not generate unused key warnings. This is used for clct to
validate the portions where the configurations are the same but not warn
about the addition entries in the clct configuration.
2017-06-20 17:44:19 -04:00
Derek Gonyeo
4d83b34202 config: generate golang structs from schema, associated refactor
This commit refactors the codebase to use the included generate script
and json-schema file in the prior commit.
2017-04-11 16:54:54 +02:00
Andrew Jeddeloh
3de34c5fbb tests: add test for getfields() 2017-02-28 10:28:20 -08:00
Andrew Jeddeloh
18ead0188a valdiate: ensure getfields works with interface{}
Ensure getFields() will correctly unbox an embedded interface{} that
actually contains a struct type. This is used in the config transpiler.
2017-02-28 12:07:00 -05:00
Alex Crawford
9f7a25b2a7 config/*: correct unit validation logic
It is valid for a unit to be empty.
2017-02-27 15:47:50 -08:00
Alex Crawford
95f018b7cd Merge branch master into spec 2017-01-20 13:26:02 -08:00
Máximo Cuadros
e97c33c4c2 types: unit validator 2017-01-17 22:50:44 +01:00
Alex Crawford
8186643862 Merge branch master into spec 2016-11-30 15:31:28 -08:00
Andrew Jeddeloh
3ffd793b12 validation: make validate function more general
Make validate more general so it can be used by fuze as well.
2016-10-18 21:09:46 -04:00
Alex Crawford
4d44fa4d14 config/validate: change to accept interface
Since this is going to validate multiple versions of the config, it will
need to be able to accept different structs.
2016-08-10 17:39:30 -07:00
Andrew Jeddeloh
da4506d735 validate: fix bug with embedded structs
Treat members of embedded structs as you own when validating.
2016-08-10 16:25:26 -07:00
Andrew Jeddeloh
cbf3871bbe config: change assertvalid to validate
Rename AssertValid to Validate and make it return a report
2016-08-10 14:35:10 -07:00
Andrew Jeddeloh
6635cdfd10 validate/report: change addlines to addposition
Make AddPosition also apply column info
Also remove dead code in Less() function
2016-08-09 16:19:51 -07:00
Andrew Jeddeloh
9d9f378cae validate: fix incorrect line number reporting
Make unknown line numbers default to the last known line number instead
of line 1.
2016-08-09 13:23:04 -07:00
Andrew Jeddeloh
2896c028af tests: move types/config_test to validate package 2016-08-08 17:57:33 -07:00
Andrew Jeddeloh
2c637c707e config/validate: add whole-config checks 2016-08-08 17:57:33 -07:00
Andrew Jeddeloh
e9f737f6f3 config: move validation logic to validation pkg
Move all the validation logic to validation package.
Change validation to build report instead of returning a single error
2016-08-08 17:57:32 -07:00
Andrew Jeddeloh
d207af95b2 config/validate: add reporting structure 2016-08-08 16:51:23 -07:00