Skip to content

Commit

Permalink
No error returns for removing a non-matching constraint (#170)
Browse files Browse the repository at this point in the history
Signed-off-by: Becky Huang <beckyhd@google.com>
  • Loading branch information
becky-hd committed Jan 22, 2022
1 parent e2cb9e5 commit f427e48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion constraint/pkg/client/drivers/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@ func (d *Driver) AddConstraint(ctx context.Context, constraint *unstructured.Uns
func (d *Driver) RemoveConstraint(ctx context.Context, constraint *unstructured.Unstructured) error {
handlers, err := d.getTargetHandlers(constraint)
if err != nil {
return err
if !errors.Is(err, ErrMissingConstraintTemplate) {
return err
}
}
for _, target := range handlers {
relPath, err := createConstraintPath(target, constraint)
Expand Down
4 changes: 2 additions & 2 deletions constraint/pkg/client/drivers/local/local_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,12 @@ func TestDriver_RemoveConstraint(t *testing.T) {
template: CreateTemplate(MockTargetHandler, TemplateModule),
constraint: MakeConstraint(t, MockTemplate, "foo"),
toRemove: MakeConstraint(t, "", "foo"),
wantError: ErrMissingConstraintTemplate,
wantError: nil,
},
{
name: "No Template",
toRemove: MakeConstraint(t, "Foos", "foo"),
wantError: ErrMissingConstraintTemplate,
wantError: nil,
},
{
name: "No Constraint",
Expand Down

0 comments on commit f427e48

Please sign in to comment.