Commit graph

171 commits

Author SHA1 Message Date
Domenico Rizzo
a981291ea2
MM-42819 mmctl: informative errors on permanent deletions (#30230)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-11-06 10:38:10 +01:00
Ben Schumacher
892a7c9c69
Use golangci-lints's build-in modernize linter (#34341)
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Waiting to run
Web App CI / check-types (push) Waiting to run
Web App CI / test (push) Waiting to run
Web App CI / build (push) Waiting to run
2025-11-04 12:09:11 +01:00
Priyansh Naskar
7e5e5ac199
[MM-47826] Review convertUserToBot function to return an error in case of a failure (#21460) (#33534)
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-10-14 16:31:01 +02:00
Ben Schumacher
4006683af0
Improve mmctl test practices and error handling (#34079)
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Waiting to run
Web App CI / check-types (push) Waiting to run
Web App CI / test (push) Waiting to run
Web App CI / build (push) Waiting to run
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-14 12:28:27 +02:00
Ben Schumacher
71579a85a6
[MM-64633] Rewrite Go client using Generics (#31805)
Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
2025-10-07 12:19:21 +02:00
Ben Schumacher
3df25e6904
[MM-65830] Fix mmctl system status exit code for health check failures (#33970)
* [MM-65830] Fix mmctl system status exit code for health check failures

Make mmctl system status return non-zero exit codes when health checks fail.
This addresses the customer blocker issue where AWS ECS health checks were
broken after the distroless Docker image change, as they rely on exit codes
to determine service health.

Changes:
- Return error (non-zero exit) when server status != "OK"
- Return error when database_status != "OK"
- Return error when filestore_status != "OK"
- Return success (exit code 0) only when all components are healthy
- Add comprehensive test coverage for all health check scenarios
- Maintain backward compatibility for missing status fields

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [MM-65830] Refactor mmctl system status to exit silently on health failures

Update mmctl system status to exit with code 1 when components are unhealthy
without outputting error messages. This addresses the customer blocker where
AWS ECS health checks were broken after the distroless Docker image change,
as they rely on exit codes to determine service health.

Changes:
- Add withClientAndExitCode wrapper for commands returning (bool, error)
- Modify systemStatusCmdF to return (bool, error) instead of error
- Return (true, nil) when any component is unhealthy (causes exit code 1)
- Return (false, nil) when all components are healthy (causes exit code 0)
- Return (false, error) for actual API/network failures
- Always print status information before checking health
- Update comprehensive test coverage for all scenarios

The refactored approach uses a clean adapter pattern that converts (bool, error)
signatures to standard error returns while delegating to existing withClient
infrastructure to avoid code duplication.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [MM-65830] Ensure printer output is flushed before exit

Add printer.Flush() call before os.Exit(1) in withClientAndExitCode wrapper
to ensure all buffered output is properly written before the program exits.
This ensures status information is always displayed to users even when
exiting with non-zero exit codes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add godoc comment

* Output content then error out

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-06 10:49:46 +00:00
Miguel de la Cruz
3f675734bb
Updates buildFieldAttrs to preseve existing attrs when editing a field (#33991)
* Updates buildFieldAttrs to preseve existing attrs when editing a field

* Fix preserve option issue for select/multiselect type fields

* Fix linter

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-10-01 11:00:06 +02:00
Miguel de la Cruz
a9b894b7c3
Move mmctl cpa subcommands under mmctl user attributes (#33975)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-09-29 11:29:30 +00:00
Miguel de la Cruz
cd3f4483ee
Improves mmctl cpa subcommands' output to show human readable values instead of IDs (#33943)
* Improves `mmctl cpa` subcommands' output to show human readable values instead of IDs

* Adds mmctl docs updates

* Fixed linter

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-09-26 10:56:01 +02:00
Harsh Aulakh
80410e99db
Add e2e tests for ConfigMigrateCmdF (#30161)
* add e2e tests for ConfigMigrateCmdF

* resolve review comments

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-23 14:27:01 +02:00
Ben Schumacher
18eb1347db
[MM-64900] Migrate to use request.CTX instead of context.Context (#33541)
* Migrate GetRoleByName

* Migrate users GetUsers

* Migrate Post and Thread store

* Migrate channel store

* Fix TestConvertGroupMessageToChannel

* Fix TestGetMemberCountsByGroup

* Fix TestPostStoreLastPostTimeCache
2025-09-18 16:14:24 +02:00
Miguel de la Cruz
aad2fa1461
Adds Custom Profile Attributes value commands to mmctl (#33881)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-09-12 17:59:40 +02:00
Miguel de la Cruz
316712522c
Adds Custom Profile Attribute field commands to mmctl (#33789)
* Adds Custom Profile Attribute field commands to mmctl

* Fix linter

* Refactor buildFieldAttrs

* Reverse test to match implementation

* Adds a confirmation prompt

* Refactor the tests

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-11 18:38:21 +02:00
Ben Schumacher
3555665a02
Remove deprecated mmctl user email and username commands (#33754)
- Removed UpdateUserEmailCmd and UpdateUsernameCmd commands
- Deleted updateUserEmailCmdF and updateUsernameCmdF functions
- Commands were deprecated in favor of 'mmctl user edit email/username'

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-08 13:36:25 +02:00
Jesse Hallam
de72b41232
relocate message export (#33805) 2025-08-27 23:22:05 +03:00
Jesse Hallam
dd11197043
MM-64807: Deprecate format parameter in client config endpoint (#33605)
* MM-64807: Deprecate format parameter in client config endpoint

- Remove requirement for format=old query parameter in /api/v4/config/client
- Endpoint now returns client configuration by default without parameters
- Maintain backward compatibility - format parameter is accepted but ignored
- Replace GetOldClientConfig with GetClientConfig across all clients
- Update API documentation to reflect simplified endpoint
- Update webapp client to remove format parameter usage

The endpoint previously returned HTTP 501 without format=old parameter.
Now it returns the client configuration directly, making the API more
intuitive while preserving compatibility with existing clients.

* Update i18n strings after format parameter deprecation

* Update E2E tests to use getClientConfig instead of getClientConfigOld

- Replace getClientConfigOld calls in playwright test library
- Aligns with format parameter deprecation in MM-64807

* Keep format=old parameter in webapp getClientConfig for pre-v11 compatibility
2025-08-20 12:15:11 -03:00
Jesse Hallam
72d363f605
MM-63726: Adjust default MaxOpenConns/MaxIdleConns settings (#33593)
* MM-63726: Adjust default MaxOpenConns/MaxIdleConns settings

- Change MaxOpenConns from 300 to 100
- Change MaxIdleConns from 20 to 50
- Establish a healthier 2:1 ratio instead of the previous 15:1
- Remove hardcoded values from config files to use new defaults

* Fix mmctl config test for updated MaxIdleConns default

Update test expectation from 20 to 50 to match the new default
value for SqlSettings.MaxIdleConns that was changed in the previous
commit.
2025-08-11 14:06:12 -03:00
Pablo Vélez
206c741226
Mm 64495 manage access rules permissions (#31658)
* MM-6449 - manage channel access rules permissions backend part

* add the system console changes to show the new permission

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-25 12:30:10 +02:00
Ben Schumacher
24bb82e345
[MM-63593] Add mmctl user edit command (#31181)
* Add mmctl user edit command

* Add e2e tests

* Use right client method to update authdata

* implement local API endpoint

* Don't allow users to clear the authdata

* make mmctl-docs

* Fix casing

* Fix example

* make mmctl-docs

* Simplify error message

* Fix test

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-25 09:56:25 +02:00
Agniva De Sarker
9dd8c056e7
MM-63368: Remove MySQL (#33458)
https://mattermost.atlassian.net/browse/MM-63368

```release-note
Remove MySQL support from the codebase entirely.
```
2025-07-22 20:40:55 +05:30
Ben Schumacher
54f407b22b
[MM-57062] Update mmctl shell completion to v2 (#31287) 2025-07-18 15:29:01 +02:00
Ben Schumacher
9add320011
[MM-64654] Migrate to modern Go features (#31820) 2025-07-18 12:54:51 +02:00
Ben Schumacher
ae35dd93a9
[MM-64844] Remove deprecated mmctl commands and flags (#33435)
* Remove deprecated mmctl commands and flags

  Remove the following deprecated commands:
  - `channel add` (use `channel users add`)
  - `channel remove` (use `channel users remove`)
  - `channel restore` (use `channel unarchive`)
  - `channel make-private` (use `channel modify --private`)
  - `command delete` (use `command archive`)
  - `permissions show` (use `permissions role show`)

  Remove the following deprecated flags:
  - `--config-path` (use `--config`)
  - `--display_name` (use `--display-name`)
  - `--system_admin` (use `--system-admin`)
  - `--email_verified` (use `--email-verified`)
  - `--attachments` from export create
  - `--resume` from export download
2025-07-18 11:08:29 +02:00
Ben Schumacher
be0d4777ef
[MM-64320] Remove deprecated include_removed_members option in api/v4/ldap/sync (#31121) 2025-07-17 12:35:08 +02:00
Vishal
dbc04cfebe
use consts for audit events (#33433) 2025-07-16 10:17:03 +05:30
Cyrus
e2b6e807c4
[MM-21466] delete users cmd return err (#31191)
* refactored error managment for deleteUsersCmdF

* updated tests related to deleteUsersCmdF

* updated user_e2e_test to reflect changes made to the deleteUsersCmdF function

* Empty-Commit to retrigger workflow

* applied gofmt formating reqs to user_test.go

* added suggested changes to the deleteUsersCmdF regarding error gathering

* added requested changes regarding error aggragation on deleteUsersCmdF

* style(mmctl): removing trailing whitespace

* feat(mmctl): returning errors in deleteUserCmdF on err

* fix(mmctl): returns when err parsing args

* test(mmctl): updated tests to expect err instead of reading printer

* style: updating returned errs

* tests: updated test to reflect error change

* tests(mmctl): updated e2e DeleteUserCmd test

* Update server/cmd/mmctl/commands/user.go

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>

* refactor: changing error to return username instead of email

* refactor: changing email to username for errors

---------

Co-authored-by: Arnaud Wanet <andrewwanet9@gmail.com>
Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-07-09 17:12:04 +02:00
Claudio Costa
47a7e62b44
Fix flaky test TestMmctlE2ESuite/TestPreferenceUpdateCmd (#33375) 2025-07-09 08:01:40 -06:00
Claudio Costa
4a7aeae861
[MM-64663] Fix potential panic in mmctl ldap job show command (#32575)
* Fix potential panic in `mmctl ldap job show` command

* fix examples and docs

---------

Co-authored-by: Christopher Poile <cpoile@gmail.com>
2025-07-04 07:48:17 -06:00
David Krauser
aaa62a40ae
[MM-64686] Expose audit logging functionality via plugin API (#31204)
This commit exposes audit logging functionality to plugins via the plugin API, allowing plugins to create and log audit records. Additionally, it addresses a gob encoding issue that could cause plugin crashes when audit data contains nil pointers or unregistered types.
2025-06-25 20:37:32 -04:00
Christopher Poile
9b1e03a6b8
[MM-63557] mmctl: Add compliance export create cmd (#30594)
* Refactor job retrieval to support multiple statuses & multiple types

- Updated job retrieval functions to handle multiple job statuses.
- Renamed `GetJobsByTypeAndStatus` to `GetJobsByTypesAndStatuses` for consistency across the codebase.
- Adjusted related function signatures and implementations in the job store and retry layer to accommodate the new method.
- Updated tests to reflect changes in job retrieval logic and ensure proper functionality.

* Add compliance export create command and tests

- Introduced `ComplianceExportCreateCmd` to facilitate the creation of compliance export jobs with options for date, start, and end timestamps.
- Added unit tests for the new command, covering various scenarios including valid and invalid inputs.
- Updated documentation to include usage examples and options for the new command.
- Enhanced existing tests to ensure proper functionality of compliance export job handling.

* update docs

* update tests for new logic

* Refactor message export job tests to use DefaultPreviousJobPageSize

- Updated all test cases in worker_test.go to replace hardcoded page size of 100 with DefaultPreviousJobPageSize for consistency.
- Adjusted the worker.go file to define DefaultPreviousJobPageSize and use it in job retrieval logic.
- Ensured that the changes maintain the functionality of job data initialization and retrieval tests.

* PR comments

* PR comments, simplifications, clarifications, formatting

* prefer hypen over underscore in command names

* merge conflict

* update mmctl docs
2025-06-24 21:38:30 +00:00
Christopher Poile
b33a7e362f
[MM-63556] mmctl: Add compliance export download cmd (#30576)
* add mmctl compliance export download command and tests

- Introduced `ComplianceExportDownloadCmd` to facilitate downloading compliance export files.
- Implemented the `DownloadComplianceExport` method in the Client interface for handling file downloads.
- Added unit tests for the download command, covering successful downloads, error handling for non-existent jobs, and retries on failure.
- Included end-to-end tests to validate the command's functionality.
- Updated documentation to include usage examples and options for the new command.

* don't know why this was left out

* PR comments

* adjust test for new retry logic

* refactored download fn for compliance_export and export

* fix test due to fixed logic

* docs
2025-06-24 16:27:54 -04:00
Christopher Poile
e60f878090
[MM-63555] mmctl: Add compliance export show and cancel cmds (#30569)
* add compliance export cancel command and tests

- Introduced `ComplianceExportCancelCmd` to allow cancellation of compliance export jobs.
- Implemented unit tests for the cancellation command, covering successful cancellation, error handling for non-existent jobs, and cancellation in non-cancellable states.
- Added end-to-end tests to validate the command's functionality in the E2E test suite.

* mmctl docs

* clean up example text; remove unneeded getJob

* fix tests

* fix tests, again.

* prefer hyphen for command naming

* update docs
2025-06-24 12:26:43 -04:00
Christopher Poile
9399398e04
[MM-62888] mmctl: Add compliance export list cmd (#30914)
* Add compliance export list cmd and tests

- Introduced `ListComplianceExports` method in the Client interface to retrieve compliance export jobs.
- Added `compliance_export` command with subcommand `list` for listing compliance export jobs, including pagination options.
- Implemented end-to-end and unit tests for the compliance export listing functionality.

* Add docs for mmctl

* fix test typo

* added paging, tested

* update docs with better desc (how it's sorted)

* simplified, reusing job call

* add show cmd, unit tests, e2e tests

* update mmctl docs
2025-06-24 11:20:40 -04:00
Ben Schumacher
cfc1503d62
[MM-63355] Add AuthData to mmctl user search output (#30478) 2025-06-19 11:52:16 +02:00
Jesse Hallam
e6d8bf5835
Upgrade Go to 1.24.3 (#31220)
* Upgrade Go to 1.24.3

Updates the following files:
- server/.go-version: 1.23.9 → 1.24.3
- server/build/Dockerfile.buildenv: golang:1.23.9-bullseye → golang:1.24.3-bullseye
- server/go.mod: go 1.23.0 → go 1.24.3, toolchain go1.23.9 → go1.24.3
- server/public/go.mod: go 1.23.0 → go 1.24.3, toolchain go1.23.9 → go1.24.3

Also fixes non-constant format string errors introduced by Go 1.24.3's stricter format string checking:
- Added response() helper function in slashcommands/util.go for simple string responses
- Removed unused responsef() function from slashcommands/util.go
- Replaced responsef() with response() for translated strings that don't need formatting
- Fixed fmt.Errorf and fmt.Fprintf calls to use proper format verbs instead of string concatenation
- Updated marketplace buildURL to handle format strings conditionally

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update generated mocks for Go 1.24.3

Regenerated mocks using mockery v2.53.4 to ensure compatibility with Go 1.24.3.
This addresses mock generation failures that occurred with the Go upgrade.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update to bookworm and fix non-existent sha

Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>

* fix non-constant format string

---------

Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Stavros Foteinopoulos <stafot@gmail.com>
2025-06-10 15:04:57 -03:00
Harsh Aulakh
09a2037b61
MMCTL: Add import delete cmd for removing the import files (#29764)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-06-10 12:06:38 +02:00
Claudio Costa
d38c27f96f
[MM-64402] Improve validation of imported attachments (#31201)
* Improve validation of imported attachments

* Simplify multiple errors handling

* Improve logic

* Fix abs paths in tests

* Remove redundant clean

* Implement additional validation

* Fix absolute paths in test

* Add additional tests

---------

Co-authored-by: Lorenzo Gallegos <1328683+enzowritescode@users.noreply.github.com>
2025-05-29 07:44:50 +02:00
Harsh Aulakh
8e033f41d1
add config reload e2e tests (#29396)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-05-20 11:26:55 +02:00
Ben Schumacher
c2d08b7540
[MM-63772] Add LDAP setting to re-add removed members (#30787) 2025-05-20 11:15:25 +02:00
Ben Schumacher
e1c94e7b63
Add deactivation status to mmctl user search output (#30379) 2025-05-13 08:52:13 +02:00
Ben Schumacher
bfb15ab179
[MM-61074] Fix errcheck issues in oauth_test.go and web_test.go (#30707)
Co-authored-by: Claude <noreply@anthropic.com>
2025-05-07 12:41:10 +02:00
KIMBOH LOVETTE
b8b3efda48
[GH-25995]_Validate SITE URL in mmctl auth login (#30362) 2025-05-07 12:24:18 +02:00
Harshil Sharma
a5e68639c2
Channel banner permissions (#30917)
* Fixed save state panel for channel banner

* Defined default background color

* Updated test

* WIP

* wip

* removed unused param

* Updated tests

* CI

* Fixed mmctl test

* Fixed TestDoAdvancedPermissionsMigration test

* Test update

* lint fix

* lint fix

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-06 14:03:35 +05:30
AulakhHarsh
3f43a16143
add e2e tests for revokeToken Command (#30149)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-04-14 09:42:35 +02:00
Ben Schumacher
6c8235d031
Fix missing errors in mmctl output (#30567) 2025-03-28 09:30:41 +01:00
Ben Schumacher
4156112f7c
Return error as last value in BulkImport functions (#30575) 2025-03-27 20:17:20 +01:00
AulakhHarsh
3954d2f346
Add e2e tests for showCommandCmdF (#30059)
* add e2e tests for showCommandCmdF

* resolve review comments

* add err check

* remove debug statement

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-26 18:05:10 +00:00
Julien Tant
48ea65aa5f
[MM-56078] mmctl: assume local mode when no credentials found (#26215)
* assume local mode when no credentials found

* Use variable

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-03-26 13:21:21 +01:00
Alejandro García Montoro
350714f390
Bump Go to v1.23.7 (#30455)
* Update Go version to v1.23.7

* Bump golangci-lint to a version supporting Go 1.23

* Fix golangci-lint warnings

Several rules from gosimple, revive and staticcheck linters were
failing:
- Redefinition of built-in identifiers (max, min, new, recover...)
- Use of printf-like functions with simple strings
- Check for nil slices, when len already takes it into account

* Trigger Build

* Trigger Build

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-17 14:22:07 +01:00
Jesse Hallam
fe7d6dcc13
MM-63420: skip flaky tests (#30457) 2025-03-12 15:45:15 +00:00