Skip to content

Commit a7715b2

Browse files
authored
[APP-8840] Add support for adding prefix to remote config (#5244)
1 parent 61af083 commit a7715b2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

config/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ type Remote struct {
377377

378378
// Secret is a helper for a robot location secret.
379379
Secret string
380+
Prefix string
380381

381382
alreadyValidated bool
382383
cachedErr error
@@ -396,6 +397,7 @@ type remoteData struct {
396397

397398
// Secret is a helper for a robot location secret.
398399
Secret string `json:"secret"`
400+
Prefix string `json:"prefix,omitempty"`
399401
}
400402

401403
// Equals checks if the two configs are deeply equal to each other.
@@ -423,6 +425,7 @@ func (conf *Remote) UnmarshalJSON(data []byte) error {
423425
Insecure: temp.Insecure,
424426
AssociatedResourceConfigs: temp.AssociatedResourceConfigs,
425427
Secret: temp.Secret,
428+
Prefix: temp.Prefix,
426429
}
427430
if temp.ConnectionCheckInterval != "" {
428431
dur, err := time.ParseDuration(temp.ConnectionCheckInterval)
@@ -453,6 +456,9 @@ func (conf Remote) MarshalJSON() ([]byte, error) {
453456
AssociatedResourceConfigs: conf.AssociatedResourceConfigs,
454457
Secret: conf.Secret,
455458
}
459+
if conf.Prefix != "" {
460+
temp.Prefix = conf.Prefix
461+
}
456462
if conf.ConnectionCheckInterval != 0 {
457463
temp.ConnectionCheckInterval = conf.ConnectionCheckInterval.String()
458464
}

config/proto_conversions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ func RemoteConfigToProto(remote *Remote) (*pb.RemoteConfig, error) {
556556
ServiceConfigs: serviceConfigs,
557557
Secret: remote.Secret,
558558
Auth: remoteAuth,
559+
Prefix: remote.Prefix,
559560
}
560561

561562
if remote.Frame != nil {
@@ -585,6 +586,7 @@ func RemoteConfigFromProto(proto *pb.RemoteConfig, _ logging.Logger) (*Remote, e
585586
ReconnectInterval: proto.ReconnectInterval.AsDuration(),
586587
AssociatedResourceConfigs: associatedResourceConfigs,
587588
Secret: proto.GetSecret(),
589+
Prefix: proto.GetPrefix(),
588590
}
589591

590592
if proto.GetAuth() != nil {

config/proto_conversions_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ var testRemote = Remote{
102102
},
103103
},
104104
},
105+
Prefix: "some-prefix",
105106
}
106107

107108
var testService = resource.Config{
@@ -562,6 +563,7 @@ func validateRemote(t *testing.T, actual, expected Remote) {
562563
test.That(t, actual.Insecure, test.ShouldEqual, expected.Insecure)
563564
test.That(t, actual.ReconnectInterval, test.ShouldEqual, expected.ReconnectInterval)
564565
test.That(t, actual.ConnectionCheckInterval, test.ShouldEqual, expected.ConnectionCheckInterval)
566+
test.That(t, actual.Prefix, test.ShouldEqual, expected.Prefix)
565567
test.That(t, actual.Auth, test.ShouldResemble, expected.Auth)
566568
f1, err := actual.Frame.ParseConfig()
567569
test.That(t, err, test.ShouldBeNil)
@@ -604,13 +606,14 @@ func TestRemoteConfigToProto(t *testing.T) {
604606
proto := pb.RemoteConfig{
605607
Name: "some-name",
606608
Address: "localohst:8080",
609+
Prefix: "some-prefix",
607610
}
608611

609612
out, err := RemoteConfigFromProto(&proto, logger)
610613
test.That(t, err, test.ShouldBeNil)
611-
612614
test.That(t, out.Name, test.ShouldEqual, proto.Name)
613615
test.That(t, out.Address, test.ShouldEqual, proto.Address)
616+
test.That(t, out.Prefix, test.ShouldEqual, proto.Prefix)
614617
test.That(t, out.Auth, test.ShouldResemble, RemoteAuth{})
615618
})
616619
}

0 commit comments

Comments
 (0)