Giter Club home page Giter Club logo

mmctl's Introduction

mmctl no longer lives in this repository since we have moved to using a monorepo located in https://github.com/mattermost/mattermost.

Our developer setup instructions have been updated to use the monorepo, and we're going to be continuing to update our developer documentation to reflect the new setup over the next couple weeks.

All changes going forward should be made in the monorepo since we're no longer accepting PRs in this repository, and any existing PRs should be resubmitted over there. We have some notes on how to do that migration here, but most of the code that was previously in this repository is now located in server/cmd/mmctl in the monorepo. We were unable to maintain Git history with the move, so migrating PRs to the new repo will likely involve a lot of manually copying changes to their new locations.

The mmctl documentation can be accessed within the the Mattermost documentation.

This repository is being kept open until December 2023 to maintain support for our extended support releases at which point it will be archived and kept as a historical record.

mmctl's People

Contributors

0xvolodya avatar agnivade avatar ashishbhate avatar attiss avatar balan2010 avatar dependabot[bot] avatar enoldev avatar ethervoid avatar gupsho avatar hanzei avatar isacikgoz avatar jecepeda avatar jespino avatar jfrerich avatar joremysh avatar larkox avatar lucianomagrao avatar lurcio avatar m-buntoro avatar m-zubairahmed avatar metanerd avatar mgdelacroix avatar noxer avatar s4kh avatar sezalagrawal avatar simross avatar sirmackk avatar streamer45 avatar wiggin77 avatar wijayaerick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mmctl's Issues

OSX Issues

I have deployed as for instructions:

go get -u github.com/mattermost/mmctl

Followed by:

source <(mmctl completion bash) | this resulted in: -bash: mmctl: command not found

When I run: source <(/Users/cosmic/go/bin/mmctl completion bash) with direct location to the executable it works. Maybe some updates in Readme, to avoid confusion, and why are the recommended .bashrc and .profiles and not .bash_profiles? My .bashrc stricly calls .bash_profiles for ex in OSx.

auth login exits with status 0 even for a non-working URL

Steps to reproduce

Note the literal use of example.com here; don't replace it with an actual, working MM instance URL.

# /usr/bin/sudo -u mattermost /usr/local/bin/mmctl  auth login http://example.com --name example --access-token 123456890abcdefghijklmnopq`
# echo $?

What I expect happen

For a non-zero exit status to be printed.

What happens instead

The exit status is 0.

Update documentation for auth

There is not possible to run such CLI:

https://github.com/mattermost/mmctl#access-tokens says:

$ mmctl auth login https://community.mattermost.com --name community --username my-username --access-token MY_ACCESS_TOKEN

The command needs to have the --username variable removed.

IE:
➜ mmctl auth login https://chat.uhlhosting.ch --name UHL --username cosmin --access-token xxxxxxxxxxxxxxxxxxxxxxx Error: You must use --access-token or --username, but not both

When running without --username:

credentials for UHL: Personal Access Token@https://chat.uhlhosting.ch stored

mmctl cannot set int64 config values

As of 5.26.0, attempting to modify a config value that is of type int64 (e.g. FileSettings.MaxFileSize) fails with an error:

$ mmctl config set FileSettings.MaxFileSize 104857600
Error: target value type is not supported
Usage:
  mmctl config set [flags]

Examples:
config set SqlSettings.DriverName mysql
config set SqlSettings.DataSourceReplicas "replica1" "replica2"

Flags:
  -h, --help   help for set

Global Flags:
      --format string                the format of the command output [plain, json] (default "plain")
      --insecure-sha1-intermediate   allows to use insecure TLS protocols, such as SHA-1
      --local                        allows communicating with the server through a unix socket
      --strict                       will only run commands if the mmctl version matches the server one

This happens because setValueWithConversion() doesn't have a case for reflect.Int64.

mmctl can't set config for newly installed plugin

Please see #427 (comment) for direction on the task here.

Original post:

