642 Commits

Author SHA1 Message Date
Jeffrey Regan
3a01a63a01 Simplify code base.
- In ResMap, drop concept of internal Id to Resource
   map.  The ResMap is now (just) a list, allowing only
   very particular edits.

 - Resources should now be maintained in the order
   loaded.  A later PR can adjust tests to remove the
   internal legacy sorting, and confirm order-out is
   predictable from order-in.  The PR would suppress
   the sort in tests, and reorder the output to make
   all tests pass again, and confirm that the new order
   matched depth-first input traversal.  The FromMap
   fixture function was removed from all test inputs to
   establish a predictable input order.

 - Resources now have two 'Ids', OriginalId and
   CurrentId.  The former is fixed as
   GVK-name-namespace at load time, the latter changes
   during transformations.  The latter can be used to
   narrow name references when the former maps to
   multiple resources.  We allow bases to be loaded
   more than once in a build (a diamond pattern), so
   the OriginalId is not unique across the resources
   set.  The CurrentId is (and must be) unique, but is
   constantly mutating.  Failing to make this
   distinction clear, and attempting to maintain a
   mapping from a single mutating Id to a resource was
   making the code too complex.

 - Drop prefix/suffix from ResId - the ResId is now
   immutable.  A later PR can remove the distinction
   with ItemId.

 - This PR increases coverage of ResMap is since this
   is a large refactor.  Higher level tests didn't need
   much change outside reordering of results at the
   resource level.
2019-06-17 10:50:45 -07:00
jregan
08b6f6f4e4 Update golinter to 1.17.1 2019-06-12 20:33:07 -07:00
jregan
11bb176a3f Push suffix/prefix code to plugin. 2019-06-11 19:37:06 -07:00
jregan
49d94f5318 Rename the prefix/suffix transformer. 2019-06-11 17:47:23 -07:00
Jeffrey Regan
0fa2d9c32c Add --reorder flag. 2019-06-11 12:52:53 -07:00
Jeffrey Regan
6d309b52a5 Introduce stacked transformers. 2019-06-07 16:16:58 -07:00
Jeffrey Regan
449175e3a6 Add a sorting plugin. 2019-06-07 15:06:12 -07:00
Jeffrey Regan
c63ebbdfc4 Preserve order when merging. 2019-06-06 20:01:39 -07:00
Jeffrey Regan
4162dbc2d8 Maintain resources in order loaded. 2019-06-06 15:55:57 -07:00
Jeffrey Regan
81c98c855f Convert inventory transformer to plugin, reduce k8sdeps. 2019-06-02 10:49:01 -07:00
Damien Robichaud
d4842ebd90 Cleanup the replica plugin implementation. 2019-05-31 13:28:51 -07:00
Damien Robichaud
5000a2e503 Implement replica transformer as patch alternative 2019-05-31 13:10:34 -07:00
Jeff Regan
ab3fed06c7 Merge pull request #1112 from Liujingfang1/validator
add validation transformer
2019-05-30 13:38:18 -07:00
Jingfang Liu
b4dbac1b84 add validation transformer 2019-05-30 10:10:16 -07:00
Jeffrey Regan
fd2248e7c2 Move hashing transformer out of k8sdeps. 2019-05-29 13:51:41 -07:00
Jeffrey Regan
ca478016c9 Update minecraft version in example. 2019-05-28 18:32:23 -07:00
jregan
47c965481f Reduce k8ds deps 2019-05-27 15:37:03 -07:00
jregan
78cdff6d09 Remove kv plugins from docs. 2019-05-22 21:13:45 -07:00
jregan
fe67bcdb8b Cut more ties to k8sdeps
Add tests for all the plugins.
2019-05-22 14:17:36 -07:00
Jeff Regan
f864c912ad Merge pull request #1101 from monopole/breakDeps
Break a bad dep.
2019-05-22 07:48:51 -07:00
Jeffrey Regan
b28aaae66b Break a bad dep. 2019-05-22 07:39:36 -07:00
Jeffrey Regan
79906d73d0 Add builtin namespace transformer plugin 2019-05-21 13:56:36 -07:00
Jeffrey Regan
9b6f8f0c74 Format generated code. 2019-05-21 11:35:41 -07:00
Jeffrey Regan
0df5883853 Add builtin JSON patch transformer 2019-05-20 15:38:46 -07:00
jregan
aafc23a615 Add annotation transformer. 2019-05-19 19:04:29 -07:00
jregan
45901219b7 Add builtin label transformer. 2019-05-19 18:20:18 -07:00
jregan
5653ae69e4 One plugin per dir. 2019-05-19 17:32:02 -07:00
Jeffrey Regan
3a85fcd365 Simplify some of the plugin testing code. 2019-05-17 16:13:55 -07:00
Jeffrey Regan
621bb7c6c5 Add builtin NameTransformer plugin. 2019-05-16 12:34:08 -07:00
Jeffrey Regan
939de0cdbe Dogfood the plugin framework.
This PR:

* provides a code generator that converts
  kustomize Go plugins to normal code, i.e.
  the plugin appears as
    t := builtin.NewImageTagTransformer()
  instead of
    p := plugin.Open("imagetagtransformer.so")
    s := p.Lookup(someSymbol)
    t, ok = s.(Transformer)

* converts the main processing thread in
  kusttarget.go to use those factory calls to run
  builtin generators and transformer before
  calling user-supplied plugins,

* as an example, provides an imagetag transformer
  plugin, converting a legacy transformer to
  builtin plugin form with its own isolated test.
  This test can be expanded by moving more code
  into it, but that can be done in a later PR.

Writing core functionality as plugins assures a
maintained plugin authoring and testing framework,
assures modularity, provides meaningful plugin
examples, and gives us a means to make informed
choices on which kustomize packages to publish
(and which to move to internal/).  The code
generator allows all this without losing "go get
sigs.k8s.io/kustomize" functionality.

TODO:

  1) Convert remaining legacy transformers to
     plugins (patch SMP/JSON, name prefix/suffix,
     labels/annos) with their own tests.  The
     generators are already done; this PR wires
     them up, and all tests & examples pass.

  2) Push code down into the plugins, as the first
     pass at conversion writes plugins as thin
     layers over calls into code under the mess
     that is pkg/.  Once this is done, we can
     reasonably move all the packages that aren't
     imported by plugins to internal/.

This PR could be split in two, one to merge the
the generator, and the second to merge the
ImageTagTransformer plugin and its wiring into the
main flow.

The latter PR could then serve as an example for
converting the remaining transformers.
2019-05-16 10:07:28 -07:00
Kubernetes Prow Robot
c6476d16e7 Upgrade version of minecraft used in tests. 2019-05-16 10:06:24 -07:00
Jeffrey Regan
5614649d14 Standalone service generator test 2019-05-13 12:30:51 -07:00
Jeffrey Regan
44ac9a9f44 Standalone ChartInflator plugin test. 2019-05-13 11:42:31 -07:00
Jeffrey Regan
2e71a3b862 Convert plugins to accept bytes instead of unstruct. 2019-05-12 12:58:56 -07:00
jregan
4df576869f Add SedTransformerTest 2019-05-12 11:32:33 -07:00
Jingfang Liu
61d46c26b8 fix the boilerplate copyright header (#1064) 2019-05-10 10:20:20 -07:00
Jeffrey Regan
7295a9b32e Fix some nits. 2019-05-07 17:56:48 -07:00
Jeffrey Regan
2d70526eab Add ConfigMapGenerator and test. 2019-05-07 17:25:43 -07:00
Jeffrey Regan
2825888ffd Add test for builtin secretgenerator plugin. 2019-05-07 16:16:07 -07:00
Jeffrey Regan
529db0493b Introduce envs field. 2019-05-06 14:35:48 -07:00
Jeffrey Regan
cd9572e0bb hey 2019-04-26 15:48:41 -07:00
jregan
cfb0c5efad Make plugin dir match Go conventions. 2019-04-25 20:30:10 -07:00