Changeset 330 in code for trunk/cmd/sojuctl/main.go


Ignore:
Timestamp:
Jun 8, 2020, 8:30:09 PM (5 years ago)
Author:
delthas
Message:

sojuctl: Add support for creating admin users

This adds a new flag, -admin for creating admin users, which can
access admin service commands, among which create-user to create other
users on-the-fly.

Since the person running the commands in the README will be the local
soju administrator, the user they create should be admin as well, hence
the README update.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cmd/sojuctl/main.go

    r326 r330  
    1616const usage = `usage: sojuctl [-config path] <action> [options...]
    1717
    18   create-user <username>        Create a new user
    19   change-password <username>    Change password for a user
    20   help                          Show this help message
     18  create-user <username> [-admin]  Create a new user
     19  change-password <username>       Change password for a user
     20  help                             Show this help message
    2121`
    2222
     
    5656                }
    5757
     58                fs := flag.NewFlagSet("", flag.ExitOnError)
     59                admin := fs.Bool("admin", false, "make the new user admin")
     60                fs.Parse(flag.Args()[2:])
     61
    5862                password, err := readPassword()
    5963                if err != nil {
     
    6973                        Username: username,
    7074                        Password: string(hashed),
     75                        Admin:    *admin,
    7176                }
    7277                if err := db.StoreUser(&user); err != nil {
Note: See TracChangeset for help on using the changeset viewer.