I'm currently automating setup of mattermost server including plugins using containers (using the latest version 6.2.1)
For the plugin installation and system configuration I'm using a script with mmctl commands.
This works well except for the step of setting the configuration of the newly installed plugin (antivirus in this case, didn't test with any other plugins).
Only after manually changing the config via the system console in the UI mmctl is able to change the settings.

My guess is that the plugin creates the config path after saving the changes in the system console whereas mmctl only changes existing values.
So not sure if this is a bug or intended behaviour, in any case, it prevents fully automating the plugin installation and configuration, you always have to manually save (create) the config via the UI.

+ docker-compose exec -T mmserver mmctl plugin marketplace install antivirus
Plugin Antivirus successfully installed
+ docker-compose exec -T mmserver mmctl plugin enable antivirus
Enabled plugin: antivirus
+ docker-compose exec -T mmserver mmctl config set PluginSettings.Plugins.antivirus.clamavhostport 192.168.10.22:3310
Error: path object type is not supported
+ docker-compose exec -T mmserver mmctl config set PluginSettings.Plugins.antivirus.scantimeoutseconds 10
Error: path object type is not supported

running config shows that the plugin was successfully installed and enabled, but no config

docker-compose exec -T mmserver mmctl config show
# just the plugin part
"PluginSettings": {
    "Enable": true,
    "EnableUploads": false,
    "AllowInsecureDownloadUrl": false,
    "EnableHealthCheck": true,
    "Directory": "/mattermost/plugins/",
    "ClientDirectory": "./client/plugins",
    "Plugins": {
      "playbooks": {
        "BotUserID": "ji5jufxjgir17nccu3619xse9e"
      }
    },
    "PluginStates": {
      "antivirus": {
        "Enable": true
      },
      "com.mattermost.nps": {
        "Enable": true
      },
      "com.mattermost.plugin-incident-management": {
        "Enable": false
      },
      "focalboard": {
        "Enable": true
      },
      "playbooks": {
        "Enable": true
      }
    },

Once I open the systemconsole, I can see the plugin listed and the configuration screen, I can edit the settings and save them. Only now the config is present in the config show output:

docker-compose exec -T mmserver mmctl config show
# just the plugin part
"PluginSettings": {
    "Enable": true,
    "EnableUploads": false,
    "AllowInsecureDownloadUrl": false,
    "EnableHealthCheck": true,
    "Directory": "/mattermost/plugins/",
    "ClientDirectory": "./client/plugins",
    "Plugins": {
      "antivirus": {
        "clamavhostport": "localhost:3310",
        "scantimeoutseconds": 10
      },
      "playbooks": {
        "BotUserID": "ji5jufxjgir17nccu3619xse9e"
      }
    },
    "PluginStates": {
      "antivirus": {
        "Enable": true
      },
      "com.mattermost.nps": {
        "Enable": true
      },
      "com.mattermost.plugin-incident-management": {
        "Enable": false
      },
      "focalboard": {
        "Enable": true
      },
      "playbooks": {
        "Enable": true
      }
    },

Now running the same script again, I can sucessfully change the plugin config:

+ docker-compose exec -T mmserver mmctl plugin marketplace install antivirus
Plugin Antivirus successfully installed
+ docker-compose exec -T mmserver mmctl plugin enable antivirus
Enabled plugin: antivirus
+ docker-compose exec -T mmserver mmctl config set PluginSettings.Plugins.antivirus.clamavhostport 192.168.10.22:3310
Value changed successfully

Verify user email command description is misleading

var VerifyUserEmailWithoutTokenCmd = &cobra.Command{

There's a big difference between “trigger a verification email” and “irrevocably mark a user as verified without performing any verification steps”. “Verify the user's email address” to me implies causing a verification flow rather than completing one! I think it should be amended to say “Mark user's email as verified.” or similar.

[feature request] get users from server

this issue is more of a feature request/discussion one than an actual issue

in the current mattermost cli there are some commands to show users
but it would be really great if mmctl could support a more generic approach that allows for more filtering.
like getting all inactive users, or just getting a list of ALL users on the server that in turn could be piped into other tools or mmctl again to allow for more versatile commands.

I'm thinking something along the line of mmctl user list > users.txt and then running that in a loop and (for example) getting user info for each user and doing something with that info (like deactivating).

It's a use case I've seen for a lot of customers and not all of them want to run SQL queries against their database, so having this in mmctl would probably help them out a lot.

Git tag commit changed?

Hi, Homebrew maintainer here. I noticed that the commit for the v5.31.0 tag changed from

fc161b2

to

689bd04

It seems this was to edit some files and update the version number. Is this right?

get posts as JSON

I achieve getting posts as a text stdout:

❯ mmctl post list mychannel:test 
[laurent.perrinet] hi
[laurent.perrinet] test 

but asking to have it in JSON format outputs the same result :

❯ mmctl post list mychannel:test --format json
[laurent.perrinet] hi
[laurent.perrinet] test 

any way to get a JSON format (with the metadata related to each post)?

cheers,
Laurent

Team still present after removal?

Greetings I have made some teams in past that I had not needed and were merely a testing team, now when I wanted to tidy up the DB and server a bit, it seems this fails or is cached?

Normally after the removal of a team I expect a:

image

In my case the teams were still browsable from the app/browser.

➜ mmctl team delete open-source
Have you performed a database backup? (YES/NO): 
YES
Are you sure you want to delete the teams specified?  All data will be permanently deleted? (YES/NO): 
YES
Deleted team 'open-source'

00:31:16.799 in zsh-syntax-highlighting on  master took 26s 
➜ mmctl team list              
cloud
devops
netops
open-source
support

VersuS server CLI this it seems it removed the team.

[root@chat bin]# ./mattermost team list
cloud
devops
netops
open-source (archived)
support
[root@chat bin]# ./mattermost team delete open-source
Have you performed a database backup? (YES/NO): 
YES
Are you sure you want to delete the teams specified?  All data will be permanently deleted? (YES/NO): 
YES
Deleted team 'open-source'
[root@chat bin]# ./mattermost team list
cloud
devops
netops
support
[root@chat bin]# ./mattermost team list

go get installation error on debian 10

Hi, when i try to install mmctl using go get on debian 10 it downloads a lot of stuff but then crashes with:

github.com/mattermost/mmctl imports github.com/mattermost/mmctl/commands imports github.com/mattermost/mattermost-server/v5/shared/mlog/human: cannot find module providing package github.com/mattermost/mattermost-server/v5/shared/mlog/human

The last successful build i installed was on the 5.03.2021, so i looked into which version this could be and tried to use

go get -u github.com/mattermost/[email protected]

but here occurs an other problem:

# github.com/mattermost/mmctl/commands pkg/mod/github.com/mattermost/[email protected]/commands/init.go:48:13: cannot use c (type *model.Client4) as type client.Client in argument to fn: *model.Client4 does not implement client.Client (wrong type for GetPostsForChannel method) have GetPostsForChannel(string, int, int, string, bool) (*model.PostList, *model.Response) want GetPostsForChannel(string, int, int, string) (*model.PostList, *model.Response) pkg/mod/github.com/mattermost/[email protected]/commands/init.go:64:12: cannot use c (type *model.Client4) as type client.Client in argument to fn: *model.Client4 does not implement client.Client (wrong type for GetPostsForChannel method) have GetPostsForChannel(string, int, int, string, bool) (*model.PostList, *model.Response) want GetPostsForChannel(string, int, int, string) (*model.PostList, *model.Response)

can someone give me a hint what i missed out in the mean time?
thanks!

post message to a user

I managed to use the command-line to post a message to a channel (test) within my team (myteam):

mmctl post create myteam:test --message "some text for the post"

However, I did not manage to send a message (or list message) for a specific user user1:

mmctl post create myteam:@user1 --message "some text for the post"

returns

Error: Unable to find channel 'myteam:@user1'

any way to implement this?

Many thanks,
Laurent

Panic for `command list` without args

./mmctl command list
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/mattermost/mmctl/commands.listCommandCmdF(0xbffac0, 0xc0000dcb90, 0x102d400, 0x1057d30, 0x0, 0x0, 0xc0000bee80, 0xc000123cb8)
/home/dlauder/Development/mattermost/mmctl/commands/command.go:204 +0x671
github.com/mattermost/mmctl/commands.withClient.func1(0x102d400, 0x1057d30, 0x0, 0x0, 0x0, 0x0)
/home/dlauder/Development/mattermost/mmctl/commands/init.go:58 +0x125
github.com/spf13/cobra.(*Command).execute(0x102d400, 0x1057d30, 0x0, 0x0, 0x102d400, 0x1057d30)
/home/dlauder/Development/mattermost/mmctl/vendor/github.com/spf13/cobra/command.go:826 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0x102a200, 0xb05c4b, 0x1a, 0xbf0d00)
/home/dlauder/Development/mattermost/mmctl/vendor/github.com/spf13/cobra/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
/home/dlauder/Development/mattermost/mmctl/vendor/github.com/spf13/cobra/command.go:864
github.com/mattermost/mmctl/commands.Run(0xc0000a8070, 0x2, 0x2, 0x8c380, 0xc00009a058)
/home/dlauder/Development/mattermost/mmctl/commands/root.go:29 +0x4f3
main.main()
/home/dlauder/Development/mattermost/mmctl/mmctl.go:13 +0x68

mmctl does not work if system user has no /etc/passwd entry (e.g. on OpenShift deployments)

There's a panic when running mmctl e.g. on an openshift deployment where you have a random uid, usually with no corresponding /etc/passwd entry:

I have no name!@mm-openshift-185-6drkz:/mattermost$ id
uid=1000170000 gid=0(root) groups=0(root),1000170000

I have no name!@mm-openshift-185-6drkz:/mattermost$ ./bin/mmctl
panic: user: unknown userid 1000170000

goroutine 1 [running]:
github.com/mattermost/mmctl/commands.init.1()
        /builds/mattermost/ci-only/mmctl/commands/auth_utils.go:44 +0x74

Especially in --local mode there should not be any need to look up anything about the current linux system user, and outside local mode $HOME could be read as an alternative.

mmctl dont show the right version

When I download the latest release of mmctl as linux_amd64.tar (tag v5.38.1) the command mmctl version tells me 5.35.0

I see that in the file commands/version.go the version 5.35.0 is still given, although it should be 5.38.1.

So, when I run mmctl with the latest Mattermost version, mmctl always gives me a warning that the version doesn't fit, although it should fit

gofmt error in v5.36.0 during brew build

2021-07-26T19:20:28.5151160Z --- /private/tmp/mmctl-20210726-5071-141gaja/src/github.com/mattermost/mmctl/commands/utils_unix.go.orig	2021-07-26 12:20:18.000000000 -0700
2021-07-26T19:20:28.5153150Z +++ /private/tmp/mmctl-20210726-5071-141gaja/src/github.com/mattermost/mmctl/commands/utils_unix.go	2021-07-26 12:20:18.000000000 -0700
2021-07-26T19:20:28.5154400Z @@ -1,6 +1,7 @@
2021-07-26T19:20:28.5155460Z  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
2021-07-26T19:20:28.5156460Z  // See LICENSE.txt for license information.
2021-07-26T19:20:28.5157100Z  
2021-07-26T19:20:28.5157560Z +//go:build linux || darwin
2021-07-26T19:20:28.5158100Z  // +build linux darwin
2021-07-26T19:20:28.5158570Z  
2021-07-26T19:20:28.5159020Z  package commands

Review Comments

Some comments about the code:

I general the code looks pretty good :)

mmctl 6.2.0 is gone?

Hi.

Homebrew maintainer here (homebrew is the missing package manager for macOS and Linux).
We started shipping the 6.2.0 release some time ago, but it looks like the tag is gone. Is this release gone?
Should we go back to 6.1.0?

Related issue: Homebrew/homebrew-core#91184

Thanks

Another macOS issue

/usr/local/bin/go vet github.com/mattermost/mmctl github.com/mattermost/mmctl/commands
/usr/local/bin/go vet -vettool=/bin/shadow github.com/mattermost/mmctl github.com/mattermost/mmctl/commands
go vet: can't execute /bin/shadow -flags: fork/exec /bin/shadow: no such file or directory
make: *** [govet] Error 2

Don't know what /bin/shadow is supposed to do, but it's non-existent in macOS 10.14.5

auth set not working - "Error cannot save the credentials"

Environment

  • mmctl version: 5.30.0 (installed with Homebrew)
  • Workstation OS: macOS Catalina 10.15.7

Steps to Reproduce

  1. Run mmctl auth set name

Expected Behavior

Authentication credentials are changed

Observed Behavior

Credentials are not changed, shows this error:

Error: cannot save the credentials: open /Users/paul/.mmctl/.mmctl: not a directory
Usage:
  mmctl auth set [server name] [flags]

Examples:
  auth set local-server

Flags:
  -h, --help   help for set

Global Flags:
      --config string                path to search for '.mmctl' configuration file (default "$HOME/.config/mmctl")
      --format string                the format of the command output [plain, json] (default "plain")
      --insecure-sha1-intermediate   allows to use insecure TLS protocols, such as SHA-1
      --local                        allows communicating with the server through a unix socket
      --strict                       will only run commands if the mmctl version matches the server one

Steps tried

  1. Upgrading mmctl to latest version
  2. Creating /Users/paul/.mmctl/ and moving existing config file into it. (This resulted in a different error)
  3. It appears that mmctl auth login and mmctl auth renew also fail

There is no way to list archived private channels if the user isn't the member of its channel

Summary

Executing mmctl channel list team doesn't list archived private channels if the user who run the command isn't member of its channel, even if the user is system admin. Not showing private channels that user isn't a member of is often the right thing to do, but there are times when system administrator want to list all channels including those the admin aren't participating in.


Up to v5.39, I can list all channels except for direct channels by mattermost channel command, because the command call GetAll(team.id) internally. But mattermost channel has removed in v6.0.
https://github.com/mattermost/mattermost-server/blob/release-5.39/cmd/mattermost/commands/channel.go#L482

mmctl system version has unspecified and inconvenient format (and mattermost version will be deprecated)

Given that mattermost version will be deprecated in favor of mmctl system version, the output format of the latter should be intelligible.

However, it is currently just "Server version " followed by the contents of the "X-Version-ID" header, which is filled in mattermost-server/web/handlers.go, i.e.,

fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, c.App.ClientConfigHash(), c.App.Srv().License() != nil)

Meaning the full output is something like Server version 5.39.2.5.39.2.b8d48854a28e225558740e00d1dfb8e2.true. This isn't easy to read, or particularly easy to machine parse if we ever expect version numbers to have more or less than 3 parts.

In particular I would like to extract 5.39.2 and true/false (for whether it is the enterprise edition) in a script, as part of an internal maintenance process.

PS: Off-topic, but I'd also like to note that it is quite inconvenient to have to use mmctl to get the binary version information, which should be available without having a running instance.

authToken is stored unencypted in config file

I have noticed that the authToken is stored as-is (unencrypted) in the configuration file. Maybe this could be improved somehow? (e.g. using platform specific APIs such as WinCrypt, macOS keychain, KDE Wallet, Gnome keyring etc.)

I have not tested a password, as our server doesn't support that in its current config (using Gitlab for login).

mmctl: provide an option to allow existing plugins to be replaced during 'mmctl plugin add'

Summary

The mmctl plugin add command does not currently support replacement of existing plugins, something that is possible when uploading plugins using the Mattermost System Console.

As a workaround, it's possible to use mmctl plugin delete to remove an existing plugin prior to the add operation.

It could be convenient to have an (opt-in) ability to replace existing plugins.

Steps to reproduce

  1. Upload a plugin (either using the System Console, or using mmctl)
  2. Attempt to upload the same plugin again using mmctl plugin add

Observed behavior (that appears unintentional)

The following error appears:

Unable to add plugin: dist/example-plugin-1.0.0.tgz. Error: : Unable to install plugin. A plugin with the same ID is already installed.

Possible fixes

The replace parameter to InstallPlugin is currently fixed to false; that could be adjusted to accept a flag from the command-line.

--quiet not honored by auth login (possibly others)

Steps to reproduce

  1. Log in using mmctl.

What I expect to happen

# /usr/bin/sudo -u mattermost /usr/local/bin/mmctl --quiet auth login https://example.com --name example --access-token 123456890abcdefghijklmnopq
# 

What happens instead

# /usr/bin/sudo -u mattermost /usr/local/bin/mmctl --quiet auth login https://example.com --name example --access-token 123456890abcdefghijklmnopq

  credentials for "example": "Personal Access Token@https://example.com" stored

# 

Potential cause

From looking at the code, output and --quiet are implemented in Printer, but auth and a few other places appear to use fmt.Printf() directly instead.

Error message confusing when new user password doesn't meet requirements

While using mmctl to create a user, if the password provided doesn't meet the requirement mmctrl returns the following error message

Error: Unable to create user. Error: : Login failed because of invalid password.

This can be misleading to think that the credentials provided to login in the mattermost instance are invalid

It would be much more user friendly to provide a clear message stating that the password provided for the new user is invalid

[Feature Request] Add `config patch` command

The command would look like this:

mmctl config patch <FILENAME>

And would emulate this CURL command to apply the configuration settings in the supplied JSON file:

curl -X PUT\
 -H "Content-Type: application/json"\
 -H "Authorization: Bearer $TOKEN"\
 -d @./patch_config.json\
 https://mattermost.example.com/api/v4/config/patch

mmctl migrate_auth from email to saml errors out

Mattermost Enterprise Edition 20 v5.38.0, mmctl v5.35.0 -- b27164c, kubernetes 1.19.7

Issued command on mattermost server after import from Slack:

$ mmctl user migrate_auth email saml MM2SAML.json
WARNING: server version 5.38.0.5.38.0.36c5b542ffc07c899bab5ebfb5a1c5cc.true doesn't match mmctl version 5.35.0
Error: AppErrorFromJson: model.utils.decode_json.app_error, body: <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>

Usage:
  mmctl user migrate_auth [from_auth] [to_auth] [migration-options] [flags]

Examples:
user migrate_auth email saml users.json

Flags:
      --auto      Automatically migrate all users. Assumes the usernames and emails are identical between Mattermost and SAML services. (saml only)
      --confirm   Confirm you really want to proceed with auto migration. (saml only)
      --force     Force the migration to occur even if there are duplicates on the LDAP server. Duplicates will not be migrated. (ldap only)
  -h, --help      help for migrate_auth

Global Flags:
      --config-path string           path to the configuration directory. If "$HOME/.mmctl" exists it will take precedence over the default value (default "$XDG_CONFIG_HOME")
      --format string                the format of the command output [plain, json] (default "plain")
      --insecure-sha1-intermediate   allows to use insecure TLS protocols, such as SHA-1
      --insecure-tls-version         allows to use TLS versions 1.0 and 1.1
      --local                        allows communicating with the server through a unix socket
      --strict                       will only run commands if the mmctl version matches the server one

Error from server log files:

mattermost-mattermost-enterprise-edition-7dc759574f-bg6wb:{"level":"error","ts":1631561721.9394324,"caller":"http/server.go:3117","msg":"http: panic serving 100.96.40.8:48940: runtime error: invalid memory address or nil pointer dereference
goroutine 177954 [running]:
net/http.(*conn).serve.func1(0xc0068405a0)
net/http/server.go:1804 +0x153
panic(0x2834280, 0x448d3d0)
runtime/panic.go:971 +0x499
github.com/mattermost/mattermost-server/v5/enterprise/account_migration.checkEmailAlreadyInUse(0xc002900c80, 0x1c, 0xc0026fd440, 0x6, 0x8, 0x6)
github.com/mattermost/mattermost-server/v5/enterprise/account_migration/account_migration.go:147 +0x46
github.com/mattermost/mattermost-server/v5/enterprise/account_migration.(*AccountMigrationInterfaceImpl).MigrateToSaml(0xc002f30780, 0x0, 0x0, 0xc001d2e8d0, 0x0, 0x17bcc18628c)
github.com/mattermost/mattermost-server/v5/enterprise/account_migration/account_migration.go:202 +0x547
github.com/mattermost/mattermost-server/v5/api4.migrateAuthToSaml(0xc0026fc900, 0x30f55b0, 0xc0026fc880, 0xc00 0ff2800)
github.com/mattermost/mattermost-server/v5/api4/user.go:2851 +0x72b
github.com/mattermost/mattermost-server/v5/web.Handler.ServeHTTP(0x316aab0, 0xc00282ac10, 0x2d511f0, 0x36aafaf, 0x11, 0x100000001, │
│ 0x0, 0x0, 0x30f75f0, 0xc0069101c0, ...)
github.com/mattermost/mattermost-server/v5/web/handlers.go:298 +0x1d72
github.com/mattermost/gziphandler.GzipHandlerWithOpts.func1.1(0x30f6b70, 0xc0047442a0, 0xc000ff 2800)
github.com/mattermost/[email protected]/gzip.go:337 +0x22d
net/http.HandlerFunc.ServeHTTP(0xc0025d7560, 0x30f6b70, 0xc0047442a0, 0xc000ff2800)
net/http/server.go:2049 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00018e240, 0x30f6b70, 0xc0047442a0, 0xc000ff2500)
github.com/gorilla/[email protected]/mux.go:210 +0xd3
net/http.serverHandler.ServeHTTP(0xc00293b500, 0x30f6b70, 0xc0047442a0, 0xc000ff2500)
net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc0068405a0, 0x3100998, 0xc0026fc740)
net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
net/http/server.go:2993 +0x39b","source":"httpserver"}

