diff --git a/.golangci.yaml b/.golangci.yaml index 1fc97cbf..2e8eac46 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -93,16 +93,13 @@ linters: fast: false enable: # These are the defaults for golangci-lint - - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - - structcheck - typecheck - unused - - varcheck # Also enable these - goconst diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf769448..9484e35d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ # limitations under the License. repos: - repo: https://github.com/golangci/golangci-lint - rev: v1.43.0 + rev: v1.51.1 hooks: - id: golangci-lint - repo: https://github.com/pre-commit/mirrors-prettier diff --git a/Dockerfile b/Dockerfile index e396a77e..d5d40fa1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ############################################################################### # Stage 1: Create the developer image for the BUILDPLATFORM only ############################################################################### -ARG GOLANG_VERSION=1.17 +ARG GOLANG_VERSION=1.19 FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION AS develop ARG PROTOC_VERSION=21.5 diff --git a/Makefile b/Makefile index eff2176f..4bda4657 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ run: use.develop .PHONY: test ## Run tests -test: +test: fmt ./scripts/run_tests.sh .PHONY: fmt diff --git a/go.mod b/go.mod index d8fe8fdd..4800018c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/kserve/modelmesh-runtime-adapter -go 1.17 +go 1.19 require ( cloud.google.com/go/storage v1.28.1 @@ -12,7 +12,7 @@ require ( github.com/go-logr/zapr v1.2.3 github.com/golang/mock v1.6.0 github.com/joho/godotenv v1.4.0 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.23.0 golang.org/x/sync v0.1.0 google.golang.org/api v0.114.0 diff --git a/go.sum b/go.sum index fd8dc67d..04ce271f 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/internal/envconfig/envconfig.go b/internal/envconfig/envconfig.go index b7ee18f9..7cac3ff1 100644 --- a/internal/envconfig/envconfig.go +++ b/internal/envconfig/envconfig.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "github.com/go-logr/logr" ) -// Returns the string value of environment variable "key" or the default value +// GetEnvString Returns the string value of environment variable "key" or the default value // if "key" is not set. Note if the environment variable is set to an empty // string, this will return an empty string, not defaultValue. func GetEnvString(key string, defaultValue string) string { @@ -31,7 +31,7 @@ func GetEnvString(key string, defaultValue string) string { return defaultValue } -// Returns the integer of value environment variable "key" or the default value +// GetEnvInt Returns the integer of value environment variable "key" or the default value // if "key" is not set. Note if the environment variable is set to a non // integer, including an empty string, this will fail and exit. func GetEnvInt(key string, defaultValue int, log logr.Logger) int { @@ -58,7 +58,7 @@ func GetEnvFloat(key string, defaultValue float64, log logr.Logger) float64 { return defaultValue } -// Returns the bool value of environment variable "key" or the default value +// GetEnvBool Returns the bool value of environment variable "key" or the default value // if "key" is not set. Note if the environment variable is set to a non // boolean, including an empty string, this will fail and exit. func GetEnvBool(key string, defaultValue bool, log logr.Logger) bool { @@ -73,7 +73,7 @@ func GetEnvBool(key string, defaultValue bool, log logr.Logger) bool { return defaultValue } -// Returns the duration value of environment variable "key" or a default value +// GetEnvDuration Returns the duration value of environment variable "key" or a default value // Note if the environment variable cannot be parsed as a duration, including an // empty string, this will fail and exit. func GetEnvDuration(key string, defaultValue time.Duration, log logr.Logger) time.Duration { diff --git a/internal/modelschema/modelschema.go b/internal/modelschema/modelschema.go index 38e63c69..11874037 100644 --- a/internal/modelschema/modelschema.go +++ b/internal/modelschema/modelschema.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -16,7 +16,7 @@ package modelschema import ( "encoding/json" "fmt" - "io/ioutil" + "os" ) // Filename for the schema JSON @@ -55,7 +55,7 @@ const ( ) func NewFromFile(schemaFilename string) (*ModelSchema, error) { - jsonBytes, err := ioutil.ReadFile(schemaFilename) + jsonBytes, err := os.ReadFile(schemaFilename) if err != nil { return nil, fmt.Errorf("Unable to read model schema file %s: %w", schemaFilename, err) } diff --git a/internal/util/connect.go b/internal/util/connect.go index c6dd8d61..11166df9 100644 --- a/internal/util/connect.go +++ b/internal/util/connect.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/internal/util/connect_test.go b/internal/util/connect_test.go index b51b15bc..8d4fd218 100644 --- a/internal/util/connect_test.go +++ b/internal/util/connect_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/internal/util/fileutil.go b/internal/util/fileutil.go index cfb6dcde..e157b05c 100644 --- a/internal/util/fileutil.go +++ b/internal/util/fileutil.go @@ -4,13 +4,14 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package util import ( @@ -22,7 +23,7 @@ import ( // RemoveFileFromListOfFileInfo // The input `files` content is modified, the order of elements is changed -func RemoveFileFromListOfFileInfo(filename string, files []os.FileInfo) (bool, []os.FileInfo) { +func RemoveFileFromListOfFileInfo(filename string, files []os.DirEntry) (bool, []os.DirEntry) { var fileIndex int = -1 for i, f := range files { if f.Name() == filename { @@ -38,7 +39,7 @@ func RemoveFileFromListOfFileInfo(filename string, files []os.FileInfo) (bool, [ return true, files[:len(files)-1] } -// Check if a file exists at path +// FileExists Check if a file exists at path func FileExists(path string) (bool, error) { if _, err := os.Stat(path); err == nil { return true, nil @@ -49,7 +50,7 @@ func FileExists(path string) (bool, error) { } } -// Clear contents of directory if it exists. +// ClearDirectoryContents Clear contents of directory if it exists. // If condition is specified then only delete dir entries to which it returns true func ClearDirectoryContents(dirPath string, condition func(entry os.DirEntry) bool) error { files, err := os.ReadDir(dirPath) diff --git a/internal/util/join.go b/internal/util/join.go index d6c11914..57f7607e 100644 --- a/internal/util/join.go +++ b/internal/util/join.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/internal/util/join_test.go b/internal/util/join_test.go index 594be78f..325c5819 100644 --- a/internal/util/join_test.go +++ b/internal/util/join_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/internal/util/loadmodel.go b/internal/util/loadmodel.go index 030ad85f..b9621b66 100644 --- a/internal/util/loadmodel.go +++ b/internal/util/loadmodel.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-mlserver-adapter/main.go b/model-mesh-mlserver-adapter/main.go index 163b2dce..368f47e4 100644 --- a/model-mesh-mlserver-adapter/main.go +++ b/model-mesh-mlserver-adapter/main.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-mlserver-adapter/server/adaptmodellayout_test.go b/model-mesh-mlserver-adapter/server/adaptmodellayout_test.go index 2a021be4..5e9c3914 100644 --- a/model-mesh-mlserver-adapter/server/adaptmodellayout_test.go +++ b/model-mesh-mlserver-adapter/server/adaptmodellayout_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -16,7 +16,6 @@ package server import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -98,7 +97,7 @@ func (tt adaptModelLayoutTestCase) writeConfigFile(t *testing.T) { if jerr != nil { t.Fatal("Error marshalling config JSON", jerr) } - if err := ioutil.WriteFile(configFullPath, jsonBytes, 0644); err != nil { + if err := os.WriteFile(configFullPath, jsonBytes, 0644); err != nil { t.Fatalf("Unable to write config JSON: %v", err) } } @@ -110,7 +109,7 @@ func (tt adaptModelLayoutTestCase) writeSchemaFile(t *testing.T) { } schemaFullPath := filepath.Join(tt.getSourceDir(), tt.SchemaPath) - if werr := ioutil.WriteFile(schemaFullPath, jsonBytes, 0644); werr != nil { + if werr := os.WriteFile(schemaFullPath, jsonBytes, 0644); werr != nil { t.Fatal("Error writing JSON to schema file", werr) } } @@ -533,7 +532,7 @@ func TestAdaptModelLayoutForRuntime(t *testing.T) { } // read in the config to assert on it - configJSON, err2 := ioutil.ReadFile(configFilePath) + configJSON, err2 := os.ReadFile(configFilePath) if err2 != nil { t.Fatalf("Unable to read config file %s: %v", configFilePath, err2) } @@ -635,7 +634,7 @@ func assertCreateEmptyFile(path string, t *testing.T) { func createFile(path, contents string) error { os.MkdirAll(filepath.Dir(path), 0755) - err := ioutil.WriteFile(path, []byte(contents), 0644) + err := os.WriteFile(path, []byte(contents), 0644) return err } diff --git a/model-mesh-mlserver-adapter/server/config.go b/model-mesh-mlserver-adapter/server/config.go index c6da9e38..0ceef9d9 100644 --- a/model-mesh-mlserver-adapter/server/config.go +++ b/model-mesh-mlserver-adapter/server/config.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-mlserver-adapter/server/server.go b/model-mesh-mlserver-adapter/server/server.go index 1c4d33db..5fc499f0 100644 --- a/model-mesh-mlserver-adapter/server/server.go +++ b/model-mesh-mlserver-adapter/server/server.go @@ -17,7 +17,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -180,7 +179,7 @@ func adaptModelLayoutForRuntime(rootModelDir, modelID, modelType, modelPath, sch err = adaptModelLayout(modelID, modelType, modelPath, schemaPath, mlserverModelIDDir, false, log) } else { // model path is a directory, inspect the files - files, err1 := ioutil.ReadDir(modelPath) + files, err1 := os.ReadDir(modelPath) if err1 != nil { return fmt.Errorf("Could not read files in dir %s: %w", modelPath, err) } @@ -216,7 +215,7 @@ func adaptModelLayoutForRuntime(rootModelDir, modelID, modelType, modelPath, sch // Only minimal changes should be made to the model repo to get it to load. For // MLServer, this means writing the model ID into the configuration file and // just symlinking all other files -func adaptNativeModelLayout(files []os.FileInfo, modelID, modelPath, schemaPath, targetDir string, log logr.Logger) error { +func adaptNativeModelLayout(files []os.DirEntry, modelID, modelPath, schemaPath, targetDir string, log logr.Logger) error { for _, f := range files { filename := f.Name() source, err := util.SecureJoin(modelPath, filename) @@ -226,9 +225,9 @@ func adaptNativeModelLayout(files []os.FileInfo, modelID, modelPath, schemaPath, } // special handling of the config file if filename == mlserverRepositoryConfigFilename { - configJSON, err1 := ioutil.ReadFile(source) + configJSON, err1 := os.ReadFile(source) if err1 != nil { - return fmt.Errorf("Could not read model config file %s: %w", source, err1) + return fmt.Errorf("could not read model config file %s: %w", source, err1) } // process the config to set the model's `name` to the model-mesh model id @@ -243,9 +242,11 @@ func adaptNativeModelLayout(files []os.FileInfo, modelID, modelPath, schemaPath, "mlserverRepositoryConfigFilename", mlserverRepositoryConfigFilename) return jerr } - err1 = ioutil.WriteFile(target, processedConfigJSON, f.Mode()) + + fInfo, _ := f.Info() + err1 = os.WriteFile(target, processedConfigJSON, fInfo.Mode()) if err1 != nil { - return fmt.Errorf("Error writing config file %s: %w", source, err1) + return fmt.Errorf("error writing config file %s: %w", source, err1) } continue } @@ -257,7 +258,7 @@ func adaptNativeModelLayout(files []os.FileInfo, modelID, modelPath, schemaPath, } err = os.Symlink(source, link) if err != nil { - return fmt.Errorf("Error creating symlink to %s: %w", source, err) + return fmt.Errorf("error creating symlink to %s: %w", source, err) } } @@ -346,7 +347,7 @@ func adaptModelLayout(modelID, modelType, modelPath, schemaPath, targetDir strin "mlserverRepositoryConfigFilename", mlserverRepositoryConfigFilename) return err } - if err = ioutil.WriteFile(target, configJSON, 0664); err != nil { + if err = os.WriteFile(target, configJSON, 0664); err != nil { return fmt.Errorf("Error writing generated config file for %s: %w", modelID, err) } diff --git a/model-mesh-mlserver-adapter/server/server_test.go b/model-mesh-mlserver-adapter/server/server_test.go index dd4625f4..0e1d3726 100644 --- a/model-mesh-mlserver-adapter/server/server_test.go +++ b/model-mesh-mlserver-adapter/server/server_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -18,7 +18,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -215,7 +214,7 @@ func TestProcessConfigJSON(t *testing.T) { } func assertGeneratedModelDirIsCorrect(sourceDir string, generatedDir string, modelID string, t *testing.T) { - generatedFiles, err := ioutil.ReadDir(generatedDir) + generatedFiles, err := os.ReadDir(generatedDir) if err != nil { t.Errorf("Could not read files in generated dir [%s]: %v", generatedDir, err) } @@ -227,7 +226,7 @@ func assertGeneratedModelDirIsCorrect(sourceDir string, generatedDir string, mod if f.Name() == mlserverRepositoryConfigFilename { configFileFound = true // should have `name` field matching the modelID - configJSON, err := ioutil.ReadFile(filePath) + configJSON, err := os.ReadFile(filePath) if err != nil { t.Errorf("Unable to read config file %s: %v", filePath, err) } @@ -245,7 +244,7 @@ func assertGeneratedModelDirIsCorrect(sourceDir string, generatedDir string, mod // if not the config file, it should be a symlink pointing to a file in the // source dir that exists - if f.Mode()&os.ModeSymlink != os.ModeSymlink { + if f.Type()&os.ModeSymlink != os.ModeSymlink { t.Errorf("Expected [%s] to be a symlink.", filePath) } diff --git a/model-mesh-ovms-adapter/main.go b/model-mesh-ovms-adapter/main.go index 3a501d42..92f48f6f 100644 --- a/model-mesh-ovms-adapter/main.go +++ b/model-mesh-ovms-adapter/main.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-ovms-adapter/server/adaptmodellayout.go b/model-mesh-ovms-adapter/server/adaptmodellayout.go index aec36f7f..09d6a0eb 100644 --- a/model-mesh-ovms-adapter/server/adaptmodellayout.go +++ b/model-mesh-ovms-adapter/server/adaptmodellayout.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -16,7 +16,6 @@ package server import ( "context" "fmt" - "io/ioutil" "os" "path/filepath" "strconv" @@ -53,7 +52,7 @@ func adaptModelLayoutForRuntime(ctx context.Context, rootModelDir, modelID, mode // simple case if ModelPath points to a file err = createOvmsModelRepositoryFromPath(modelPath, "1", schemaPath, modelType, ovmsModelIDDir, log) } else { - files, err1 := ioutil.ReadDir(modelPath) + files, err1 := os.ReadDir(modelPath) if err1 != nil { return fmt.Errorf("Could not read files in dir %s: %w", modelPath, err1) } @@ -68,7 +67,7 @@ func adaptModelLayoutForRuntime(ctx context.Context, rootModelDir, modelID, mode // Creates the ovms model structure /models/_ovms_models/model-id/1/ // Within this path there will be a symlink back to the original /models/model-id directory tree. -func createOvmsModelRepositoryFromDirectory(files []os.FileInfo, modelPath, schemaPath, modelType, ovmsModelIDDir string, log logr.Logger) error { +func createOvmsModelRepositoryFromDirectory(files []os.DirEntry, modelPath, schemaPath, modelType, ovmsModelIDDir string, log logr.Logger) error { var err error // allow the directory to contain version directories @@ -126,8 +125,8 @@ func createOvmsModelRepositoryFromPath(modelPath, versionNumber, schemaPath, mod } // Returns the largest positive int dir as long as all fileInfo dirs are integers (files are ignored). -// If fileInfos is empty or contains any any non-integer dirs, this will return the empty string. -func largestNumberDir(fileInfos []os.FileInfo) string { +// If fileInfos is empty or contains any non-integer dirs, this will return the empty string. +func largestNumberDir(fileInfos []os.DirEntry) string { largestInt := 0 largestDir := "" for _, f := range fileInfos { diff --git a/model-mesh-ovms-adapter/server/adaptmodellayout_test.go b/model-mesh-ovms-adapter/server/adaptmodellayout_test.go index eec0657b..3d750027 100644 --- a/model-mesh-ovms-adapter/server/adaptmodellayout_test.go +++ b/model-mesh-ovms-adapter/server/adaptmodellayout_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -16,7 +16,6 @@ package server import ( "context" "encoding/json" - "io/ioutil" "os" "path/filepath" "testing" @@ -82,7 +81,7 @@ func (tt adaptModelLayoutTestCase) writeSchemaFile(t *testing.T) { } schemaFullpath := filepath.Join(tt.getSourceDir(), tt.SchemaPath) - if werr := ioutil.WriteFile(schemaFullpath, jsonBytes, 0644); werr != nil { + if werr := os.WriteFile(schemaFullpath, jsonBytes, 0644); werr != nil { t.Fatal("Error writing JSON to schema file", werr) } } @@ -253,9 +252,7 @@ func findSymlinks(root string) []string { return result } -// // Definition of writeModelLayoutForRuntime test cases -// var adaptModelLayoutTests = []adaptModelLayoutTestCase{ // Group: ONNX format { diff --git a/model-mesh-ovms-adapter/server/config.go b/model-mesh-ovms-adapter/server/config.go index a8bcc33f..d24fd135 100644 --- a/model-mesh-ovms-adapter/server/config.go +++ b/model-mesh-ovms-adapter/server/config.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-ovms-adapter/server/const.go b/model-mesh-ovms-adapter/server/const.go index 8221e648..ff0f5bbe 100644 --- a/model-mesh-ovms-adapter/server/const.go +++ b/model-mesh-ovms-adapter/server/const.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-ovms-adapter/server/modelconfig.go b/model-mesh-ovms-adapter/server/modelconfig.go index 5b3a8ef5..9477a36e 100644 --- a/model-mesh-ovms-adapter/server/modelconfig.go +++ b/model-mesh-ovms-adapter/server/modelconfig.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -19,22 +19,23 @@ package server // JSON Schema: https://github.com/openvinotoolkit/model_server/blob/eab97207fbe9078f83a3f85b468418555b02959a/src/schema.cpp#L28 // // EXAMPLE: -// { -// "model_config_list": [ -// { -// "config": { -// "name": "model_name1", -// "base_path": "/models/model1" -// } -// }, -// { -// "config": { -// "name": "model_name2", -// "base_path": "/models/model1" -// } -// } -// ] -// } +// +// { +// "model_config_list": [ +// { +// "config": { +// "name": "model_name1", +// "base_path": "/models/model1" +// } +// }, +// { +// "config": { +// "name": "model_name2", +// "base_path": "/models/model1" +// } +// } +// ] +// } type OvmsMultiModelRepositoryConfig struct { ModelConfigList []OvmsMultiModelConfigListEntry `json:"model_config_list"` } diff --git a/model-mesh-ovms-adapter/server/modelmanager.go b/model-mesh-ovms-adapter/server/modelmanager.go index 9f2df8d1..fca6739b 100644 --- a/model-mesh-ovms-adapter/server/modelmanager.go +++ b/model-mesh-ovms-adapter/server/modelmanager.go @@ -4,13 +4,14 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package server import ( @@ -20,7 +21,6 @@ import ( "fmt" "io" "io/fs" - "io/ioutil" "net/http" "os" "path/filepath" @@ -261,7 +261,7 @@ type request struct { // Run loop for the manager's internal actor that owns the model repository config // -// Maintains a slice of batched requests that are in process in the reload +// # Maintains a slice of batched requests that are in process in the reload // // Returns results from the reload operation once it completes // Receives a stream of requests from its channel @@ -343,7 +343,6 @@ func (mm *OvmsModelManager) run() { // requests that will not change the state and ignoring requests that are // cancelled. // -// // We need a criteria to determine when to stop grabbing requests after a reload // is needed; here we take the approach of waiting for a period of time after a // request is received @@ -512,7 +511,7 @@ func (mm *OvmsModelManager) writeConfig() error { return fmt.Errorf("Error marshalling config file: %w", err) } - if err := ioutil.WriteFile(mm.modelConfigFilename, modelRepositoryConfigJSON, mm.config.ModelConfigFilePerms); err != nil { + if err := os.WriteFile(mm.modelConfigFilename, modelRepositoryConfigJSON, mm.config.ModelConfigFilePerms); err != nil { return fmt.Errorf("Error writing config file: %w", err) } diff --git a/model-mesh-ovms-adapter/server/modelmanager_test.go b/model-mesh-ovms-adapter/server/modelmanager_test.go index cc08d9ce..2355278a 100644 --- a/model-mesh-ovms-adapter/server/modelmanager_test.go +++ b/model-mesh-ovms-adapter/server/modelmanager_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-ovms-adapter/server/server.go b/model-mesh-ovms-adapter/server/server.go index efe2efc7..3c7399d8 100644 --- a/model-mesh-ovms-adapter/server/server.go +++ b/model-mesh-ovms-adapter/server/server.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-ovms-adapter/server/server_test.go b/model-mesh-ovms-adapter/server/server_test.go index f38c9b16..7ef32e7f 100644 --- a/model-mesh-ovms-adapter/server/server_test.go +++ b/model-mesh-ovms-adapter/server/server_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -18,7 +18,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "net/http" "os" "os/exec" @@ -255,7 +254,7 @@ func TestAdapter(t *testing.T) { } func checkEntryExistsInModelConfig(modelid string, path string) error { - configBytes, err := ioutil.ReadFile(testModelConfigFile) + configBytes, err := os.ReadFile(testModelConfigFile) if err != nil { return fmt.Errorf("Unable to read config file: %w", err) } diff --git a/model-mesh-torchserve-adapter/main.go b/model-mesh-torchserve-adapter/main.go index 333fbf8c..43c45071 100644 --- a/model-mesh-torchserve-adapter/main.go +++ b/model-mesh-torchserve-adapter/main.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-torchserve-adapter/server/config.go b/model-mesh-torchserve-adapter/server/config.go index 07cd2449..a74aaba2 100644 --- a/model-mesh-torchserve-adapter/server/config.go +++ b/model-mesh-torchserve-adapter/server/config.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-torchserve-adapter/server/server.go b/model-mesh-torchserve-adapter/server/server.go index 03843460..45bccdd6 100644 --- a/model-mesh-torchserve-adapter/server/server.go +++ b/model-mesh-torchserve-adapter/server/server.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-torchserve-adapter/server/server_test.go b/model-mesh-torchserve-adapter/server/server_test.go index c2f0ced6..f8ffb4cf 100644 --- a/model-mesh-torchserve-adapter/server/server_test.go +++ b/model-mesh-torchserve-adapter/server/server_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-torchserve-adapter/torchserve/mock_torchserve_server.go b/model-mesh-torchserve-adapter/torchserve/mock_torchserve_server.go index dbac8c13..9cf2e4d1 100644 --- a/model-mesh-torchserve-adapter/torchserve/mock_torchserve_server.go +++ b/model-mesh-torchserve-adapter/torchserve/mock_torchserve_server.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -105,10 +105,10 @@ func serve(server *grpc.Server, port uint16, log logr.Logger) { // Implements gomock TestReporter interface: // -// type TestReporter interface { -// Errorf(format string, args ...interface{}) -// Fatalf(format string, args ...interface{}) -// } +// type TestReporter interface { +// Errorf(format string, args ...interface{}) +// Fatalf(format string, args ...interface{}) +// } type CustomReporter struct { log logr.Logger } diff --git a/model-mesh-triton-adapter/main.go b/model-mesh-triton-adapter/main.go index ec9493cd..8391fd66 100644 --- a/model-mesh-triton-adapter/main.go +++ b/model-mesh-triton-adapter/main.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/server/adaptmodellayout.go b/model-mesh-triton-adapter/server/adaptmodellayout.go index 394cc5df..3663bbf2 100644 --- a/model-mesh-triton-adapter/server/adaptmodellayout.go +++ b/model-mesh-triton-adapter/server/adaptmodellayout.go @@ -4,20 +4,20 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package server import ( "context" "errors" "fmt" - "io/ioutil" "os" "path/filepath" "strconv" @@ -100,7 +100,7 @@ func adaptModelLayoutForRuntime(ctx context.Context, rootModelDir, modelID, mode // simple case if ModelPath points to a file err = createTritonModelRepositoryFromPath(modelPath, "1", schemaPath, modelType, tritonModelIDDir, log) } else { - files, err1 := ioutil.ReadDir(modelPath) + files, err1 := os.ReadDir(modelPath) if err1 != nil { return fmt.Errorf("Could not read files in dir %s: %w", modelPath, err1) } @@ -121,7 +121,7 @@ func adaptModelLayoutForRuntime(ctx context.Context, rootModelDir, modelID, mode // Creates the triton model structure /models/_triton_models/model-id/1/model.X where // model.X is a file or directory with a name defined by the model type (see modelTypeToDirNameMapping and modelTypeToFileNameMapping). // Within this path there will be a symlink back to the original /models/model-id directory tree. -func createTritonModelRepositoryFromDirectory(files []os.FileInfo, modelPath, schemaPath, modelType, tritonModelIDDir string, log logr.Logger) error { +func createTritonModelRepositoryFromDirectory(files []os.DirEntry, modelPath, schemaPath, modelType, tritonModelIDDir string, log logr.Logger) error { var err error // for backwards compatibility, remove any file called _schema.json from @@ -138,7 +138,7 @@ func createTritonModelRepositoryFromDirectory(files []os.FileInfo, modelPath, sc return err } - if files, err = ioutil.ReadDir(modelPath); err != nil { + if files, err = os.ReadDir(modelPath); err != nil { return fmt.Errorf("Could not read files in dir %s: %w", modelPath, err) } } else { @@ -233,7 +233,7 @@ func createTritonModelRepositoryFromPath(modelPath, versionNumber, schemaPath, m // If the Triton specific config file exists, assume the model files has the // proper structure, but process the config.pbtxt to remove the `name` field. // All other files are symlinked to their source -func adaptNativeModelLayout(files []os.FileInfo, sourceModelIDDir, schemaPath, tritonModelIDDir string, log logr.Logger) error { +func adaptNativeModelLayout(files []os.DirEntry, sourceModelIDDir, schemaPath, tritonModelIDDir string, log logr.Logger) error { for _, f := range files { var err1 error filename := f.Name() @@ -245,7 +245,7 @@ func adaptNativeModelLayout(files []os.FileInfo, sourceModelIDDir, schemaPath, t // special handling of the config file if filename == tritonRepositoryConfigFilename { - pbtxt, err2 := ioutil.ReadFile(source) + pbtxt, err2 := os.ReadFile(source) if err2 != nil { return fmt.Errorf("Error reading config file %s: %w", source, err2) } @@ -261,7 +261,8 @@ func adaptNativeModelLayout(files []os.FileInfo, sourceModelIDDir, schemaPath, t return err2 } - if err2 = ioutil.WriteFile(target, processedPbtxt, f.Mode()); err2 != nil { + info, _ := f.Info() + if err2 = os.WriteFile(target, processedPbtxt, info.Mode()); err2 != nil { return fmt.Errorf("Error writing config file %s: %w", source, err2) } @@ -283,8 +284,8 @@ func adaptNativeModelLayout(files []os.FileInfo, sourceModelIDDir, schemaPath, t } // Returns the largest positive int dir as long as all fileInfo dirs are integers (files are ignored). -// If fileInfos is empty or contains any any non-integer dirs, this will return the empty string. -func largestNumberDir(fileInfos []os.FileInfo) string { +// If fileInfos is empty or contains any non-integer dirs, this will return the empty string. +func largestNumberDir(fileInfos []os.DirEntry) string { largestInt := 0 largestDir := "" for _, f := range fileInfos { @@ -307,8 +308,8 @@ func largestNumberDir(fileInfos []os.FileInfo) string { // Returns true if these the files make up the top level of a triton model repository. // In other words, the parent of the files is the root of the triton repository (we don't pass the parent path // because then we'd have to read the filesystem more than once). -// Currently this is using the existence of file 'config.pbtxt' to determine it is a triton repository. -func isTritonModelRepository(files []os.FileInfo) bool { +// Currently, this is using the existence of file 'config.pbtxt' to determine it is a triton repository. +func isTritonModelRepository(files []os.DirEntry) bool { for _, f := range files { if f.Name() == tritonRepositoryConfigFilename { return true diff --git a/model-mesh-triton-adapter/server/adaptmodellayout_test.go b/model-mesh-triton-adapter/server/adaptmodellayout_test.go index b390f05a..c077440d 100644 --- a/model-mesh-triton-adapter/server/adaptmodellayout_test.go +++ b/model-mesh-triton-adapter/server/adaptmodellayout_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -17,7 +17,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -172,7 +171,7 @@ func (tt adaptModelLayoutTestCase) writeSchemaFile(t *testing.T) { } schemaFullpath := filepath.Join(tt.getSourceDir(), tt.SchemaPath) - if werr := ioutil.WriteFile(schemaFullpath, jsonBytes, 0644); werr != nil { + if werr := os.WriteFile(schemaFullpath, jsonBytes, 0644); werr != nil { t.Fatal("Error writing JSON to schema file", werr) } } @@ -278,7 +277,7 @@ func assertConfigFileContents(t *testing.T, tt adaptModelLayoutTestCase) { // read in the generated config file configFilePath := filepath.Join(tt.getTargetDir(), "config.pbtxt") - configFileContents, err := ioutil.ReadFile(configFilePath) + configFileContents, err := os.ReadFile(configFilePath) if err != nil { t.Fatalf("Unable to read config file [%s]: %v", configFilePath, err) } @@ -379,9 +378,7 @@ func findSymlinks(root string) []string { return result } -// // Definition of writeModelLayoutForRuntime test cases -// var adaptModelLayoutTests = []adaptModelLayoutTestCase{ // Group: file layout / model path support { diff --git a/model-mesh-triton-adapter/server/config.go b/model-mesh-triton-adapter/server/config.go index 31ae3d30..1fa136aa 100644 --- a/model-mesh-triton-adapter/server/config.go +++ b/model-mesh-triton-adapter/server/config.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/server/const.go b/model-mesh-triton-adapter/server/const.go index 599c5639..c7e3b768 100644 --- a/model-mesh-triton-adapter/server/const.go +++ b/model-mesh-triton-adapter/server/const.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/server/schema.go b/model-mesh-triton-adapter/server/schema.go index 93835d08..da459e88 100644 --- a/model-mesh-triton-adapter/server/schema.go +++ b/model-mesh-triton-adapter/server/schema.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/server/schema_test.go b/model-mesh-triton-adapter/server/schema_test.go index 6008d5d4..8f6959d7 100644 --- a/model-mesh-triton-adapter/server/schema_test.go +++ b/model-mesh-triton-adapter/server/schema_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/server/server.go b/model-mesh-triton-adapter/server/server.go index 05f64a71..6b831f14 100644 --- a/model-mesh-triton-adapter/server/server.go +++ b/model-mesh-triton-adapter/server/server.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/server/server_test.go b/model-mesh-triton-adapter/server/server_test.go index 5262c8e9..9434ed70 100644 --- a/model-mesh-triton-adapter/server/server_test.go +++ b/model-mesh-triton-adapter/server/server_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -17,7 +17,6 @@ import ( "context" "flag" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -156,7 +155,7 @@ func TestAdapter(t *testing.T) { // Check that the `name` property was removed from the config file { var err1 error - pbtxt, err1 := ioutil.ReadFile(configFile) + pbtxt, err1 := os.ReadFile(configFile) if err1 != nil { t.Errorf("Unable to read config file %s: %v", configFile, err) } diff --git a/model-mesh-triton-adapter/server/utils.go b/model-mesh-triton-adapter/server/utils.go index 39484124..7bc456b5 100644 --- a/model-mesh-triton-adapter/server/utils.go +++ b/model-mesh-triton-adapter/server/utils.go @@ -4,13 +4,14 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package server import ( @@ -18,7 +19,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "os" "os/exec" "strconv" @@ -55,7 +55,7 @@ func writeConfigPbtxt(filename string, modelConfig *triton.ModelConfig) error { return fmt.Errorf("Unable to marshal config.pbtxt: %w", err) } - if err = ioutil.WriteFile(filename, pbtxtOut, 0644); err != nil { + if err = os.WriteFile(filename, pbtxtOut, 0644); err != nil { return fmt.Errorf("Unable to write config.pbtxt: %w", err) } return nil diff --git a/model-mesh-triton-adapter/triton/adapter_client/adapter_client.go b/model-mesh-triton-adapter/triton/adapter_client/adapter_client.go index d881072c..079428bc 100644 --- a/model-mesh-triton-adapter/triton/adapter_client/adapter_client.go +++ b/model-mesh-triton-adapter/triton/adapter_client/adapter_client.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/triton/mesh_client/mesh_client.go b/model-mesh-triton-adapter/triton/mesh_client/mesh_client.go index 0b78e950..ab0c27b3 100644 --- a/model-mesh-triton-adapter/triton/mesh_client/mesh_client.go +++ b/model-mesh-triton-adapter/triton/mesh_client/mesh_client.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-mesh-triton-adapter/triton/mock_triton_server.go b/model-mesh-triton-adapter/triton/mock_triton_server.go index a9c18e2b..a9ba2b4b 100644 --- a/model-mesh-triton-adapter/triton/mock_triton_server.go +++ b/model-mesh-triton-adapter/triton/mock_triton_server.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/main.go b/model-serving-puller/main.go index 3bd2d6ed..487b021e 100644 --- a/model-serving-puller/main.go +++ b/model-serving-puller/main.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/puller/config.go b/model-serving-puller/puller/config.go index 2ccd8130..2af39601 100644 --- a/model-serving-puller/puller/config.go +++ b/model-serving-puller/puller/config.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -16,13 +16,13 @@ package puller import ( "encoding/json" "fmt" - "io/ioutil" "os" "github.com/go-logr/logr" - . "github.com/kserve/modelmesh-runtime-adapter/internal/envconfig" "github.com/kserve/modelmesh-runtime-adapter/internal/util" + + . "github.com/kserve/modelmesh-runtime-adapter/internal/envconfig" ) // PullerConfiguration stores configuration variables for the puller server @@ -72,7 +72,7 @@ func (config *PullerConfiguration) GetStorageConfiguration(storageKey string, lo return nil, fmt.Errorf("Storage secretKey not found: %s", storageKey) } - bytes, err := ioutil.ReadFile(configPath) + bytes, err := os.ReadFile(configPath) if err != nil { return nil, fmt.Errorf("Could not read storage configuration from %s: %v", configPath, err) } diff --git a/model-serving-puller/puller/dotpath.go b/model-serving-puller/puller/dotpath.go index dbb73ee7..42329d15 100644 --- a/model-serving-puller/puller/dotpath.go +++ b/model-serving-puller/puller/dotpath.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/puller/dotpath_test.go b/model-serving-puller/puller/dotpath_test.go index 75684ba9..7441b913 100644 --- a/model-serving-puller/puller/dotpath_test.go +++ b/model-serving-puller/puller/dotpath_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/puller/puller.go b/model-serving-puller/puller/puller.go index 6229f1dc..89481e91 100644 --- a/model-serving-puller/puller/puller.go +++ b/model-serving-puller/puller/puller.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -17,7 +17,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" @@ -58,7 +57,8 @@ type Puller struct { } // PullerInterface is the interface for `pullman` -// useful to mock for testing +// +// useful to mock for testing type PullerInterface interface { Pull(context.Context, pullman.PullCommand) error } @@ -291,7 +291,7 @@ func (p *Puller) ClearLocalModelStorage(exclude string) error { } func (p *Puller) ListModels() ([]string, error) { - entries, err := ioutil.ReadDir(p.PullerConfig.RootModelDir) + entries, err := os.ReadDir(p.PullerConfig.RootModelDir) if err != nil { return nil, err } diff --git a/model-serving-puller/puller/puller_test.go b/model-serving-puller/puller/puller_test.go index 0db7586f..5d86a4ff 100644 --- a/model-serving-puller/puller/puller_test.go +++ b/model-serving-puller/puller/puller_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -17,7 +17,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -99,7 +98,7 @@ func eqPullCommand(pc *pullman.PullCommand) gomock.Matcher { // helper to create a RepositoryConfig from the testdata storage config dir func readStorageConfig(key string) (*pullman.RepositoryConfig, error) { - j, err := ioutil.ReadFile(filepath.Join(StorageConfigDir, key)) + j, err := os.ReadFile(filepath.Join(StorageConfigDir, key)) if err != nil { return nil, err } @@ -428,7 +427,7 @@ func Test_ProcessLoadModelRequest_SuccessStorageTypeOnly(t *testing.T) { func Test_ProcessLoadModelRequest_DefaultStorageKey(t *testing.T) { // create a typeless default storage config file for this test defaultConfigFile := filepath.Join(StorageConfigDir, "default") - err := ioutil.WriteFile(defaultConfigFile, []byte(`{"type": "typeless-default"}`), 0555) + err := os.WriteFile(defaultConfigFile, []byte(`{"type": "typeless-default"}`), 0555) assert.NoError(t, err) defer func() { errd := os.Remove(defaultConfigFile) diff --git a/model-serving-puller/server/config.go b/model-serving-puller/server/config.go index 73481f17..aa8c4797 100644 --- a/model-serving-puller/server/config.go +++ b/model-serving-puller/server/config.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/server/modelstate.go b/model-serving-puller/server/modelstate.go index 25488f87..68b601a8 100644 --- a/model-serving-puller/server/modelstate.go +++ b/model-serving-puller/server/modelstate.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/server/modelstate_test.go b/model-serving-puller/server/modelstate_test.go index d830db51..ada5a067 100644 --- a/model-serving-puller/server/modelstate_test.go +++ b/model-serving-puller/server/modelstate_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/server/server.go b/model-serving-puller/server/server.go index e5d31466..d3b97026 100644 --- a/model-serving-puller/server/server.go +++ b/model-serving-puller/server/server.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/model-serving-puller/server/server_test.go b/model-serving-puller/server/server_test.go index 03ab95d8..0478f396 100644 --- a/model-serving-puller/server/server_test.go +++ b/model-serving-puller/server/server_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/cache.go b/pullman/cache.go index 53a7c55f..d6573450 100644 --- a/pullman/cache.go +++ b/pullman/cache.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/cache_test.go b/pullman/cache_test.go index 0a2bdb3e..9d49a6af 100644 --- a/pullman/cache_test.go +++ b/pullman/cache_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/cmd/main.go b/pullman/cmd/main.go index d9f62648..ff6fc6ba 100644 --- a/pullman/cmd/main.go +++ b/pullman/cmd/main.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -18,7 +18,7 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" + "os" "github.com/go-logr/zapr" "go.uber.org/zap" @@ -65,7 +65,7 @@ func main() { manager := pullman.NewPullManager(zapr.NewLogger(zaplog)) // create repository from the config file - configMapJSON, err := ioutil.ReadFile(configFilename) + configMapJSON, err := os.ReadFile(configFilename) if err != nil { fmt.Printf("Error reading config file [%s]: %v\n", configFilename, err) return diff --git a/pullman/config.go b/pullman/config.go index 849350c4..909a74b0 100644 --- a/pullman/config.go +++ b/pullman/config.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/config_test.go b/pullman/config_test.go index 74a8fa81..006166b1 100644 --- a/pullman/config_test.go +++ b/pullman/config_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/helpers.go b/pullman/helpers.go index eea88dad..85d53428 100644 --- a/pullman/helpers.go +++ b/pullman/helpers.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/pullman.go b/pullman/pullman.go index 0ce0be19..51369c16 100644 --- a/pullman/pullman.go +++ b/pullman/pullman.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/pullman_test.go b/pullman/pullman_test.go index dd02a0f9..a647e263 100644 --- a/pullman/pullman_test.go +++ b/pullman/pullman_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/azure/downloader.go b/pullman/storageproviders/azure/downloader.go index 698f8481..6a38595d 100644 --- a/pullman/storageproviders/azure/downloader.go +++ b/pullman/storageproviders/azure/downloader.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/azure/provider.go b/pullman/storageproviders/azure/provider.go index 6651fd49..92bd721b 100644 --- a/pullman/storageproviders/azure/provider.go +++ b/pullman/storageproviders/azure/provider.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/azure/provider_test.go b/pullman/storageproviders/azure/provider_test.go index 7ca9b1fb..ce327e6b 100644 --- a/pullman/storageproviders/azure/provider_test.go +++ b/pullman/storageproviders/azure/provider_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/gcs/downloader.go b/pullman/storageproviders/gcs/downloader.go index c95ee225..d9ebb631 100644 --- a/pullman/storageproviders/gcs/downloader.go +++ b/pullman/storageproviders/gcs/downloader.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/gcs/provider.go b/pullman/storageproviders/gcs/provider.go index d2a71199..69cbaead 100644 --- a/pullman/storageproviders/gcs/provider.go +++ b/pullman/storageproviders/gcs/provider.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/gcs/provider_test.go b/pullman/storageproviders/gcs/provider_test.go index 0f534633..b113b714 100644 --- a/pullman/storageproviders/gcs/provider_test.go +++ b/pullman/storageproviders/gcs/provider_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/http/downloader.go b/pullman/storageproviders/http/downloader.go index 2e320d19..dc3332cf 100644 --- a/pullman/storageproviders/http/downloader.go +++ b/pullman/storageproviders/http/downloader.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/http/provider.go b/pullman/storageproviders/http/provider.go index 2d70d77a..18a97cc5 100644 --- a/pullman/storageproviders/http/provider.go +++ b/pullman/storageproviders/http/provider.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/http/provider_test.go b/pullman/storageproviders/http/provider_test.go index b3e85efe..a51a455f 100644 --- a/pullman/storageproviders/http/provider_test.go +++ b/pullman/storageproviders/http/provider_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/pvc/provider.go b/pullman/storageproviders/pvc/provider.go index 68139b50..949c71f4 100644 --- a/pullman/storageproviders/pvc/provider.go +++ b/pullman/storageproviders/pvc/provider.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/pvc/provider_test.go b/pullman/storageproviders/pvc/provider_test.go index 66685257..ca316745 100644 --- a/pullman/storageproviders/pvc/provider_test.go +++ b/pullman/storageproviders/pvc/provider_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/s3/downloader.go b/pullman/storageproviders/s3/downloader.go index 74184717..0cb8be14 100644 --- a/pullman/storageproviders/s3/downloader.go +++ b/pullman/storageproviders/s3/downloader.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/s3/downloader_test.go b/pullman/storageproviders/s3/downloader_test.go index aa058e99..fd88e02c 100644 --- a/pullman/storageproviders/s3/downloader_test.go +++ b/pullman/storageproviders/s3/downloader_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/s3/provider.go b/pullman/storageproviders/s3/provider.go index 22fd4998..a33aba7c 100644 --- a/pullman/storageproviders/s3/provider.go +++ b/pullman/storageproviders/s3/provider.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/storageproviders/s3/provider_test.go b/pullman/storageproviders/s3/provider_test.go index 4b306053..429fdcc5 100644 --- a/pullman/storageproviders/s3/provider_test.go +++ b/pullman/storageproviders/s3/provider_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pullman/types.go b/pullman/types.go index 5d65dfda..e11a3b4a 100644 --- a/pullman/types.go +++ b/pullman/types.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/scripts/fmt.sh b/scripts/fmt.sh index 7617f0ce..4821ffd7 100755 --- a/scripts/fmt.sh +++ b/scripts/fmt.sh @@ -13,9 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License.# +# Fix: 'fatal: detected dubious ownership in repository', +# only do this if it is running into the develop image +if [ "${PWD}" == "/opt/app" ]; then + git config --global --add safe.directory "*" +fi + pre-commit run --all-files RETURN_CODE=$? +## cat this file for helping on identifying the root cause when some issue happens +if [ -f /$USER/.cache/pre-commit/pre-commit.log ]; then + cat /$USER/.cache/pre-commit/pre-commit.log +fi + function echoError() { LIGHT_YELLOW='\033[1;33m' NC='\033[0m' # No Color