Skip to content

Commit

Permalink
Remove dependency on io/ioutil module
Browse files Browse the repository at this point in the history
This fixes lint errors generated in CI after upgrading
go version into 1.19.6.

Signed-off-by: Periyasamy Palanisamy <[email protected]>
  • Loading branch information
pperiyasamy committed Sep 26, 2023
1 parent e0bed3f commit 464e26b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cache/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package cache provides a cache of model.Model elements that can be used in an OV
The cache can be accessed using a simple API:
cache.Table("Open_vSwitch").Row("<ovs-uuid>")
cache.Table("Open_vSwitch").Row("<ovs-uuid>")
It implements the ovsdb.NotificationHandler interface
such that it can be populated automatically by
Expand Down
4 changes: 2 additions & 2 deletions cmd/modelgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -56,7 +56,7 @@ func main() {
}
defer schemaFile.Close()

schemaBytes, err := ioutil.ReadAll(schemaFile)
schemaBytes, err := io.ReadAll(schemaFile)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/print_schema/print_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"runtime"
Expand Down Expand Up @@ -53,7 +53,7 @@ func main() {
}
defer schemaFile.Close()

schemaBytes, err := ioutil.ReadAll(schemaFile)
schemaBytes, err := io.ReadAll(schemaFile)
if err != nil {
log.Fatal(err)
}
Expand Down
10 changes: 6 additions & 4 deletions mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import (
// to what column in the database id through field a field tag.
// The tag used is "ovsdb" and has the following structure
// 'ovsdb:"${COLUMN_NAME}"'
//
// where COLUMN_NAME is the name of the column and must match the schema
//
//Example:
// type MyObj struct {
// Name string `ovsdb:"name"`
// }
// Example:
//
// type MyObj struct {
// Name string `ovsdb:"name"`
// }
type Mapper struct {
Schema ovsdb.DatabaseSchema
}
Expand Down
13 changes: 7 additions & 6 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
// The struct may also have non-tagged fields (which will be ignored by the API calls)
// The Model interface must be implemented by the pointer to such type
// Example:
//type MyLogicalRouter struct {
// UUID string `ovsdb:"_uuid"`
// Name string `ovsdb:"name"`
// ExternalIDs map[string]string `ovsdb:"external_ids"`
// LoadBalancers []string `ovsdb:"load_balancer"`
//}
//
// type MyLogicalRouter struct {
// UUID string `ovsdb:"_uuid"`
// Name string `ovsdb:"name"`
// ExternalIDs map[string]string `ovsdb:"external_ids"`
// LoadBalancers []string `ovsdb:"load_balancer"`
// }
type Model interface{}

type CloneableModel interface {
Expand Down
6 changes: 3 additions & 3 deletions modelgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"fmt"
"go/format"
"io/ioutil"
"log"
"os"
"text/template"
)

Expand Down Expand Up @@ -47,11 +47,11 @@ func (g *generator) Generate(filename string, tmpl *template.Template, args inte
fmt.Print("\n")
return nil
}
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err == nil && bytes.Equal(content, src) {
return nil
}
return ioutil.WriteFile(filename, src, 0644)
return os.WriteFile(filename, src, 0644)
}

// NewGenerator returns a new Generator
Expand Down
5 changes: 2 additions & 3 deletions ovsdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math"
"os"
"strings"
Expand Down Expand Up @@ -48,7 +47,7 @@ func (schema DatabaseSchema) Print(w io.Writer) {

// SchemaFromFile returns a DatabaseSchema from a file
func SchemaFromFile(f *os.File) (DatabaseSchema, error) {
data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
if err != nil {
return DatabaseSchema{}, err
}
Expand Down Expand Up @@ -124,7 +123,7 @@ of this library, we define an ExtendedType that includes all possible column typ
atomic fields).
*/

//ExtendedType includes atomic types as defined in the RFC plus Enum, Map and Set
// ExtendedType includes atomic types as defined in the RFC plus Enum, Map and Set
type ExtendedType = string

// RefType is used to define the possible RefTypes
Expand Down

0 comments on commit 464e26b

Please sign in to comment.