Source json file format is :
{
"user@email": "user-name"
}

Add polibility to split or copy channel

Would it be possible to add a command channel copy to copy a channel. I frequently end up in a situation where the tasks grow, much like described in Organizing Mattermost.

For example, you might begin with a general “Marketing” channel. As conversations progress, you might divide that channel into: “Marketing: Website”, “Marketing: Social Media”, “Marketing: General”.

However, when splitting Marketing into Marketing: Website and Marketing: Social Media, I might want to keep the history of the old channel Marketing in both new channels. Especially so, if I might later create a new team to exclusively work on Marketing: Social Media. Fortunately, the api would already provide channel move for the last task.

[ Feature Request ] `mmctl ping` to send a DM

I have a bash script that I use to send me a Mattermost notification to let me know that long processes have completed. It would be great to have this in mmctl. Here's how I see it working:

make dist; mmctl ping "make dist complete"

It would also be nice to be able to append STDIN as a code block to the message that's sent, e.g.:

tail -n3 mattermost.log > mmctl ping "Here's the last three lines of the Mattermost log:"

Would produce a post like this:

Here's the last three lines of the Mattermost log:

```
2021-08-12T23:07:45.163Z	debug	wsapi/websocket_handler.go:25	Websocket request	{"action": "ping"}
2021-08-12T23:08:00.923Z	debug	web/handlers.go:107	Received HTTP request	{"method": "POST", "url": "/api/v4/users/status/ids", "request_id": "ggk78sfk6brp8rukihp4myt1cc", "host": "mattermost.example.com", "scheme": "https", "status_code": "200"}
2021-08-12T23:08:15.163Z	debug	wsapi/websocket_handler.go:25	Websocket request	{"action": "ping"}
```

