Skip to content

Commit

Permalink
fix: changes required for Kafka SDK update (#1470)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtrocki authored Mar 14, 2022
1 parent 81688cc commit 72515dc
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/pkg/errors v0.9.1
github.com/redhat-developer/app-services-sdk-go/accountmgmt v0.1.0
github.com/redhat-developer/app-services-sdk-go/kafkainstance v0.4.0
github.com/redhat-developer/app-services-sdk-go/kafkainstance v0.5.0
github.com/redhat-developer/app-services-sdk-go/kafkamgmt v0.9.0
github.com/redhat-developer/app-services-sdk-go/registryinstance v0.3.1
github.com/redhat-developer/app-services-sdk-go/registrymgmt v0.6.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ github.com/redhat-developer/app-services-sdk-go v0.10.0 h1:zI0X5FR0NOj6IwBWk3y1T
github.com/redhat-developer/app-services-sdk-go v0.10.0/go.mod h1:enn8Zz6IT0HZYzS6LSttiME2apwnvfVWZnGRS81A4rk=
github.com/redhat-developer/app-services-sdk-go/accountmgmt v0.1.0 h1:MOljVN8AKTM72Yed8ioAwhdW0KdWEhBZjjam3lY2lyY=
github.com/redhat-developer/app-services-sdk-go/accountmgmt v0.1.0/go.mod h1:0LX7ZCEmMKAbncO05/zRYsV0K5wsds7AGPpOFC7KWGo=
github.com/redhat-developer/app-services-sdk-go/kafkainstance v0.4.0 h1:eAtKA1umUzWMCtfgC28k59xTYS4uAoxIOiSlzdF8NhU=
github.com/redhat-developer/app-services-sdk-go/kafkainstance v0.4.0/go.mod h1:6CxhBFDnXyrl5rWiLX2iBVs30o7Yhbt63SxGk4ZAnu0=
github.com/redhat-developer/app-services-sdk-go/kafkainstance v0.5.0 h1:1FMsZfo2xCtYimrBcR+s0O0b0MzxdxiStY8A78oTGBA=
github.com/redhat-developer/app-services-sdk-go/kafkainstance v0.5.0/go.mod h1:UYJgMZWmd238bk6l464U1g8I3YWcEE9PGnjvNRi5Lqw=
github.com/redhat-developer/app-services-sdk-go/kafkamgmt v0.9.0 h1:wb335WbgyhFZRIHOwqHJm+D877l50MPMacrONCmknnw=
github.com/redhat-developer/app-services-sdk-go/kafkamgmt v0.9.0/go.mod h1:Bs/YQI9ZuZLzBoeBAWV6KmkO8Jwm8NcrUn3VFp8eleo=
github.com/redhat-developer/app-services-sdk-go/registryinstance v0.3.1 h1:xRq5XJzRDs/Z7e/9SDt6zbNRIyesC4LTqN9ajHKwjHo=
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/kafka/acl/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func runDelete(instanceID string, opts *aclcmdutil.CrudOptions) error {
localize.NewEntry("Count", deletedCount),
))

