Skip to content

Commit 2240d71

Browse files
committed
feat: add control_plane_id field to the dumped configuration
Add the `control_plane_id` field to enable its usage in `decK`.
1 parent c62c194 commit 2240d71

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

pkg/dump/dump.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ type Config struct {
5858
LookUpSelectorTagsPartials []string
5959

6060
// KonnectControlPlane
61-
KonnectControlPlane string
61+
KonnectControlPlane string
62+
KonnectControlPlaneID string
6263

6364
// IsConsumerGroupScopedPluginSupported
6465
IsConsumerGroupScopedPluginSupported bool
@@ -108,7 +109,7 @@ func validateConfig(config Config) error {
108109
}
109110

110111
func isKongVersion34Plus(ctx context.Context, client *kong.Client, config Config) (bool, error) {
111-
if config.KonnectControlPlane != "" {
112+
if config.KonnectControlPlane != "" || config.KonnectControlPlaneID != "" {
112113
return false, nil
113114
}
114115

@@ -267,7 +268,7 @@ func getConsumerConfiguration(ctx context.Context, group *errgroup.Group,
267268
})
268269

269270
// OAuth2 credentials are not supported in Konnect.
270-
if config.KonnectControlPlane == "" {
271+
if config.KonnectControlPlane == "" && config.KonnectControlPlaneID == "" {
271272
group.Go(func() error {
272273
oauth2Creds, err := GetAllOauth2Creds(ctx, client, config.SelectorTags)
273274
if err != nil {

pkg/file/kong_json_schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,9 @@
16601660
"control_plane_name": {
16611661
"type": "string"
16621662
},
1663+
"control_plane_id": {
1664+
"type": "string"
1665+
},
16631666
"runtime_group_name": {
16641667
"type": "string"
16651668
}
@@ -2182,4 +2185,4 @@
21822185
"type": "object"
21832186
}
21842187
}
2185-
}
2188+
}

pkg/file/reader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func Get(ctx context.Context, fileContent *Content, opt RenderConfig, dumpConfig
7979
builder.client = wsClient
8080
builder.ctx = ctx
8181
builder.skipCACerts = dumpConfig.SkipCACerts
82-
builder.isKonnect = dumpConfig.KonnectControlPlane != ""
82+
builder.isKonnect = dumpConfig.KonnectControlPlane != "" || dumpConfig.KonnectControlPlaneID != ""
8383
builder.includeLicenses = dumpConfig.IncludeLicenses
8484
builder.isPartialApply = dumpConfig.IsPartialApply
8585
builder.isConsumerGroupPolicyOverrideSet = dumpConfig.IsConsumerGroupPolicyOverrideSet

pkg/file/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ type LookUpSelectorTags struct {
802802
type Konnect struct {
803803
RuntimeGroupName string `json:"runtime_group_name,omitempty" yaml:"runtime_group_name,omitempty"`
804804
ControlPlaneName string `json:"control_plane_name,omitempty" yaml:"control_plane_name,omitempty"`
805+
ControlPlaneID string `json:"control_plane_id,omitempty" yaml:"control_plane_id,omitempty"`
805806
}
806807

807808
// Kong represents Kong implementation of a Service in Konnect.

pkg/file/writer.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type WriteConfig struct {
2424
FileFormat Format
2525
WithID bool
2626
ControlPlaneName string
27+
ControlPlaneID string
2728
KongVersion string
2829
IsConsumerGroupPolicyOverrideSet bool
2930
}
@@ -56,9 +57,10 @@ func KongStateToContent(kongState *state.KongState, config WriteConfig) (*Conten
5657
return nil, fmt.Errorf("get format version: %w", err)
5758
}
5859
file.FormatVersion = formatVersion
59-
if config.ControlPlaneName != "" {
60+
if config.ControlPlaneName != "" || config.ControlPlaneID != "" {
6061
file.Konnect = &Konnect{
6162
ControlPlaneName: config.ControlPlaneName,
63+
ControlPlaneID: config.ControlPlaneID,
6264
}
6365
}
6466

0 commit comments

Comments
 (0)