Usage:
mmctl ping [message] [flags]

Examples:

ping 'Time to make the donuts!'

ping 'Open the pod bay doors' -u hal

Flags:
-u, --user The username or ID of the user to whom to send the direct message

Add auth_data to user search output

having the auth_data field in the output of the user search would highly increase the usefulness of the command when debugging ldap issues.

--config with auth login only works correctly with "config" as filename

Issue

When a custom configuration file is supplied via --config to auth login, and reading credentials from the given file doesn't succeed, an attempt is made to create the supplied directory path. This path is constructed by stripping a fixed "config" (without a directory separator) from the user-supplied path.

When the custom configuration file doesn't exist, this results in an unnecessary mkdir when the given filename ends with the hardcoded value of "config" (case 1 below), or that plus a "is a directory" failure when it doesn't (case 2).

If the custom configuration file does exist, the useless mkdir is still triggered when the given filename ends with the hardcoded value of "config" (case 3), or a "not a directory" failure when it doesn't (case 4).

Cause

The problematic mkdir call is issued here. I have no experience in Go, but instead of the TrimSuffix() call nested on that line, I think there should be a Go equivalent of a dirname instead, using the user-supplied path as parameter, and without referencing the value of configFileName (the source of the hardcoded "config").

Steps to reproduce

Case 1

A useless, empty mmctl_ directory gets created:

# rm -rf /tmp/mmctl_test/
# sudo -u mattermost mkdir /tmp/mmctl_test/
# /usr/bin/sudo -u mattermost /usr/local/bin/mmctl auth --quiet login https://example.com --name example --access-token 123456890abcdefghijklmnopq --config /tmp/mmctl_test/mmctl_config

  credentials for "example": "Personal Access Token@https://example.com" stored

# ls -lRa /tmp/mmctl_test/
/tmp/mmctl_test/:
yhteensä 24
drwxrwxr-x  3 mattermost mattermost  4096 tammi  30 15:27 .
drwxrwxrwt 23 root       root       12288 tammi  30 15:27 ..
drwx------  2 mattermost mattermost  4096 tammi  30 15:27 mmctl_
-rw-------  1 mattermost mattermost   244 tammi  30 15:27 mmctl_config

/tmp/mmctl_test/mmctl_:
yhteensä 8
drwx------ 2 mattermost mattermost 4096 tammi  30 15:27 .
drwxrwxr-x 3 mattermost mattermost 4096 tammi  30 15:27 ..

Case 2

Saving the credentials fails:

# rm -rf /tmp/mmctl_test/
# sudo -u mattermost mkdir /tmp/mmctl_test/
# /usr/bin/sudo -u mattermost /usr/local/bin/mmctl auth --quiet login https://example.com--name example --access-token 123456890abcdefghijklmnopq --config /tmp/mmctl_test/test
Error: cannot save the credentials: open /tmp/mmctl_test/test: is a directory
# ls -lRa /tmp/mmctl_test/
/tmp/mmctl_test/:
yhteensä 20
drwxrwxr-x  3 mattermost mattermost  4096 tammi  30 15:31 .
drwxrwxrwt 23 root       root       12288 tammi  30 15:31 ..
drwx------  2 mattermost mattermost  4096 tammi  30 15:31 test

