Skip to content

Commit

Permalink
Make UID and GID pointers so we can check for nil
Browse files Browse the repository at this point in the history
  • Loading branch information
munnik committed Oct 22, 2024
1 parent a49c800 commit fe4afc5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkgs/sops-install-secrets/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type secret struct {
Key string `json:"key"`
Path string `json:"path"`
Owner string `json:"owner"`
UID int `json:"uid"`
UID *int `json:"uid,omitempty"`
Group string `json:"group"`
GID int `json:"gid"`
GID *int `json:"gid,omitempty"`
SopsFile string `json:"sopsFile"`
Format FormatType `json:"format"`
Mode string `json:"mode"`
Expand Down Expand Up @@ -478,8 +478,8 @@ func (app *appContext) validateSecret(secret *secret) error {
} else if app.checkMode == Off || app.ignorePasswd {
// we only access to the user/group during deployment

if secret.Owner == "" && secret.UID >= 0 {
secret.owner = secret.UID
if secret.UID != nil {
secret.owner = *secret.UID
} else {
owner, err := user.Lookup(secret.Owner)
if err != nil {
Expand All @@ -492,8 +492,8 @@ func (app *appContext) validateSecret(secret *secret) error {
secret.owner = int(uid)
}

if secret.Group == "" && secret.GID >= 0 {
secret.group = secret.GID
if secret.GID != nil {
secret.group = *secret.GID
} else {
group, err := user.LookupGroup(secret.Group)
if err != nil {
Expand Down

0 comments on commit fe4afc5

Please sign in to comment.