From 47441f1344ba627e791394de9136dfa65e9ae920 Mon Sep 17 00:00:00 2001 From: Yasmin Valim Date: Mon, 19 Feb 2024 19:16:49 -0300 Subject: [PATCH] fcos/v1_6_exp: Remove validations --- config/fcos/v1_6_exp/translate.go | 3 +- config/fcos/v1_6_exp/validate.go | 12 ------- config/fcos/v1_6_exp/validate_test.go | 52 --------------------------- 3 files changed, 2 insertions(+), 65 deletions(-) diff --git a/config/fcos/v1_6_exp/translate.go b/config/fcos/v1_6_exp/translate.go index 2e51200e..ecde4656 100644 --- a/config/fcos/v1_6_exp/translate.go +++ b/config/fcos/v1_6_exp/translate.go @@ -448,7 +448,8 @@ func processModule(rendered types.Config, module Module, options common.Translat "CmdToExecute": cmdToExecute, }) if err != nil { - panic(err) + r.AddOnError(yamlPath, err) + return rendered } result := contents.String() diff --git a/config/fcos/v1_6_exp/validate.go b/config/fcos/v1_6_exp/validate.go index 9f6695f5..481e3d84 100644 --- a/config/fcos/v1_6_exp/validate.go +++ b/config/fcos/v1_6_exp/validate.go @@ -98,15 +98,3 @@ func (user GrubUser) Validate(c path.ContextPath) (r report.Report) { } return } - -func (m Module) Validate(c path.ContextPath) (r report.Report) { - if m.Name == "" { - r.AddOnError(c.Append("name"), common.ErrSelinuxNameNotSpecified) - } - - if m.Contents.Inline == nil || *m.Contents.Inline == "" { - r.AddOnError(c.Append("contents"), common.ErrSelinuxContentsNotSpecified) - } - - return r -} diff --git a/config/fcos/v1_6_exp/validate_test.go b/config/fcos/v1_6_exp/validate_test.go index 07474704..2c850580 100644 --- a/config/fcos/v1_6_exp/validate_test.go +++ b/config/fcos/v1_6_exp/validate_test.go @@ -479,55 +479,3 @@ func TestValidateConfig(t *testing.T) { }) } } - -func TestValidateModule(t *testing.T) { - tests := []struct { - in Module - out error - errPath path.ContextPath - }{ - { - // valid module - in: Module{ - Contents: Resource{ - Inline: util.StrToPtr("some contents"), - }, - Name: "some name", - }, - out: nil, - errPath: path.New("yaml"), - }, - { - // contents is not specified - in: Module{ - Contents: Resource{ - Inline: util.StrToPtr(""), - }, - Name: "some name", - }, - out: common.ErrSelinuxContentsNotSpecified, - errPath: path.New("yaml", "contents"), - }, - { - // name is not specified - in: Module{ - Name: "", - Contents: Resource{ - Inline: util.StrToPtr("some contents"), - }, - }, - out: common.ErrSelinuxNameNotSpecified, - errPath: path.New("yaml", "name"), - }, - } - - for i, test := range tests { - t.Run(fmt.Sprintf("validate %d", i), func(t *testing.T) { - actual := test.in.Validate(path.New("yaml")) - baseutil.VerifyReport(t, test.in, actual) - expected := report.Report{} - expected.AddOnError(test.errPath, test.out) - assert.Equal(t, expected, actual, "bad report") - }) - } -}