/tmp/mmctl_test/test:
yhteensä 8
drwx------ 2 mattermost mattermost 4096 tammi  30 15:31 .
drwxrwxr-x 3 mattermost mattermost 4096 tammi  30 15:31 ..

Case 3

A useless, empty test_ directory is created:

# rm -rf /tmp/mmctl_test/
# sudo -u mattermost mkdir /tmp/mmctl_test/
# sudo -u mattermost touch /tmp/mmctl_test/test_config
# /usr/bin/sudo -u mattermost /usr/local/bin/mmctl auth login https://example.com --name example --access-token 123456890abcdefghijklmnopq --config /tmp/mmctl_test/test_config

  credentials for "example": "Personal Access Token@https://example.com" stored

# ls -lRa /tmp/mmctl_test/
/tmp/mmctl_test/:
yhteensä 24
drwxrwxr-x  3 mattermost mattermost  4096 tammi  30 15:58 .
drwxrwxrwt 22 root       root       12288 tammi  30 15:58 ..
drwx------  2 mattermost mattermost  4096 tammi  30 15:58 test_
-rw-rw-r--  1 mattermost mattermost   244 tammi  30 15:58 test_config

/tmp/mmctl_test/test_:
yhteensä 8
drwx------ 2 mattermost mattermost 4096 tammi  30 15:58 .
drwxrwxr-x 3 mattermost mattermost 4096 tammi  30 15:58 ..

