Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
clockworksoul committed Oct 5, 2021
2 parents a021fa1 + 012b2b8 commit 67d029c
Show file tree
Hide file tree
Showing 34 changed files with 1,300 additions and 526 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/quickstart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

function cleanup() {
ARG=$?
LAST=$previous_command
echo -e "\n=== Cleanup ==="
rm gort
docker-compose down
echo -e "\n"

if [ $ARG = 0 ]; then
echo "Passed!"
else
echo "Last command: $LAST"
echo "Failed!"
fi

exit $ARG
}
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap cleanup EXIT

# Exit on failure
set -e

# Create your Configuration File
cp config.yml development.yml

# Create a Slack Bot User
# This can be skipped as Gort will run when it cannot connect to Slack
# But could this be mocked in future?

# Build the Gort Image
make image

# Starting Containerized Gort
docker-compose up -d

# Bootstrapping Gort
wait-port -t 10000 4000
go build -o gort
./gort bootstrap --allow-insecure localhost:4000

# Using Gort.
# TODO: Worth having a hidden command to emulate this?
16 changes: 15 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,18 @@ jobs:
with:
coverageLocations: |
${{github.workspace}}/*.out:gocov
prefix: github.com/getgort/gort
prefix: github.com/getgort/gort
Quickstart:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.16.5' # The Go version to download (if necessary) and use.
- uses: actions/setup-node@v1
with:
node-version: '16.4.x'
- name: Install
run: npm install -g wait-port
- name: Test
run: ${GITHUB_WORKSPACE}/.github/workflows/quickstart.sh
10 changes: 5 additions & 5 deletions adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ type Adapter interface {
// GetName provides the name of this adapter as per the configuration.
GetName() string

// GetPresentChannels returns a slice of channels that a user is present in.
GetPresentChannels(userID string) ([]*ChannelInfo, error)
// GetPresentChannels returns a slice of channels that the adapter is present in.
GetPresentChannels() ([]*ChannelInfo, error)

// GetUserInfo provides info on a specific provider user accessible
// to the adapter.
Expand Down Expand Up @@ -197,7 +197,7 @@ func OnConnected(ctx context.Context, event *ProviderEvent, data *ConnectedEvent

le.Info("Connection established to provider")

channels, err := event.Adapter.GetPresentChannels(event.Info.User.ID)
channels, err := event.Adapter.GetPresentChannels()
if err != nil {
telemetry.Errors().WithError(err).Commit(ctx)
addSpanAttributes(ctx, sp, err)
Expand Down Expand Up @@ -615,7 +615,7 @@ func addSpanAttributes(ctx context.Context, sp trace.Span, obs ...interface{}) {

case *ProviderEvent:
attr = append(attr,
attribute.String("event", o.EventType),
attribute.String("event", string(o.EventType)),
attribute.String("adapter.name", o.Info.Provider.Name),
attribute.String("adapter.type", o.Info.Provider.Type),
)
Expand Down Expand Up @@ -894,7 +894,7 @@ func handleIncomingEvent(event *ProviderEvent, commandRequests chan<- data.Comma
ctx, sp := tr.Start(context.Background(), "adapter.handleIncomingEvent")
defer sp.End()

sp.SetAttributes(attribute.String("event.type", event.EventType))
sp.SetAttributes(attribute.String("event.type", string(event.EventType)))

switch ev := event.Data.(type) {
case *ConnectedEvent:
Expand Down
17 changes: 15 additions & 2 deletions adapter/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,28 @@ import (

// Info is used by events to wrap user and provider info.
type Info struct {
User *UserInfo
Provider *ProviderInfo
}

// EventType specifies the kind of event received from an adapter
// in response to an event from the chat server.
type EventType string

const (
EventChannelMessage EventType = "channel_message"
EventConnected EventType = "connected"
EventConnectionError EventType = "connection_error"
EventDirectMessage EventType = "direct_message"
EventDisconnected EventType = "disconnected"
EventAuthenticationError EventType = "authentication_error"
EventError EventType = "error"
)

// ProviderEvent is the main wrapper. You will find all the other messages
// attached as Data
type ProviderEvent struct {
// The type of event
EventType string
EventType EventType

// The event instance
Data interface{}
Expand Down
Loading

0 comments on commit 67d029c

Please sign in to comment.