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

Feat: add cue strategyUnify provider #70

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

yangsoon
Copy link
Contributor

Thie PR add strategyUnify provider for user to strategy patch the cue Value, The signatures of the strategyUnify provider are as follows:

#StrategyUnify: {
	#do:       "strategyUnify"
	#provider: "cue"

	// +usage=The params of this action
	$params: {
		value: {...}
		patch: {...}
	}

	// +usage=The result of this action
	$returns: {...}
}

The $params.value represents the original object to be patched,$params.patch describe patch action, The behavior of $params.patch is consistent with that of patch in TraitDefinition, So you can describes patch behavior strategically with tags patchKey or patchStrategy.

A simple example is as follows:

import "vela/cue"
patch: cue.#StrategyUnify & {
	$params: {
		value: {
			containers: [{
				name: "x1"
			}, {
				name:  "x2"
				image: "redis:latest"
			}]
		}
		patch: {
			// +patchKey=name
			containers: [{
				name: "x2"
				// +patchStrategy=retainKeys
				image: "nginx:latest"
			}]
		}
	}
}

==> after  compiler

patch: cue.#StrategyUnify & {
	$params: {
         ...
	}
	$returns: {
		// +patchKey=name
		containers: [{
			name: "x1"
		}, {
			name: "x2"
			// +patchStrategy=retainKeys
			image: "nginx:latest"
		}]
	}
}

@codecov
Copy link

codecov bot commented Mar 30, 2023

Codecov Report

Patch coverage: 71.61% and project coverage change: -3.96 ⚠️

Comparison is base (d7022ea) 90.27% compared to head (b6c45af) 86.31%.

❗ Current head b6c45af differs from pull request most recent head 5cc41bd. Consider uploading reports for the commit 5cc41bd to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
- Coverage   90.27%   86.31%   -3.96%     
==========================================
  Files          68       72       +4     
  Lines        2529     3209     +680     
==========================================
+ Hits         2283     2770     +487     
- Misses        179      333     +154     
- Partials       67      106      +39     
Flag Coverage Δ
unit-test 86.31% <71.61%> (-3.96%) ⬇️

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

Impacted Files Coverage Δ
cue/cuex/model/sets/walk.go 62.63% <62.63%> (ø)
cue/cuex/providers/cue/cue.go 66.66% <66.66%> (ø)
cue/cuex/model/sets/operation.go 72.72% <72.72%> (ø)
cue/cuex/model/sets/utils.go 73.35% <73.35%> (ø)
cue/cuex/compiler.go 83.19% <100.00%> (+0.14%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@FogDong FogDong left a comment

Choose a reason for hiding this comment

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

It would be nice if we can add more tests to cover the code, generally LGTM, great job!

@yangsoon yangsoon force-pushed the cue-patch-provider branch 3 times, most recently from 88ee339 to a7cbea4 Compare March 30, 2023 08:17
Signed-off-by: yangsoon <songyang.song@alibaba-inc.com>
@Somefive Somefive merged commit 10542b1 into kubevela:main Mar 30, 2023
@yangsoon yangsoon deleted the cue-patch-provider branch March 30, 2023 08:36
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.

None yet

3 participants