Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for build tags #1054

Merged
merged 1 commit into from
Mar 22, 2020
Merged

Add support for build tags #1054

merged 1 commit into from
Mar 22, 2020

Conversation

qaisjp
Copy link
Collaborator

@qaisjp qaisjp commented Mar 22, 2020

[gitter] I see. Thank you. Is it possible to make a build choosing with platforms to support? (just curious)

This feature makes that possible. I just want to see if I could do it, I don't really care about this being merged, but it works if you want it!

By default all bridges are available.

You can turn off certain bridges by providing
e.g. "withoutdiscord" as a build tag.

go build -tags withoutmsteams,withoutapi

Example config

(simple with just discord, slack and telegram)
[telegram]
[telegram.test]
Token="tok"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

[discord]
[discord.mta]
Token="tok"
Server="id"
RemoteNickFormat="{NICK}"
WebhookURL="tok"
ShowEmbeds=true

[slack]
[slack.mta]
Token="tok"
RemoteNickFormat="{NICK}"

[[gateway]]
name="mta.test"
enable=true

[[gateway.inout]]
account="slack.mta"
channel="test"

[[gateway.inout]]
account="discord.mta"
channel="test"

[[gateway.inout]]
account="telegram.test"
channel="-411596043"

Example: without discord

➜ go build -tags withoutdiscord
➜ ./matterbridge -debug
[0000]  INFO main:         Enabling debug logging.
[0000]  INFO main:         Running version 1.17.1-dev
[0000]  INFO main:         WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.
[0000] FATAL gateway:      Incorrect protocol discord specified in gateway configuration discord.mta, exiting.

Example: size with/without msteams

➜ go build
➜ ls -lah matterbridge
-rwxr-xr-x  1 qaisjp  staff    61M 22 Mar 04:45 matterbridge

➜ go build --tags withoutmsteams
➜ ls -lah matterbridge
-rwxr-xr-x  1 qaisjp  staff    34M 22 Mar 04:45 matterbridge

Example: without any tags

➜ go build
➜ ./matterbridge
[2020-03-22T04:46:31Z]  INFO main:         Running version 1.17.1-dev
[2020-03-22T04:46:31Z]  INFO main:         WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.
[2020-03-22T04:46:31Z]  INFO router:       Parsing gateway mta.test
[2020-03-22T04:46:31Z]  INFO router:       Starting bridge: discord.mta
[2020-03-22T04:46:31Z]  INFO discord:      Connecting
[2020-03-22T04:46:31Z]  INFO discord:      Connecting using webhookurl (for posting) and token
[2020-03-22T04:46:31Z]  INFO discord:      Connection succeeded
[2020-03-22T04:46:32Z]  INFO discord:      Can manage webhooks; will edit channel for global webhook on send
[2020-03-22T04:46:33Z]  INFO discord:      discord.mta: joining test (ID: testdiscord.mta)
[2020-03-22T04:46:33Z]  INFO router:       Starting bridge: telegram.test
[2020-03-22T04:46:33Z]  INFO telegram:     Connecting
[2020-03-22T04:46:33Z]  INFO telegram:     Connection succeeded
[2020-03-22T04:46:33Z]  INFO telegram:     telegram.test: joining -411596043 (ID: -411596043telegram.test)
[2020-03-22T04:46:33Z]  INFO router:       Starting bridge: slack.mta
[2020-03-22T04:46:33Z]  INFO slack:        Connecting using token
[2020-03-22T04:46:33Z]  INFO slack:        slack.mta: joining test (ID: testslack.mta)
[2020-03-22T04:46:33Z]  INFO main:         Gateway(s) started succesfully. Now relaying messages

@42wim
Copy link
Owner

42wim commented Mar 22, 2020

It's a good idea and gives people easy options to exclude stuff, with msteams we now also need 1.5GB ram to build.
I've added a linter exclude for the bridgemap, could you rebase on master ?

@qaisjp qaisjp force-pushed the feature/build-tags branch from 6dcec8d to 07927ac Compare March 22, 2020 14:55
@qaisjp
Copy link
Collaborator Author

qaisjp commented Mar 22, 2020

Rebased! Also, I'm not sure if withoutdiscord or nodiscord is preferred

@42wim
Copy link
Owner

42wim commented Mar 22, 2020

I think "no" is better. You ok with rebasing once more with that change?

@qaisjp qaisjp force-pushed the feature/build-tags branch from 07927ac to 062cb3c Compare March 22, 2020 15:49
@qaisjp
Copy link
Collaborator Author

qaisjp commented Mar 22, 2020

Yes, done!

@qaisjp
Copy link
Collaborator Author

qaisjp commented Mar 22, 2020

Wait, I need to change commit message

By default all bridges are available.

You can turn off certain bridges by providing
e.g. "nodiscord" as a build tag.

    go build -tags nomsteams,noapi
@qaisjp qaisjp force-pushed the feature/build-tags branch from 062cb3c to 9defe06 Compare March 22, 2020 15:50
@42wim 42wim added this to the 1.17.1 milestone Mar 22, 2020
@42wim 42wim merged commit 2b7eab6 into 42wim:master Mar 22, 2020
@qaisjp qaisjp deleted the feature/build-tags branch March 22, 2020 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants