Skip to content

Commit

Permalink
fcos/v1_6_exp: Remove validations
Browse files Browse the repository at this point in the history
  • Loading branch information
yasminvalim committed Feb 19, 2024
1 parent 363a23e commit 47441f1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 65 deletions.
3 changes: 2 additions & 1 deletion config/fcos/v1_6_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 0 additions & 12 deletions config/fcos/v1_6_exp/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
52 changes: 0 additions & 52 deletions config/fcos/v1_6_exp/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}
}

0 comments on commit 47441f1

Please sign in to comment.