Compare commits

...

6 Commits

Author SHA1 Message Date
IamTheFij afffddc07b Comply with updated linting
continuous-integration/drone/push Build is passing Details
2023-09-19 13:55:08 -07:00
IamTheFij b74edaff2f Update go version and slack dependency
continuous-integration/drone/push Build is failing Details
2023-09-19 13:18:44 -07:00
IamTheFij fb0fe18eb7 Don't delete certs when cleaning 2023-09-19 13:18:27 -07:00
IamTheFij 83279f4fbf Fix git links in pre-commit-config 2023-09-19 13:18:14 -07:00
IamTheFij a388a3f78b Add linux-arm64 builds
continuous-integration/drone/push Build is passing Details
2022-01-27 21:17:32 -08:00
IamTheFij 5d2f4b1bba Update readme to describe removal of openssl dependency
continuous-integration/drone/push Build is passing Details
2021-02-17 10:31:06 -08:00
6 changed files with 29 additions and 19 deletions

View File

@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- repo: git://github.com/dnephin/pre-commit-golang
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.3.5
hooks:
- id: go-fmt

View File

@ -1,6 +1,6 @@
OUTPUT = slack-status
GOFILES = *.go go.mod go.sum
DIST_ARCH = darwin-amd64 darwin-arm64 linux-amd64
DIST_ARCH = darwin-amd64 darwin-arm64 linux-amd64 linux-arm64
DIST_TARGETS = $(addprefix dist/$(OUTPUT)-,$(DIST_ARCH))
VERSION ?= $(shell git describe --tags --dirty)
@ -46,6 +46,9 @@ certs/key.pem:
clean:
rm -f ./slack-status
rm -fr ./dist
.PHONY: clean-certs
clean-certs:
rm -fr ./certs
.PHONY: install-hooks

View File

@ -4,9 +4,9 @@ Set your Slack status via the command line
## Requirements
Rather than host a web server that you would need to trust, this command runs one on your local machine to retrieve the OAuth code. This page is hosted with an auto generated, self-signed certificate.
Rather than host a web server that you would need to trust, this command runs one on your local machine to retrieve the OAuth code. This page is hosted with an embedded, self-signed certificate.
This requires you to have `openssl` installed on your machine and, when the page loads for the first time, it will require you to trust the certificate or ignore the warning.
When the page loads for the first time, it will require you to trust the certificate or ignore the warning.
Here's how to do that on [Firefox](https://support.mozilla.org/en-US/kb/error-codes-secure-websites?as=u&utm_source=inproduct#w_self-signed-certificate). On Chrome, you may have to enable `chrome://flags/#allow-insecure-localhost`. If you can't get the link to open in Chrome, you can copy the URL into a different browser and try it there. It should work in Firefox or Safari.
@ -69,3 +69,7 @@ Clear existing status and snooze durations
Snooze notifications without updating your status
slack-status -duration 15m -snooze
## Development
Building requires you to have `openssl` installed on your machine and to export `CLIENT_ID` and `CLIENT_SECRET` environment variables. The certificate and client info can be overridden at runtime for development purposes by running with exported variables post compilation as well as placing the your openssl pem files in the application's config directory. See `auth.go` for more information.

View File

@ -4,12 +4,16 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
)
const (
PERM_OWNER_RW = 0o600
PERM_RW_ALL = 0o755
)
var errUnknownDomain = errors.New("unknown domain")
type configData struct {
@ -27,7 +31,7 @@ func getConfigFilePath(filename string) (string, error) {
}
configDir = filepath.Join(configDir, configApplicationName)
_ = os.MkdirAll(configDir, 0o755)
_ = os.MkdirAll(configDir, PERM_RW_ALL)
configFile := filepath.Join(configDir, filename)
// Handle migration of old config file path
@ -70,7 +74,7 @@ func readConfig() (*configData, error) {
return &configData{DomainTokens: map[string]string{}}, nil
}
content, err := ioutil.ReadFile(configPath)
content, err := os.ReadFile(configPath)
if err != nil {
return nil, fmt.Errorf("error reading config from file: %w", err)
}
@ -97,7 +101,7 @@ func writeConfig(config configData) error {
return fmt.Errorf("failed converting config to json: %w", err)
}
if err = ioutil.WriteFile(configPath, contents, 0o600); err != nil {
if err = os.WriteFile(configPath, contents, PERM_OWNER_RW); err != nil {
return fmt.Errorf("error writing config to file: %w", err)
}

6
go.mod
View File

@ -1,5 +1,7 @@
module github.com/iamthefij/slack-status-cli
go 1.16
go 1.21
require github.com/slack-go/slack v0.7.4
require github.com/slack-go/slack v0.12.3
require github.com/gorilla/websocket v1.5.0 // indirect

15
go.sum
View File

@ -1,14 +1,11 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho=
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/slack-go/slack v0.7.4 h1:Z+7CmUDV+ym4lYLA4NNLFIpr3+nDgViHrx8xsuXgrYs=
github.com/slack-go/slack v0.7.4/go.mod h1:FGqNzJBmxIsZURAxh2a8D21AnOVvvXZvGligs4npPUM=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/slack-go/slack v0.12.3 h1:92/dfFU8Q5XP6Wp5rr5/T5JHLM5c5Smtn53fhToAP88=
github.com/slack-go/slack v0.12.3/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=