Case 4

Saving the credentials again fails:

# rm -rf /tmp/mmctl_test/
# sudo -u mattermost mkdir /tmp/mmctl_test/
# sudo -u mattermost touch /tmp/mmctl_test/test
# /usr/bin/sudo -u mattermost /usr/local/bin/mmctl auth login https://example.com --name example --access-token 123456890abcdefghijklmnopq --config /tmp/mmctl_test/test
Error: mkdir /tmp/mmctl_test/test: not a directory
# ls -lRa /tmp/mmctl_test/
/tmp/mmctl_test/:
yhteensä 16
drwxrwxr-x  2 mattermost mattermost  4096 tammi  30 16:00 .
drwxrwxrwt 22 root       root       12288 tammi  30 16:00 ..
-rw-rw-r--  1 mattermost mattermost     0 tammi  30 16:00 test

postCreateCmdF does not return post id

It would be great to obtain the post id either via callback or returned when this method is called so that you don't have to list posts with the -i flag to get the appropriate post ids

Error: unknown flag: --local-socket-path

The documentation claims that the option --local-socket-path can be used to point mmctl to the right server socket. Anyhow mmctl --local --local-socket-path … cmd (from Mattermost 5.31.1 team edition tar ball) gives me:

Error: unknown flag: --local-socket-path

I checked that the socket has been created by the server with the proper owner and permissions (0600).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.