ovn-kubernetes/libovsdb

Consider making `ovsdb.Operation` an interface

Open

#178 opened on Jun 24, 2021

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Go (164 forks)auto 404
featuregood first issue

Repository metrics

Stars
 (211 stars)
PR merge metrics
 (PR metrics pending)

Description

It's used a lot as a return type (e.g client.Create return []ovsdb.Operation and as a parameter in client.Transact

Since there are a number of optional fields, constructing operations yourself can be error prone (and annoying when having to create temporary variables to assign to a *string as literals can't be indirected). To avoid leaking this datastructure outside the OVSDB package, we should consider providing an intermediate type in the client package - like we've done for Condition or Mutation for example:

package client

type Operation interface {
    json.Marshaler
    json.Unmarshaler
}

We'd also want functions to create new Operations, e.g NewInsertOperation, NewDeleteOperation, NewCommentOperation

Contributor guide