diff --git a/pkg/kadm/configs.go b/pkg/kadm/configs.go index 8e183c97..b1e824a4 100644 --- a/pkg/kadm/configs.go +++ b/pkg/kadm/configs.go @@ -56,7 +56,7 @@ type ResourceConfigs []ResourceConfig // The fn is given a copy of the config. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the resource does not exist, this returns an error indicating it is missing. +// If the resource does not exist, this returns kerr.UnknownTopicOrPartition. func (rs ResourceConfigs) On(name string, fn func(*ResourceConfig) error) (ResourceConfig, error) { for _, r := range rs { if r.Name == name { @@ -66,7 +66,7 @@ func (rs ResourceConfigs) On(name string, fn func(*ResourceConfig) error) (Resou return r, fn(&r) } } - return ResourceConfig{}, errMissing(name) + return ResourceConfig{}, kerr.UnknownTopicOrPartition } // DescribeTopicConfigs returns the configuration for the requested topics. @@ -196,7 +196,7 @@ type AlterConfigsResponses []AlterConfigsResponse // The fn is given a copy of the response. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the resource does not exist, this returns an error indicating it is missing. +// If the resource does not exist, this returns kerr.UnknownTopicOrPartition. func (rs AlterConfigsResponses) On(name string, fn func(*AlterConfigsResponse) error) (AlterConfigsResponse, error) { for _, r := range rs { if r.Name == name { @@ -206,7 +206,7 @@ func (rs AlterConfigsResponses) On(name string, fn func(*AlterConfigsResponse) e return r, fn(&r) } } - return AlterConfigsResponse{}, errMissing(name) + return AlterConfigsResponse{}, kerr.UnknownTopicOrPartition } // AlterTopicConfigs incrementally alters topic configuration values. diff --git a/pkg/kadm/errors.go b/pkg/kadm/errors.go index bcd92834..05bfff29 100644 --- a/pkg/kadm/errors.go +++ b/pkg/kadm/errors.go @@ -9,14 +9,6 @@ import ( "github.com/twmb/franz-go/pkg/kmsg" ) -func errMissing(name string) error { - return fmt.Errorf("missing %q", name) -} - -func errPartMissing(t string, p int32) error { - return fmt.Errorf("missing %q partition %d", t, p) -} - // AuthError can be returned from requests for resources that you are not // authorized for. type AuthError struct { diff --git a/pkg/kadm/groups.go b/pkg/kadm/groups.go index d30c8ba1..a52a6bff 100644 --- a/pkg/kadm/groups.go +++ b/pkg/kadm/groups.go @@ -150,7 +150,7 @@ func (ds DescribedGroups) Sorted() []DescribedGroup { // Modifications on a described group's inner fields are persisted to the // original map (because slices are pointers). // -// If the group does not exist, this returns an error indicating it is missing. +// If the group does not exist, this returns kerr.GroupIDNotFound. func (rs DescribedGroups) On(group string, fn func(*DescribedGroup) error) (DescribedGroup, error) { if len(rs) > 0 { r, ok := rs[group] @@ -161,7 +161,7 @@ func (rs DescribedGroups) On(group string, fn func(*DescribedGroup) error) (Desc return r, fn(&r) } } - return DescribedGroup{}, errMissing(group) + return DescribedGroup{}, kerr.GroupIDNotFound } // Topics returns a sorted list of all group names. @@ -373,7 +373,7 @@ func (ds DeleteGroupResponses) Sorted() []DeleteGroupResponse { // The fn is given a copy of the response. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the group does not exist, this returns an error indicating it is missing. +// If the group does not exist, this returns kerr.GroupIDNotFound. func (rs DeleteGroupResponses) On(group string, fn func(*DeleteGroupResponse) error) (DeleteGroupResponse, error) { if len(rs) > 0 { r, ok := rs[group] @@ -384,7 +384,7 @@ func (rs DeleteGroupResponses) On(group string, fn func(*DeleteGroupResponse) er return r, fn(&r) } } - return DeleteGroupResponse{}, errMissing(group) + return DeleteGroupResponse{}, kerr.GroupIDNotFound } // DeleteGroups deletes all groups specified. @@ -750,7 +750,7 @@ func (rs FetchOffsetsResponses) AllFailed() bool { // The fn is given a copy of the response. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the group does not exist, this returns an error indicating it is missing. +// If the group does not exist, this returns kerr.GroupIDNotFound. func (rs FetchOffsetsResponses) On(group string, fn func(*FetchOffsetsResponse) error) (FetchOffsetsResponse, error) { if len(rs) > 0 { r, ok := rs[group] @@ -761,7 +761,7 @@ func (rs FetchOffsetsResponses) On(group string, fn func(*FetchOffsetsResponse) return r, fn(&r) } } - return FetchOffsetsResponse{}, errMissing(group) + return FetchOffsetsResponse{}, kerr.GroupIDNotFound } // FetchManyOffsets issues a fetch offsets requests for each group specified. diff --git a/pkg/kadm/topics.go b/pkg/kadm/topics.go index 9a5600b2..327d0273 100644 --- a/pkg/kadm/topics.go +++ b/pkg/kadm/topics.go @@ -73,7 +73,7 @@ func (rs CreateTopicResponses) Sorted() []CreateTopicResponse { // The fn is given a copy of the response. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the topic does not exist, this returns an error indicating it is missing. +// If the topic does not exist, this returns kerr.UnknownTopicOrPartition. func (rs CreateTopicResponses) On(topic string, fn func(*CreateTopicResponse) error) (CreateTopicResponse, error) { if len(rs) > 0 { r, ok := rs[topic] @@ -84,7 +84,7 @@ func (rs CreateTopicResponses) On(topic string, fn func(*CreateTopicResponse) er return r, fn(&r) } } - return CreateTopicResponse{}, errMissing(topic) + return CreateTopicResponse{}, kerr.UnknownTopicOrPartition } // CreateTopics issues a create topics request with the given partitions, @@ -197,7 +197,7 @@ func (rs DeleteTopicResponses) Sorted() []DeleteTopicResponse { // The fn is given a copy of the response. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the topic does not exist, this returns an error indicating it is missing. +// If the topic does not exist, this returns kerr.UnknownTopicOrPartition. func (rs DeleteTopicResponses) On(topic string, fn func(*DeleteTopicResponse) error) (DeleteTopicResponse, error) { if len(rs) > 0 { r, ok := rs[topic] @@ -208,7 +208,7 @@ func (rs DeleteTopicResponses) On(topic string, fn func(*DeleteTopicResponse) er return r, fn(&r) } } - return DeleteTopicResponse{}, errMissing(topic) + return DeleteTopicResponse{}, kerr.UnknownTopicOrPartition } // DeleteTopics issues a delete topics request for the given topic names with a @@ -317,8 +317,8 @@ func (rs DeleteRecordsResponses) Sorted() []DeleteRecordsResponse { // The fn is given a copy of the response. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the topic or partition does not exist, this returns an error indicating -// it is missing. +// If the topic or partition does not exist, this returns +// kerr.UnknownTopicOrPartition. func (rs DeleteRecordsResponses) On(topic string, partition int32, fn func(*DeleteRecordsResponse) error) (DeleteRecordsResponse, error) { if len(rs) > 0 { t, ok := rs[topic] @@ -332,7 +332,7 @@ func (rs DeleteRecordsResponses) On(topic string, partition int32, fn func(*Dele } } } - return DeleteRecordsResponse{}, errPartMissing(topic, partition) + return DeleteRecordsResponse{}, kerr.UnknownTopicOrPartition } // DeleteRecords issues a delete records request for the given offsets. Per @@ -411,7 +411,7 @@ func (rs CreatePartitionsResponses) Sorted() []CreatePartitionsResponse { // The fn is given a copy of the response. This function returns the copy as // well; any modifications within fn are modifications on the returned copy. // -// If the topic does not exist, this returns an error indicating it is missing. +// If the topic does not exist, this returns kerr.UnknownTopicOrPartition. func (rs CreatePartitionsResponses) On(topic string, fn func(*CreatePartitionsResponse) error) (CreatePartitionsResponse, error) { if len(rs) > 0 { r, ok := rs[topic] @@ -422,7 +422,7 @@ func (rs CreatePartitionsResponses) On(topic string, fn func(*CreatePartitionsRe return r, fn(&r) } } - return CreatePartitionsResponse{}, errMissing(topic) + return CreatePartitionsResponse{}, kerr.UnknownTopicOrPartition } // CreatePartitions issues a create partitions request for the given topics,