fix: return error instead of log.Fatalf() (#5625)

* fix: return error instead of log.Fatalf()

* chore: add meaningful message to error output

* chore: add meaningful message to fatal function
This commit is contained in:
Yusuke Abe
2024-04-18 19:56:51 +09:00
committed by GitHub
parent 82ee768212
commit ed09399cd1
11 changed files with 412 additions and 190 deletions

View File

@@ -41,7 +41,7 @@ s/$BAR/bar baz/g
}
pvd := provider.NewDefaultDepProvider()
rf := resmap.NewFactory(pvd.GetResourceFactory())
pluginConfig := rf.RF().FromMap(
pluginConfig, err := rf.RF().FromMap(
map[string]interface{}{
"apiVersion": "someteam.example.com/v1",
"kind": "SedTransformer",
@@ -51,6 +51,9 @@ s/$BAR/bar baz/g
"argsOneLiner": "one two 'foo bar'",
"argsFromFile": "sed-input.txt",
})
if err != nil {
t.Fatalf("failed to writes the data to a file: %v", err)
}
pluginConfig.RemoveBuildAnnotations()
pc := types.DisabledPluginConfig()

View File

@@ -32,11 +32,14 @@ func TestDeterminePluginSrcRoot(t *testing.T) {
}
func makeConfigMap(rf *resource.Factory, name, behavior string, hashValue *string) *resource.Resource {
r := rf.FromMap(map[string]interface{}{
r, err := rf.FromMap(map[string]interface{}{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{"name": name},
})
if err != nil {
panic(err)
}
annotations := map[string]string{}
if behavior != "" {
annotations[BehaviorAnnotation] = behavior