Commit Graph

123 Commits

Author SHA1 Message Date
Richard Marshall
ed3c29be12 Simplify name reference candidate resmap building
This patch removes a layer of looping in the name reference candiate
resmap building process by not checking if the resources already exist
in the new resmap.
2019-07-30 17:15:15 -07:00
Richard Marshall
963913f9ef Automatically anchor resource selector patterns 2019-07-29 17:57:33 -07:00
Jerome Brette
230090d790 Fix namereference and stacked kustomization contexts (3/3)
- Update unit and integration tests.
2019-07-24 18:02:29 +00:00
Jerome Brette
8fa3861ba3 Fix namereference and stacked kustomization contexts (2/3)
- Leverage nameprefix and namesuffix contextual data
2019-07-24 18:02:23 +00:00
Jerome Brette
579995dc8a Address simultaneous transformation of name and namespace
Namereference handler needs to address simulatenous change of
name and namespace in ClusterRoleBinding for instance.
2019-07-16 18:17:33 -05:00
jingfangliu
eeed1954fb include nameprefix and namesuffix to find matched reference for cluster level kinds 2019-07-12 10:27:02 -07:00
Jingfang Liu
31ab347da2 refactor the strategic merge patch transformer toward moving it to a plugin (#1340) 2019-07-11 10:22:56 -07:00
Jeffrey Regan
0fe95a2f74 Add another resmap test. 2019-07-01 11:17:46 -07:00
Jeff Regan
58faa762cb Merge pull request #1275 from Liujingfang1/patches
add function to find all matched patch targets
2019-06-29 09:36:53 -07:00
jingfangliu
349cfff1cb add function to find all matched patch targets 2019-06-28 17:12:02 -07:00
Jeffrey Regan
a60d99fdc9 Fix 972 2019-06-27 17:37:12 -07:00
Jeffrey Regan
07e5a544fe Delete deprecated GetById 2019-06-27 15:26:03 -07:00
Jeffrey Regan
877e9ecf64 Fix some minor nits around namespace code. 2019-06-26 10:02:22 -07:00
Jerome Brette
4272611593 Change key used sort "not namespaceable objects.
- Use "%no_namespace% instead of "cluster-wide"
- Ensure will be no conflict with a kubernetes valid namespace name.
2019-06-25 17:04:55 -05:00
Jerome Brette
74f5e74b89 Consolidate IsClusterKind and IsNamespaceableKind method to avoid duplication 2019-06-25 13:46:49 -05:00
Jerome Brette
2bba0a6aa3 Support for ConfigMap generator with identical names in different namespaces.
- Attempt to account, at build time, for subsequent kubectl apply behavior.
  (empty or no namespace means default).
- Account for the fact that not all objects have a namespace.
- Add new Equal method to ResId address merge name conflict
- Add GroupByName to resources by namespaces to resolve filenames conflict
- Added corresponding unit tests.
- Change the fail test for issue #1155
2019-06-25 13:39:32 -05:00
jregan
a7df00c07a Starting v3 release for plugin developers.
[doc]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

Per this Go modules [doc] a repo or branch that's
already tagged v2 or higher should increment the major
version (e.g. go to v3) when releasing their first Go
module-based packages.

At the moment, the kustomize repo has these top level
packages in the sigs.k8s.io/kustomize module:

 - `cmd` - holds main program for kustomize

	 Conceivably someone can depend on this
	 package for integration tests.

 - `internal` - intentionally unreleased subpackages

 - `k8sdeps` - an adapter wrapping k8s dependencies

	 This exists only for use in pre-Go-modules kustomize-into-kubectl
	 integration and won't live much longer (as everything involved is
	 switching to Go modules).

 - `pkg` - kustomize packages for export

	 This should shrink in later versions, since
	 the surface area is too large, containing
	 sub-packages that should be in 'internal'.

 - `plugin` - holds main programs for plugins

This PR changes the top level go.mod file from

```
module sigs.k8s.io/kustomize
```

to

```
module sigs.k8s.io/kustomize/v3
```

and adjusts all import statements to
reflect the change.
2019-06-23 15:05:59 -07:00
Jeffrey Regan
2eccf67b1c Push namespace transformer code to plugin. 2019-06-19 12:57:02 -07:00
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
Jeffrey Regan
8d9897d5a5 Add the rmBuilder test helper. 2019-06-13 16:15:43 -07:00
jregan
755dd3d024 Add some utilities. 2019-06-12 20:43:39 -07:00
Jeffrey Regan
5e054c9d31 Add originalName field to resource. 2019-06-12 16:30:03 -07:00
Jeffrey Regan
9c36ac28fa Improve comments in name transform code. 2019-06-10 16:58:16 -07:00
Jeffrey Regan
449175e3a6 Add a sorting plugin. 2019-06-07 15:06:12 -07:00
jregan
0e4f9acb6e Rename ErrorIfNotEqual to ErrorIfNotEqualSets 2019-06-06 20:20:48 -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
jregan
47c965481f Reduce k8ds deps 2019-05-27 15:37:03 -07:00
jregan
fe67bcdb8b Cut more ties to k8sdeps
Add tests for all the plugins.
2019-05-22 14:17:36 -07:00
Jeffrey Regan
9a4cb6c991 Delete unused code. 2019-05-13 12:15:30 -07:00
Yujun Zhang
e079c20ceb Fix typo 2019-05-13 16:46:41 +08:00
Jeffrey Regan
2e71a3b862 Convert plugins to accept bytes instead of unstruct. 2019-05-12 12:58:56 -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
rohitsardesai83
b67d713bc0 Remove dependency on ghodss/yaml 2019-04-25 23:47:01 +05:30
Jeffrey Regan
8991bcb399 Collect existing internal pkgs under one roof. 2019-04-23 11:53:50 -07:00
jregan
9a85071085 Delete kustomizationerror.
Do a longstanding TODO to remove kustomizationerror.

It wasn't used much, and it wasn't used consistently,
because it's complicated to decided when it's worth
proceeding to accumulate errors when one already knows
that one has a fatal error in the kustomization.  Its
use was blocking refactoring for simplicity and making
tests harder to write.

Removing it lets us reinstate the cyclomatic complexity
check in KustTarget.

Also added more info to the affected error messages.
2019-04-21 16:10:58 -07:00
jregan
c06b95077d Secret/configmap factory cleanup. 2019-03-15 09:25:59 -07:00
jregan
6bfd7cff72 Improve error handling during var resolution. 2019-02-26 14:05:38 -08:00
jregan
d4d993a53c Add more resid test coverage. 2019-02-16 14:26:43 -08:00
Jingfang Liu
84057436d6 Combine generatorArgs and generatorOptions into options of Resource 2019-01-31 15:32:32 -08:00
Jeffrey Regan
c21dfefbdf Cover CleanedAbs 2019-01-25 12:21:03 -08:00
jregan
d141b2421c DataSources is now common to Secrets and ConfigMaps. 2019-01-22 18:57:11 -08:00
Kubernetes Prow Robot
bfd61a7605 Merge pull request #699 from Liujingfang1/fix657
Allow namespaced object to refer cluster level object
2019-01-17 14:04:47 -08:00
Jingfang Liu
f7c34ccb52 Remove filesystem from ConfigMapGenerator and SecretGenerator 2019-01-16 13:33:06 -08:00
Jingfang Liu
2fa4a34589 replace commands/envcommand by DataSource in SecretGenerator 2019-01-16 11:17:34 -08:00
Jingfang Liu
38f0ca9f03 Allow namespaced object to refer cluster level object 2019-01-14 15:54:09 -08:00