Skip to content

Commit

Permalink
Fix golint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
milindl committed Oct 17, 2023
1 parent a07f393 commit 755bc19
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
16 changes: 8 additions & 8 deletions examples/admin_describe_cluster/admin_describe_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ func main() {
if len(os.Args) < 3 {
fmt.Fprintf(
os.Stderr,
"Usage: %s <bootstrap-servers> <include_authorized_operations>\n",
"Usage: %s <bootstrap-servers> <includeAuthorizedOperations>\n",
os.Args[0])
os.Exit(1)
}

bootstrapServers := os.Args[1]
include_authorized_operations, err_operations := strconv.ParseBool(os.Args[2])
if err_operations != nil {
includeAuthorizedOperations, errOperations := strconv.ParseBool(os.Args[2])
if errOperations != nil {
fmt.Printf(
"Failed to parse value of include_authorized_operations %s: %s\n",
os.Args[2], err_operations)
"Failed to parse value of includeAuthorizedOperations %s: %s\n",
os.Args[2], errOperations)
os.Exit(1)
}

Expand All @@ -60,16 +60,16 @@ func main() {
defer cancel()
clusterDesc, err := a.DescribeCluster(
ctx, kafka.SetAdminOptionIncludeAuthorizedOperations(
include_authorized_operations))
includeAuthorizedOperations))
if err != nil {
fmt.Printf("Failed to describe cluster: %s\n", err)
os.Exit(1)
}

