argo-cd/pkg/diff/testdata/data.go
Andrii Korotkov 8849c3f30c
fix: Server side diff now works correctly with fields removal (#640)
* fix: Server side diff now works correctly with some fields removal

Helps with https://github.com/argoproj/argo-cd/issues/20792

Removed and modified sets may only contain the fields that changed, not including key fields like "name". This can cause merge to fail, since it expects those fields to be present if they are present in the predicted live.
Fortunately, we can inspect the set and derive the key fields necessary. Then they can be added to the set and used during a merge.
Also, have a new test which fails before the fix, but passes now.

Failure of the new test before the fix
```
            	Error:      	Received unexpected error:
            	            	error removing non config mutations for resource Deployment/nginx-deployment: error reverting webhook removed fields in predicted live resource: .spec.template.spec.containers: element 0: associative list with keys has an element that omits key field "name" (and doesn't have default value)
            	Test:       	TestServerSideDiff/will_test_removing_some_field_with_undoing_changes_done_by_webhook
```

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* Use new version of structured merge diff with a new option

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* Add DCO

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* Try to fix sonar exclusions config

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

---------

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
2024-12-11 15:28:47 -05:00

53 lines
1.3 KiB
Go

package testdata
import _ "embed"
var (
//go:embed smd-service-config.yaml
ServiceConfigYAML string
//go:embed smd-service-live.yaml
ServiceLiveYAML string
//go:embed smd-service-config-2-ports.yaml
ServiceConfigWith2Ports string
//go:embed smd-service-live-with-type.yaml
LiveServiceWithTypeYAML string
//go:embed smd-service-config-ports.yaml
ServiceConfigWithSamePortsYAML string
//go:embed smd-deploy-live.yaml
DeploymentLiveYAML string
//go:embed smd-deploy-config.yaml
DeploymentConfigYAML string
//go:embed smd-deploy2-live.yaml
Deployment2LiveYAML string
//go:embed smd-deploy2-config.yaml
Deployment2ConfigYAML string
//go:embed smd-deploy2-predicted-live.json
Deployment2PredictedLiveJSONSSD string
// OpenAPIV2Doc is a binary representation of the openapi
// document available in a given k8s instance. To update
// this file the following commands can be executed:
// kubectl proxy --port=7777 &
// curl -s -H Accept:application/com.github.proto-openapi.spec.v2@v1.0+protobuf http://localhost:7777/openapi/v2 > openapiv2.bin
//
//go:embed openapiv2.bin
OpenAPIV2Doc []byte
//go:embed ssd-service-config.yaml
ServiceConfigYAMLSSD string
//go:embed ssd-service-live.yaml
ServiceLiveYAMLSSD string
//go:embed ssd-service-predicted-live.json
ServicePredictedLiveJSONSSD string
)