Skip to content

Commit

Permalink
Drop ad-hoc resource validation on remove=true
Browse files Browse the repository at this point in the history
This code is redundant, as we had this logic moved to `resources/resources.go:ValidateResource()`, so it is universally applied to all resource types, no code duplication required.

commit-id:d1ea523e
  • Loading branch information
fornellas committed Sep 3, 2024
1 parent 30e37cd commit f02dd5a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
7 changes: 0 additions & 7 deletions resources/apt_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ func (a *APTPackage) Validate() error {
return fmt.Errorf("`package` must match regexp %s: %s", validAptPackageNameRegexp, a.Version)
}

// Remove
if a.Remove {
if a.Version != "" {
return fmt.Errorf("'version' can not be set when 'remove' is true")
}
}

// Version
// https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
if strings.HasSuffix(a.Version, "+") {
Expand Down
22 changes: 0 additions & 22 deletions resources/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,6 @@ func (f *File) Validate() error {
return fmt.Errorf("'path' must be absolute")
}

if f.Remove {
if f.Content != "" {
return fmt.Errorf("'content' can not be set when 'remove' is true")
}
if f.Perm != os.FileMode(0) {
return fmt.Errorf("'perm' can not be set when 'remove' is true")
}
if f.Uid != 0 {
return fmt.Errorf("'uid' can not be set when 'remove' is true")
}
if f.User != "" {
return fmt.Errorf("'user' can not be set when 'remove' is true")
}
if f.Gid != 0 {
return fmt.Errorf("'gid' can not be set when 'remove' is true")
}
if f.Group != "" {
return fmt.Errorf("'group' can not be set when 'remove' is true")
}
return nil
}

if f.Uid != 0 && f.User != "" {
return fmt.Errorf("can't set both 'uid' and 'user'")
}
Expand Down

0 comments on commit f02dd5a

Please sign in to comment.