Changing deprecated functions in ./hack/update-codegen.sh (#1279)

* Changing deprecated functions in ./hack/update-codegen.sh

* Removing deprecrated I/O functions
This commit is contained in:
Aditya Bisht 2023-02-15 21:35:51 +05:30 committed by GitHub
parent 12035424cb
commit c16c224b8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -19,7 +19,6 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
@ -339,7 +338,7 @@ func (r *Reconciler) printGroupMembersAndSettings() error {
func (c *Config) Load(configFilePath string, confirmChanges bool) error {
log.Printf("reading config file: %s", configFilePath)
content, err := ioutil.ReadFile(configFilePath)
content, err := os.ReadFile(configFilePath)
if err != nil {
return fmt.Errorf("error reading config file %s: %w", configFilePath, err)
}
@ -371,7 +370,7 @@ func (c *Config) Load(configFilePath string, confirmChanges bool) error {
// nil if successful, or an error otherwise
func (rc *RestrictionsConfig) Load(path string) error {
log.Printf("reading restrictions config file: %s", path)
content, err := ioutil.ReadFile(path)
content, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("error reading restrictions config file %s: %w", path, err)
}
@ -414,7 +413,7 @@ func (gc *GroupsConfig) Load(rootDir string, restrictions *RestrictionsConfig) e
err error
)
if content, err = ioutil.ReadFile(path); err != nil {
if content, err = os.ReadFile(path); err != nil {
return fmt.Errorf("error reading groups config file %s: %w", path, err)
}
if err = yaml.Unmarshal(content, &groupsConfigAtPath); err != nil {

View File

@ -2,7 +2,6 @@ package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
@ -26,7 +25,7 @@ func main() {
}
infile, outfile := os.Args[2], os.Args[3]
f, err := ioutil.ReadFile(infile)
f, err := os.ReadFile(infile)
if err != nil {
log.Print("Unable to open ", err)
os.Exit(1)
@ -63,11 +62,11 @@ func main() {
`, infile)
output = append([]byte(preamble), output...)
prevOut, err := ioutil.ReadFile(outfile)
prevOut, err := os.ReadFile(outfile)
if err == nil && string(prevOut) == string(output) {
log.Print("No changes needed for ", outfile)
} else {
ioutil.WriteFile(outfile, output, 0644)
os.WriteFile(outfile, output, 0644)
log.Print("Wrote ", outfile)
}
}