Skip to content

add dynamic unknown fields to the blueprint property types #260

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

Merged
merged 1 commit into from
Jun 15, 2025

Conversation

itamar-smirra-port
Copy link
Contributor

@itamar-smirra-port itamar-smirra-port commented Jun 14, 2025

Description

What - add dynamic unknown fields to the blueprint property types
Why - to successfully import object properties, especially the 'filter' object property of SCAB feature
How - Add custom json marshal and unmarshal to the blueprint property strucure

Type of change

Please leave one option from the following and delete the rest:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Non-breaking change (fix of existing functionality that will not change current behavior)
  • Documentation (added/updated documentation)

Copy link

TestsPassed ✅SkippedFailedTime ⏱
JUnit Test Report170 ran170 ✅0 ⚠️0 ❌20m 19s 100ms
TestRetriesTime ⏱
JUnit Test Report
com/port-labs/terraform-provider-port-labs/v2/port/entity.TestAccPortEntityWithManyRelation18s 880ms

Copy link

Code Coverage Artifact 📈: https://github.com/port-labs/terraform-provider-port-labs/actions/runs/15653917805/artifacts/3328739266

Code Coverage Total Percentage: 71.9%

Copy link
Member

@erikzaadi erikzaadi left a comment

Choose a reason for hiding this comment

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

image

SpecAuthentication *SpecAuthentication `json:"specAuthentication,omitempty"`
EnumColors map[string]string `json:"enumColors,omitempty"`
// UnknownFields captures any dynamic fields not explicitly defined above
UnknownFields map[string]any `json:"-"`
Copy link
Member

Choose a reason for hiding this comment

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

Nice!
Didn't know about ``json:"-"`

@itamar-smirra-port itamar-smirra-port merged commit dcda3f4 into main Jun 15, 2025
22 checks passed
bp.UnknownFields = make(map[string]interface{})

// List of known fields that shouldn't go into UnknownFields
knownFields := map[string]bool{
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to use reflection here instead of hard coding the list of known fields

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.

3 participants