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

Switch to use internal diff package #697

Merged
merged 3 commits into from
Aug 26, 2020
Merged

Switch to use internal diff package #697

merged 3 commits into from
Aug 26, 2020

Conversation

nghialv
Copy link
Member

@nghialv nghialv commented Aug 26, 2020

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

/cc @nakabonne

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

result_test.go
--- pkg/app/piped/diff/result_test.go.orig
+++ pkg/app/piped/diff/result_test.go
@@ -22,7 +22,7 @@
 
 func TestFindOne(t *testing.T) {
 	nodes := []Node{
-		Node{PathString: "spec.template.spec"},
+		{PathString: "spec.template.spec"},
 	}
 
 	testcases := []struct {
@@ -62,9 +62,9 @@
 
 func TestFind(t *testing.T) {
 	nodes := []Node{
-		Node{PathString: "spec.replicas"},
-		Node{PathString: "spec.template.spec.containers.0.image"},
-		Node{PathString: "spec.template.spec.containers.1.image"},
+		{PathString: "spec.replicas"},
+		{PathString: "spec.template.spec.containers.0.image"},
+		{PathString: "spec.template.spec.containers.1.image"},
 	}
 
 	testcases := []struct {

@nghialv
Copy link
Member Author

nghialv commented Aug 26, 2020

/golinter fmt

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 20.93%. This pull request decreases coverage by -0.43%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/manifest.go Diff -- 0.00% +0.00%
pkg/app/piped/diff/renderer.go WithLeftPadding -- 100.00% +100.00%
pkg/app/piped/diff/renderer.go WithRedactPath -- 0.00% +0.00%
pkg/app/piped/diff/renderer.go NewRenderer -- 100.00% +100.00%
pkg/app/piped/diff/renderer.go Renderer.Render -- 95.83% +95.83%
pkg/app/piped/diff/renderer.go pathDuplicateDepth -- 100.00% +100.00%
pkg/app/piped/diff/renderer.go renderNodeValue -- 93.94% +93.94%
pkg/app/piped/diff/renderer.go RenderPrimativeValue -- 100.00% +100.00%
pkg/app/piped/diff/result.go Result.NumNodes -- 100.00% +100.00%
pkg/app/piped/diff/result.go Result.Nodes -- 100.00% +100.00%
pkg/app/piped/diff/result.go Node.StringX -- 0.00% +0.00%
pkg/app/piped/diff/result.go Node.StringY -- 0.00% +0.00%
pkg/app/piped/diff/result.go Nodes.FindOne -- 88.89% +88.89%
pkg/app/piped/diff/result.go Nodes.Find -- 90.00% +90.00%
pkg/app/piped/diff/result.go Nodes.FindByPrefix -- 0.00% +0.00%
pkg/app/piped/driftdetector/kubernetes/detector.go detector.checkApplication 0.00% 0.00% +0.00%
pkg/app/piped/driftdetector/kubernetes/detector.go makeOutOfSyncState 0.00% 0.00% +0.00%
pkg/app/piped/planner/kubernetes/kubernetes.go decideStrategy 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffPathPrefix 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffIgnoreOrder 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffIgnoreMissingFields 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffRedactPathPrefix 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffPath.String 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go parseDiffPath 91.67% -- -91.67%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResult.String 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.Find 88.89% -- -88.89%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.FindAll 88.89% -- -88.89%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.FindByPrefix 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.String 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffWorkload 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go Diff 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffManifests 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.PushStep 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.Report 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.PopStep 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.String 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go convertDiffPath 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go sortLess 25.00% -- -25.00%
pkg/app/piped/diff/result.go Result.SetLeftPadding 100.00% -- -100.00%
pkg/app/piped/diff/result.go Result.SetRedactPath 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.Num 100.00% -- -100.00%
pkg/app/piped/diff/result.go Result.Find 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.FindAll 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.FindByPrefix 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.DiffString 95.83% -- -95.83%
pkg/app/piped/diff/result.go pathDuplicateDepth 100.00% -- -100.00%
pkg/app/piped/diff/result.go PrintNodeValue 100.00% -- -100.00%
pkg/app/piped/diff/result.go printNodeValue 93.94% -- -93.94%

case reflect.String:
return v.String(), false

case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
Copy link
Member

Choose a reason for hiding this comment

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

Just in case, let me confirm that Uints are unneeded?

Suggested change
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I skipped them because our current algorithm is only for k8s.Unstructured where it contains only simple primitive types such as string, float, int, bool, []interface{}, map[string]interface{}.
But let me add them for using later (maybe).

@nakabonne
Copy link
Member

LGTM with just one question.

@nghialv
Copy link
Member Author

nghialv commented Aug 26, 2020

I have just updated for your reviews.
f6ddb89

@nakabonne
Copy link
Member

Thanks!
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nakabonne.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 20.94%. This pull request decreases coverage by -0.43%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/manifest.go Diff -- 0.00% +0.00%
pkg/app/piped/diff/renderer.go WithLeftPadding -- 100.00% +100.00%
pkg/app/piped/diff/renderer.go WithRedactPath -- 0.00% +0.00%
pkg/app/piped/diff/renderer.go NewRenderer -- 100.00% +100.00%
pkg/app/piped/diff/renderer.go Renderer.Render -- 95.83% +95.83%
pkg/app/piped/diff/renderer.go pathDuplicateDepth -- 100.00% +100.00%
pkg/app/piped/diff/renderer.go renderNodeValue -- 93.94% +93.94%
pkg/app/piped/diff/renderer.go RenderPrimitiveValue -- 100.00% +100.00%
pkg/app/piped/diff/result.go Result.NumNodes -- 100.00% +100.00%
pkg/app/piped/diff/result.go Result.Nodes -- 100.00% +100.00%
pkg/app/piped/diff/result.go Node.StringX -- 0.00% +0.00%
pkg/app/piped/diff/result.go Node.StringY -- 0.00% +0.00%
pkg/app/piped/diff/result.go Nodes.FindOne -- 88.89% +88.89%
pkg/app/piped/diff/result.go Nodes.Find -- 90.00% +90.00%
pkg/app/piped/diff/result.go Nodes.FindByPrefix -- 0.00% +0.00%
pkg/app/piped/driftdetector/kubernetes/detector.go detector.checkApplication 0.00% 0.00% +0.00%
pkg/app/piped/driftdetector/kubernetes/detector.go makeOutOfSyncState 0.00% 0.00% +0.00%
pkg/app/piped/planner/kubernetes/kubernetes.go decideStrategy 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffPathPrefix 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffIgnoreOrder 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffIgnoreMissingFields 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go WithDiffRedactPathPrefix 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffPath.String 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go parseDiffPath 91.67% -- -91.67%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResult.String 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.Find 88.89% -- -88.89%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.FindAll 88.89% -- -88.89%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.FindByPrefix 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffResultList.String 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffWorkload 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go Diff 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go DiffManifests 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.PushStep 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.Report 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.PopStep 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go diffReporter.String 0.00% -- +-0.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go convertDiffPath 100.00% -- -100.00%
pkg/app/piped/cloudprovider/kubernetes/diff.go sortLess 25.00% -- -25.00%
pkg/app/piped/diff/result.go Result.SetLeftPadding 100.00% -- -100.00%
pkg/app/piped/diff/result.go Result.SetRedactPath 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.Num 100.00% -- -100.00%
pkg/app/piped/diff/result.go Result.Find 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.FindAll 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.FindByPrefix 0.00% -- +-0.00%
pkg/app/piped/diff/result.go Result.DiffString 95.83% -- -95.83%
pkg/app/piped/diff/result.go pathDuplicateDepth 100.00% -- -100.00%
pkg/app/piped/diff/result.go PrintNodeValue 100.00% -- -100.00%
pkg/app/piped/diff/result.go printNodeValue 93.94% -- -93.94%

@pipecd-bot pipecd-bot merged commit 4e197ef into master Aug 26, 2020
@pipecd-bot pipecd-bot deleted the diff branch August 26, 2020 07:37
@pipecd-bot
Copy link
Collaborator

TEMPLATE

failed to handle template rule examples

Details
Error: unabled to push rendered files to destination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants