backy/docs/content/config/commands/user-commands.md
Andrew Woodlee c7302f0e17
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
update docs
2025-03-10 12:34:33 -05:00

2.7 KiB

title weight description
User commands 2 This is dedicated to user commands.

This is dedicated to user commands. The command type field must be user. User is a type that allows one to perform user operations. There are several additional options available when type is user:

name notes type required External directive support
userName The name of a user to be configured. string yes no
userOperation The type of operation to perform. string yes no
userID The user ID to use. string no no
userGroups The groups the user should be added to. []string no no
userSshPubKeys The keys to add to the user's authorized keys. []string no yes
userShell The shell for the user. string no no
userHome The user's home directory. string no no
userPassword The new password value when using the password operation. string no yes

example

The following is an example of a package command:

  addUser:
	name: add user backy with custom home dir
    type: user
    userName: backy
    userHome: /opt/backy
    userOperation: add
    host: some-host

userOperation

The following package operations are supported:

  • add
  • remove
  • modify
  • password
  • checkIfExists

Development

The UserManager interface provides an way easy to add new commands. There is one interface Usermanager in directory pkg/usermanager.

UserManager

// UserManager defines the interface for user management operations.
// All functions but one return a string for the command and any args.
type UserManager interface {
	AddUser(username, homeDir, shell string, isSystem bool, groups, args []string) (string, []string)
	RemoveUser(username string) (string, []string)
	ModifyUser(username, homeDir, shell string, groups []string) (string, []string)
	// Modify password uses chpasswd for Linux systems to build the command to change the password
	// Should return a password as the last argument
	// TODO: refactor when adding more systems instead of Linux
	ModifyPassword(username, password string) (string, *strings.Reader, string)
	UserExists(username string) (string, []string)
}