Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
clean up [nt]
Browse files Browse the repository at this point in the history
flarco committed Jan 31, 2024
1 parent 1cc2183 commit 0fa6656
Showing 7 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions database/analyzer.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package database

import (
"context"
"io/ioutil"
"os"
"strings"

"github.com/flarco/dbio/iop"
@@ -396,7 +396,7 @@ func (da *DataAnalyzer) WriteRelationsYaml(path string) (err error) {
return g.Error(err, "could not marshal to yaml")
}

err = ioutil.WriteFile(path, out, 0755)
err = os.WriteFile(path, out, 0755)
if err != nil {
return g.Error(err, "could not write to yaml")
}
7 changes: 4 additions & 3 deletions env/env.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ package env

import (
"embed"
"io/ioutil"
"os"
"path"
"sort"
@@ -85,7 +84,9 @@ func (ef *EnvFile) WriteEnvFile() (err error) {

output := []byte(ef.TopComment + string(envBytes))

err = ioutil.WriteFile(ef.Path, formatYAML(output), 0644)
// fix windows path
ef.Path = strings.ReplaceAll(ef.Path, `\`, `/`)
err = os.WriteFile(ef.Path, formatYAML(output), 0644)
if err != nil {
return g.Error(err, "could not write YAML file")
}
@@ -133,7 +134,7 @@ func formatYAML(input []byte) []byte {
}

func LoadEnvFile(path string) (ef EnvFile) {
bytes, _ := ioutil.ReadFile(path)
bytes, _ := os.ReadFile(path)
err := yaml.Unmarshal(bytes, &ef)
if err != nil {
err = g.Error(err, "error parsing yaml string")
3 changes: 1 addition & 2 deletions filesys/sheet.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
@@ -441,7 +440,7 @@ func NewGoogleSheet(props ...string) (ggs *GoogleSheet, err error) {
ggs.Props["GOOGLE_PASSWORD"] = os.Getenv("GOOGLE_PASSWORD")

// https://developers.google.com/sheets/api/quickstart/go
b, err := ioutil.ReadFile(ggs.Props["GSHEETS_CRED_FILE"])
b, err := os.ReadFile(ggs.Props["GSHEETS_CRED_FILE"])
if err != nil {
err = g.Error(err, "Unable to read client secret file: "+ggs.Props["GSHEETS_CRED_FILE"])
return
3 changes: 1 addition & 2 deletions filesys/sheet_test.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ package filesys

import (
"bufio"
"io/ioutil"
"os"
"testing"

@@ -154,7 +153,7 @@ func TestGoogleSheet(t *testing.T) {
err = ggs.deleteSheet("new")
assert.NoError(t, err)

jsonBody, err := ioutil.ReadFile(os.Getenv("GSHEETS_CRED_FILE"))
jsonBody, err := os.ReadFile(os.Getenv("GSHEETS_CRED_FILE"))
assert.NoError(t, err)

httpFs, err := NewFileSysClient(
4 changes: 2 additions & 2 deletions local/local.go
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ func (home *Home) Authenticate(url string) (err error) {
return
}

err = ioutil.WriteFile(home.authPath, fileBytes, 0600)
err = os.WriteFile(home.authPath, fileBytes, 0600)
if err != nil {
err = g.Error(err, "could not create dbio auth.json")
}
@@ -142,7 +142,7 @@ func (home *Home) Authenticate(url string) (err error) {
func (home *Home) APIKey() (key string) {
key = os.Getenv("dbio_API_KEY")
if key == "" {
fileBytes, err := ioutil.ReadFile(home.authPath)
fileBytes, err := os.ReadFile(home.authPath)
if err != nil {
return
}
13 changes: 6 additions & 7 deletions saas/airbyte/connector.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ package airbyte
import (
"context"
"embed"
"io/ioutil"
"os"
"path"
"runtime"
@@ -47,7 +46,7 @@ func GetSourceConnectors(fetch bool) (connectors Connectors, err error) {
if ok {
filePath := g.F("%s/sources.yaml", path.Dir(filename))
if g.PathExists(filePath) {
err = ioutil.WriteFile(filePath, respBytes, 0755)
err = os.WriteFile(filePath, respBytes, 0755)
if !g.LogError(err) {
g.Debug("wrote latest to %s", filePath)
}
@@ -176,7 +175,7 @@ func (c *Connector) Check(config map[string]interface{}) (s AirbyteConnectionSta
}
defer os.RemoveAll(c.tempFolder)

err = ioutil.WriteFile(c.file("config.json"), []byte(g.Marshal(config)), 0755)
err = os.WriteFile(c.file("config.json"), []byte(g.Marshal(config)), 0755)
if err != nil {
err = g.Error(err, "could not write to config file")
return
@@ -212,7 +211,7 @@ func (c *Connector) Discover(config map[string]interface{}) (ac AirbyteCatalog,
}
defer os.RemoveAll(c.tempFolder)

err = ioutil.WriteFile(c.file("config.json"), []byte(g.Marshal(config)), 0755)
err = os.WriteFile(c.file("config.json"), []byte(g.Marshal(config)), 0755)
if err != nil {
err = g.Error(err, "could not write to config file")
return
@@ -243,13 +242,13 @@ func (c *Connector) Read(config map[string]interface{}, catalog ConfiguredAirbyt
return
}

err = ioutil.WriteFile(c.file("config.json"), []byte(g.Marshal(config)), 0755)
err = os.WriteFile(c.file("config.json"), []byte(g.Marshal(config)), 0755)
if err != nil {
err = g.Error(err, "could not write to config file")
return
}

err = ioutil.WriteFile(c.file("catalog.json"), []byte(g.Marshal(catalog)), 0755)
err = os.WriteFile(c.file("catalog.json"), []byte(g.Marshal(catalog)), 0755)
if err != nil {
err = g.Error(err, "could not write to catalog file")
return
@@ -261,7 +260,7 @@ func (c *Connector) Read(config map[string]interface{}, catalog ConfiguredAirbyt
if props == nil {
props = map[string]string{}
}
err = ioutil.WriteFile(c.file("state.json"), []byte(g.Marshal(state)), 0755)
err = os.WriteFile(c.file("state.json"), []byte(g.Marshal(state)), 0755)
if err != nil {
err = g.Error(err, "could not write to state file")
return
3 changes: 1 addition & 2 deletions saas/airbyte/definitions_sync/definitions_sync.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"os"
"path/filepath"
"time"
@@ -69,7 +68,7 @@ func getSpecification(c airbyte.Connector, force bool) (err error) {
g.LogError(err, "could not marshall spec for: "+c.Definition.Name)
return
}
err = ioutil.WriteFile(filePath, specBytes, 0755)
err = os.WriteFile(filePath, specBytes, 0755)
if err != nil {
g.LogError(err, "could not write spec for: "+c.Definition.Name)
return

0 comments on commit 0fa6656

Please sign in to comment.