// Print results
fmt.Printf("ClusterId: %s\nController: %s\nNodes: %s\n",
clusterDesc.ClusterId, clusterDesc.Controller, clusterDesc.Nodes)
if include_authorized_operations {
clusterDesc.ClusterID, clusterDesc.Controller, clusterDesc.Nodes)
if includeAuthorizedOperations {
fmt.Printf("Allowed operations: %s\n", clusterDesc.AuthorizedOperations)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ func main() {
if len(os.Args) < 4 {
fmt.Fprintf(
os.Stderr,
"Usage: %s <bootstrap-servers> <include_authorized_operations>"+
"Usage: %s <bootstrap-servers> <includeAuthorizedOperations>"+
" <group1> [<group2> ...]\n",
os.Args[0])
os.Exit(1)
}

bootstrapServers := os.Args[1]
include_authorized_operations, err_operations := strconv.ParseBool(os.Args[2])
if err_operations != nil {
includeAuthorizedOperations, errOperations := strconv.ParseBool(os.Args[2])
if errOperations != nil {
fmt.Printf(
"Failed to parse value of include_authorized_operations %s: %s\n", os.Args[2], err_operations)
"Failed to parse value of includeAuthorizedOperations %s: %s\n", os.Args[2], errOperations)
os.Exit(1)
}

Expand All @@ -61,7 +61,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
describeGroupsResult, err := a.DescribeConsumerGroups(ctx, groups,
kafka.SetAdminOptionIncludeAuthorizedOperations(include_authorized_operations))
kafka.SetAdminOptionIncludeAuthorizedOperations(includeAuthorizedOperations))
if err != nil {
fmt.Printf("Failed to describe groups: %s\n", err)
os.Exit(1)
Expand All @@ -80,7 +80,7 @@ func main() {
"Members: %+v\n",
g.GroupID, g.Error, g.IsSimpleConsumerGroup, g.PartitionAssignor,
g.State, g.Coordinator, g.Members)
if include_authorized_operations {
if includeAuthorizedOperations {
fmt.Printf("Allowed operations: %s\n", g.AuthorizedOperations)
}
fmt.Printf("\n")
Expand Down
14 changes: 7 additions & 7 deletions examples/admin_describe_topics/admin_describe_topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ func main() {
if len(os.Args) < 4 {
fmt.Fprintf(
os.Stderr,
"Usage: %s <bootstrap-servers> <include_authorized_operations>"+
"Usage: %s <bootstrap-servers> <includeAuthorizedOperations>"+
" <topic1> [<topic2> ...]\n",
os.Args[0])
os.Exit(1)
}

bootstrapServers := os.Args[1]
include_authorized_operations, err_operations := strconv.ParseBool(os.Args[2])
if err_operations != nil {
includeAuthorizedOperations, errOperations := strconv.ParseBool(os.Args[2])
if errOperations != nil {
fmt.Printf(
"Failed to parse value of include_authorized_operations %s: %s\n",
os.Args[2], err_operations)
"Failed to parse value of includeAuthorizedOperations %s: %s\n",
os.Args[2], errOperations)
os.Exit(1)
}
topics := os.Args[3:]
Expand All @@ -63,7 +63,7 @@ func main() {
describeTopicsResult, err := a.DescribeTopics(
ctx, kafka.NewTopicCollectionOfTopicNames(topics),
kafka.SetAdminOptionIncludeAuthorizedOperations(
include_authorized_operations))
includeAuthorizedOperations))
if err != nil {
fmt.Printf("Failed to describe topics: %s\n", err)
os.Exit(1)
Expand All @@ -79,7 +79,7 @@ func main() {
continue
}
fmt.Printf("Topic: %s has succeeded\n", t.Name)
if include_authorized_operations {
if includeAuthorizedOperations {
fmt.Printf("Allowed operations: %s\n", t.AuthorizedOperations)
}
for i := 0; i < len(t.Partitions); i++ {
Expand Down
15 changes: 8 additions & 7 deletions kafka/adminapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ func NewTopicCollectionOfTopicNames(names []string) TopicCollection {
}
}

// Topic Partition information
// TopicPartitionInfo represents a specific partition's information inside a
// TopicDescription.
type TopicPartitionInfo struct {
// Partition id.
Partition int
Expand Down Expand Up @@ -350,7 +351,7 @@ type DescribeTopicsResult struct {
// DescribeClusterResult represents the result of DescribeCluster.
type DescribeClusterResult struct {
// Cluster id for the cluster.
ClusterId string
ClusterID string
// Current controller broker for the cluster.
Controller *Node
// List of brokers in the cluster.
Expand Down Expand Up @@ -1108,8 +1109,8 @@ func (a *AdminClient) cToNode(cNode *C.rd_kafka_Node_t) Node {

cRack := C.rd_kafka_Node_rack(cNode)
if cRack != nil {
rackId := C.GoString(cRack)
node.Rack = &rackId
rackID := C.GoString(cRack)
node.Rack = &rackID
}

return node
Expand Down Expand Up @@ -1212,9 +1213,9 @@ func (a *AdminClient) cToConsumerGroupDescriptions(
// TopicPartitionInfo.
func (a *AdminClient) cToTopicPartitionInfo(
partitionInfo *C.rd_kafka_TopicPartitionInfo_t) TopicPartitionInfo {
cPartitionId := C.rd_kafka_TopicPartitionInfo_partition(partitionInfo)
cPartitionID := C.rd_kafka_TopicPartitionInfo_partition(partitionInfo)
info := TopicPartitionInfo{
Partition: int(cPartitionId),
Partition: int(cPartitionID),
}

cLeader := C.rd_kafka_TopicPartitionInfo_leader(partitionInfo)
Expand Down Expand Up @@ -1302,7 +1303,7 @@ func (a *AdminClient) cToDescribeClusterResult(
cAuthorizedOperations, cAuthorizedOperationsCnt)

return DescribeClusterResult{
ClusterId: clusterID,
ClusterID: clusterID,
Controller: controller,
Nodes: nodes,
AuthorizedOperations: authorizedOperations,
Expand Down
6 changes: 3 additions & 3 deletions kafka/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ func (its *IntegrationTestSuite) TestAdminClient_DescribeCluster() {
// of the cluster ID. We try checking for the existence in cases we can.
assert.Nil(err, "DescribeCluster should not throw an error")
assert.NotEmpty(descres.Nodes, "Cluster nodes should not be empty")
assert.NotEmpty(descres.ClusterId, "Cluster id should be set")
assert.NotEmpty(descres.ClusterID, "Cluster id should be set")
assert.NotEmpty(descres.Nodes[0].Host,
"First node's host should be non-empty")
assert.Empty(descres.AuthorizedOperations,
Expand All @@ -1290,7 +1290,7 @@ func (its *IntegrationTestSuite) TestAdminClient_DescribeCluster() {

assert.Nil(err, "DescribeCluster should not throw an error")
assert.NotEmpty(descres.Nodes, "Cluster nodes should not be empty")
assert.NotEmpty(descres.ClusterId, "Cluster id should be set")
assert.NotEmpty(descres.ClusterID, "Cluster id should be set")
assert.NotEmpty(descres.Nodes[0].Host,
"First node's host should be non-empty")
assert.NotEmpty(descres.AuthorizedOperations,
Expand Down Expand Up @@ -1355,7 +1355,7 @@ func (its *IntegrationTestSuite) TestAdminClient_DescribeCluster() {

assert.Nil(err, "DescribeCluster should not throw an error")
assert.NotEmpty(descres.Nodes, "Cluster nodes should not be empty")
assert.NotEmpty(descres.ClusterId, "Cluster id should be set")
assert.NotEmpty(descres.ClusterID, "Cluster id should be set")
assert.NotEmpty(descres.Nodes[0].Host,
"First node's host should be non-empty")
assert.NotEmpty(descres.AuthorizedOperations,
Expand Down

0 comments on commit 755bc19

Please sign in to comment.