rows := aclcmdutil.MapACLsToTableRows(*deletedACLs.Items, opts.Localizer)
rows := aclcmdutil.MapACLsToTableRows(deletedACLs.Items, opts.Localizer)
opts.Logger.Info(opts.Localizer.MustLocalizePlural("kafka.acl.grantPermissions.log.delete.info.aclsPreview", len(rows)))
opts.Logger.Info()

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/kafka/acl/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func runList(opts *options) (err error) {

req := api.AclsApi.GetAcls(opts.context)

req = req.Page(float32(opts.page)).Size(float32(opts.size))
req = req.Page(opts.page).Size(opts.size)
req = req.Order("asc").OrderKey("principal")

if opts.principal != "" {
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/kafka/consumergroup/groupcmdutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

// valid values for consumer group reset offset operaion
const (
OffsetAbsolute = "absolute"
OffsetEarliest = "earliest"
OffsetTimestamp = "timestamp"
OffsetLatest = "latest"
OffsetAbsolute = string(kafkainstanceclient.OFFSETTYPE_ABSOLUTE)
OffsetEarliest = string(kafkainstanceclient.OFFSETTYPE_EARLIEST)
OffsetTimestamp = string(kafkainstanceclient.OFFSETTYPE_TIMESTAMP)
OffsetLatest = string(kafkainstanceclient.OFFSETTYPE_LATEST)
)

var ValidOffsets = []string{OffsetAbsolute, OffsetEarliest, OffsetTimestamp, OffsetLatest}
Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/kafka/consumergroup/resetoffset/reset_offset.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ func runCmd(opts *options) error {
return err
}

offsetEnum, _ := kafkainstanceclient.NewOffsetTypeFromValue(opts.offset)
offsetResetParams := kafkainstanceclient.ConsumerGroupResetOffsetParameters{
Offset: opts.offset,
Offset: *offsetEnum,
Value: new(string),
Topics: &[]kafkainstanceclient.TopicsToResetOffset{},
}

if opts.value != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/kafka/topic/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func runCmd(opts *options) error {
topicInput := kafkainstanceclient.NewTopicInput{
Name: opts.topicName,
Settings: kafkainstanceclient.TopicSettings{
NumPartitions: opts.partitions,
NumPartitions: &opts.partitions,
Config: createConfigEntries(opts),
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/kafka/topic/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ func mapTopicResultsToTableFormat(topics []kafkainstanceclient.Topic) []topicRow
for _, conf := range t.GetConfig() {
unlimitedVal := "-1 (Unlimited)"

if *conf.Key == topiccmdutil.RetentionMsKey {
if conf.Key == topiccmdutil.RetentionMsKey {
val := conf.GetValue()
if val == "-1" {
row.RetentionTime = unlimitedVal
} else {
row.RetentionTime = val
}
}
if *conf.Key == topiccmdutil.RetentionSizeKey {
if conf.Key == topiccmdutil.RetentionSizeKey {
val := conf.GetValue()
if val == "-1" {
row.RetentionSize = unlimitedVal
Expand Down
6 changes: 2 additions & 4 deletions pkg/cmd/kafka/topic/topiccmdutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ func CreateConfigEntries(entryMap map[string]*string) *[]kafkainstanceclient.Con
for key, value := range entryMap {
if value != nil {
// nolint:scopelint
entry := kafkainstanceclient.NewConfigEntry()
entry.SetKey(key)
entry.SetValue(*value)
entry := kafkainstanceclient.NewConfigEntry(key, *value)
entries = append(entries, *entry)
}
}
Expand Down Expand Up @@ -64,7 +62,7 @@ func ConvertRetentionBytesToInt(retentionBytesStr string) (int, error) {
func GetConfigValue(configEntries []kafkainstanceclient.ConfigEntry, keyName string) (val string) {
for _, config := range configEntries {

if *config.Key == keyName {
if config.Key == keyName {
val = config.GetValue()
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/kafka/topic/topiccmdutil/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestCreateConfigEntries(t *testing.T) {
},
want: &[]kafkainstanceclient.ConfigEntry{
{
Key: &keyOne,
Value: &valOne,
Key: keyOne,
Value: valOne,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/kafka/topic/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func runCmd(opts *options) error {

updateTopicReq := api.TopicsApi.UpdateTopic(opts.Context, opts.name)

topicSettings := &kafkainstanceclient.UpdateTopicInput{}
topicSettings := &kafkainstanceclient.TopicSettings{}

if opts.retentionMsStr != "" {
needsUpdate = true
Expand Down Expand Up @@ -262,7 +262,7 @@ func runCmd(opts *options) error {
topicSettings.SetConfig(*configEntries)
}

updateTopicReq = updateTopicReq.UpdateTopicInput(*topicSettings)
updateTopicReq = updateTopicReq.TopicSettings(*topicSettings)

// update the topic
_, httpRes, err = updateTopicReq.Execute()
Expand Down
2 changes: 1 addition & 1 deletion pkg/shared/connection/api/defaultapi/default_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (a *defaultAPI) KafkaAdmin(instanceID string) (*kafkainstanceclient.APIClie
apiHost := fmt.Sprintf("admin-server-%v", host)
apiURL, _ = url.Parse(apiHost)
apiURL.Scheme = "https"
apiURL.Path = "/rest"
apiURL.Path = "/"
apiURL.Host = fmt.Sprintf("admin-server-%v", host)
}

Expand Down

0 comments on commit 72515dc

Please sign in to comment.