Skip to content

Commit a6e28dc

Browse files
authored
fix dynamic config (#1228)
1 parent a1ce5e6 commit a6e28dc

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

pulsaradmin/pkg/admin/admin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@ func (c *pulsarClient) endpoint(componentPath string, parts ...string) string {
112112
path.Join(escapedParts...),
113113
)
114114
}
115+
116+
// this function won't do any escaping
117+
func (c *pulsarClient) endpointWithFullPath(componentPath string, fullPath string) string {
118+
return path.Join(utils.MakeHTTPPath(c.APIVersion.String(), componentPath), fullPath)
119+
}

pulsaradmin/pkg/admin/brokers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package admin
1919

2020
import (
2121
"fmt"
22-
"net/url"
2322
"strings"
2423

2524
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
@@ -120,8 +119,8 @@ func (b *broker) GetOwnedNamespaces(cluster, brokerURL string) (map[string]utils
120119
}
121120

122121
func (b *broker) UpdateDynamicConfiguration(configName, configValue string) error {
123-
value := url.QueryEscape(configValue)
124-
endpoint := b.pulsar.endpoint(b.basePath, "/configuration/", configName, value)
122+
value := fmt.Sprintf("/configuration/%s/%s", configName, configValue)
123+
endpoint := b.pulsar.endpointWithFullPath(b.basePath, value)
125124
return b.pulsar.Client.Post(endpoint, nil)
126125
}
127126

pulsaradmin/pkg/admin/brokers_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,21 @@ func TestGetAllActiveBrokers(t *testing.T) {
7373
assert.NoError(t, err)
7474
assert.NotEmpty(t, brokers)
7575
}
76+
77+
func TestUpdateDynamicConfiguration(t *testing.T) {
78+
readFile, err := os.ReadFile("../../../integration-tests/tokens/admin-token")
79+
assert.NoError(t, err)
80+
cfg := &config.Config{
81+
Token: string(readFile),
82+
}
83+
admin, err := New(cfg)
84+
assert.NoError(t, err)
85+
assert.NotNil(t, admin)
86+
87+
err = admin.Brokers().UpdateDynamicConfiguration("allowAutoSubscriptionCreation", "true")
88+
assert.NoError(t, err)
89+
90+
configurations, err := admin.Brokers().GetDynamicConfigurationNames()
91+
assert.NoError(t, err)
92+
assert.NotEmpty(t, configurations)
93+
}

0 commit comments

Comments
 (0)