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

fix: correct diffs when comparing objects with empty tags #985

Merged
merged 2 commits into from
Jul 27, 2023

Conversation

GGabriele
Copy link
Collaborator

Right now, when some declarative configuration having empty tags on any of its entities is deployed, subsequent diff / sync will show misleading results:

$ cat kong.yaml
_format_version: "3.0"
services:
  - name: foo
    protocol: http
    host: foo
    port: 8000
    tags: []

$ deck sync
creating service foo
Summary:
  Created: 1
  Updated: 0
  Deleted: 0

$ deck sync
updating service foo  {
   "connect_timeout": 60000,
   "enabled": true,
   "host": "foo",
   "id": "afadd2ed-2bcd-49fc-9000-adb58cd11b50",
   "name": "foo",
   "port": 8000,
   "protocol": "http",
   "read_timeout": 60000,
   "retries": 5,
   "write_timeout": 60000
 }

Summary:
  Created: 0
  Updated: 1
  Deleted: 0

The second deck sync run is showing an update without an actual diff. This is due to the way empty tags are treated internally in decK.

This commit fixes this defect.

Right now, when some declarative configuration having empty tags
on any of its entities is deployed, subsequent `diff` / `sync`
will show misleading results:

```
$ cat kong.yaml
_format_version: "3.0"
services:
  - name: foo
    protocol: http
    host: foo
    port: 8000
    tags: []

$ deck sync
creating service foo
Summary:
  Created: 1
  Updated: 0
  Deleted: 0

$ deck sync
updating service foo  {
   "connect_timeout": 60000,
   "enabled": true,
   "host": "foo",
   "id": "afadd2ed-2bcd-49fc-9000-adb58cd11b50",
   "name": "foo",
   "port": 8000,
   "protocol": "http",
   "read_timeout": 60000,
   "retries": 5,
   "write_timeout": 60000
 }

Summary:
  Created: 0
  Updated: 1
  Deleted: 0
```

The second `deck sync` run is showing an update without an actual diff.
This is due to the way empty tags are treated internally in decK.

This commit fixes this defect.
@GGabriele GGabriele requested a review from a team as a code owner July 26, 2023 17:14
Tieske
Tieske previously approved these changes Jul 26, 2023
Copy link
Member

@Tieske Tieske left a comment

Choose a reason for hiding this comment

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

Should there be a change log entry?

@GGabriele
Copy link
Collaborator Author

Should there be a change log entry?

done

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 76.47% and project coverage change: +0.34% 🎉

Comparison is base (24ef372) 33.71% compared to head (7ac1b1a) 34.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #985      +/-   ##
==========================================
+ Coverage   33.71%   34.06%   +0.34%     
==========================================
  Files         100      100              
  Lines       12006    12106     +100     
==========================================
+ Hits         4048     4124      +76     
- Misses       7564     7588      +24     
  Partials      394      394              
Files Changed Coverage Δ
state/types.go 57.94% <76.47%> (+2.32%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GGabriele GGabriele merged commit aee76dd into main Jul 27, 2023
35 checks passed
@GGabriele GGabriele deleted the fix/empty-tags branch July 27, 2023 11:30
AntoineJac pushed a commit that referenced this pull request Jan 23, 2024
Right now, when some declarative configuration having empty tags
on any of its entities is deployed, subsequent `diff` / `sync`
will show misleading results:

```
$ cat kong.yaml
_format_version: "3.0"
services:
  - name: foo
    protocol: http
    host: foo
    port: 8000
    tags: []

$ deck sync
creating service foo
Summary:
  Created: 1
  Updated: 0
  Deleted: 0

$ deck sync
updating service foo  {
   "connect_timeout": 60000,
   "enabled": true,
   "host": "foo",
   "id": "afadd2ed-2bcd-49fc-9000-adb58cd11b50",
   "name": "foo",
   "port": 8000,
   "protocol": "http",
   "read_timeout": 60000,
   "retries": 5,
   "write_timeout": 60000
 }

Summary:
  Created: 0
  Updated: 1
  Deleted: 0
```

The second `deck sync` run is showing an update without an actual diff.
This is due to the way empty tags are treated internally in decK.

This commit fixes this defect.
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