Skip to content

Commit 95a7b2d

Browse files
add owner role (#43)
1 parent 0135838 commit 95a7b2d

File tree

7 files changed

+136
-144
lines changed

7 files changed

+136
-144
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
name: ci
2-
on: pull_request
2+
on:
3+
pull_request:
4+
types: [opened, reopened, synchronize]
5+
push:
6+
branches:
7+
- main
38
jobs:
49
go-lint:
510
runs-on: ubuntu-latest
611
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
714
- name: Install Go
8-
uses: actions/setup-go@v4
15+
uses: actions/setup-go@v5
916
with:
10-
go-version: 1.23.x
11-
- name: Checkout code
12-
uses: actions/checkout@v3
17+
go-version-file: "go.mod"
1318
- name: Run linters
14-
uses: golangci/golangci-lint-action@v3
19+
uses: golangci/golangci-lint-action@v8
1520
with:
1621
version: latest
1722
args: --timeout=3m
1823
go-test:
1924
strategy:
2025
matrix:
21-
go-version: [1.23.x]
2226
platform: [ubuntu-latest]
2327
runs-on: ${{ matrix.platform }}
2428
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
2531
- name: Install Go
2632
if: success()
27-
uses: actions/setup-go@v4
33+
uses: actions/setup-go@v5
2834
with:
29-
go-version: ${{ matrix.go-version }}
30-
- name: Checkout code
31-
uses: actions/checkout@v3
35+
go-version-file: "go.mod"
3236
- name: go tests
3337
run: go test -v -covermode=count -json ./... > test.json
3438
- name: annotate go tests

.github/workflows/main.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.golangci.yml

Lines changed: 112 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,116 @@
1-
#AUTO GENERATED CODE. UPDATE THE CONFIG IN BATON-TEMPLATE FIRST
2-
linters-settings:
3-
exhaustive:
4-
default-signifies-exhaustive: true
5-
gocritic:
6-
enabled-checks:
7-
- ruleguard
8-
# The list of supported checkers can be find in https://go-critic.github.io/overview.
9-
settings:
10-
underef:
11-
# Whether to skip (*x).method() calls where x is a pointer receiver.
12-
skipRecvDeref: false
13-
ruleguard:
14-
rules: "${configDir}/tools/rules.go"
15-
govet:
16-
enable-all: true
17-
disable:
18-
- fieldalignment # too strict
19-
- shadow # complains too much about shadowing errors. All research points to this being fine.
20-
nakedret:
21-
max-func-lines: 0
22-
nolintlint:
23-
allow-no-explanation: [forbidigo, tracecheck, gomnd, gochecknoinits, makezero]
24-
require-explanation: true
25-
require-specific: true
26-
revive:
27-
ignore-generated-header: true
28-
severity: error
29-
rules:
30-
- name: atomic
31-
- name: line-length-limit
32-
arguments: [200]
33-
# These are functions that we use without checking the errors often. Most of these can't return an error even
34-
# though they implement an interface that can.
35-
- name: unhandled-error
36-
arguments:
37-
- fmt.Printf
38-
- fmt.Println
39-
- fmt.Fprint
40-
- fmt.Fprintf
41-
- fmt.Fprintln
42-
- os.Stderr.Sync
43-
- sb.WriteString
44-
- buf.WriteString
45-
- hasher.Write
46-
- os.Setenv
47-
- os.RemoveAll
48-
- name: var-naming
49-
arguments: [["ID", "URL", "HTTP", "API"], []]
50-
tenv:
51-
all: true
1+
version: "2"
522
linters:
53-
disable-all: true
3+
default: none
544
enable:
55-
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
56-
- gosimple # Linter for Go source code that specializes in simplifying a code
57-
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
58-
- ineffassign # Detects when assignments to existing variables are not used
59-
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
60-
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
61-
- unused # Checks Go code for unused constants, variables, functions and types
62-
- asasalint # Check for pass []any as any in variadic func(...any)
63-
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
64-
- bidichk # Checks for dangerous unicode character sequences
65-
- bodyclose # checks whether HTTP response body is closed successfully
66-
- durationcheck # check for two durations multiplied together
67-
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
68-
- exhaustive # check exhaustiveness of enum switch statements
69-
- forbidigo # Forbids identifiers
70-
- gochecknoinits # Checks that no init functions are present in Go code
71-
- goconst # Finds repeated strings that could be replaced by a constant
72-
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
73-
- godot # Check if comments end in a period
74-
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
75-
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
76-
- goprintffuncname # Checks that printf-like functions are named with f at the end
77-
- gosec # Inspects source code for security problems
78-
- nakedret # Finds naked returns in functions greater than a specified function length
79-
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
80-
- noctx # noctx finds sending http request without context.Context
81-
- nolintlint # Reports ill-formed or insufficient nolint directives
82-
- nonamedreturns # Reports all named returns
83-
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
84-
- predeclared # find code that shadows one of Go's predeclared identifiers
85-
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
86-
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
87-
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
88-
- unconvert # Remove unnecessary type conversions
89-
- usestdlibvars # detect the possibility to use variables/constants from the Go standard library
90-
- whitespace # Tool for detection of leading and trailing whitespace
5+
- asasalint
6+
- asciicheck
7+
- bidichk
8+
- bodyclose
9+
- durationcheck
10+
- errcheck
11+
- errorlint
12+
- exhaustive
13+
- forbidigo
14+
- gochecknoinits
15+
- goconst
16+
- gocritic
17+
- godot
18+
- gomoddirectives
19+
- goprintffuncname
20+
- gosec
21+
- govet
22+
- ineffassign
23+
- nakedret
24+
- nilerr
25+
- noctx
26+
- nolintlint
27+
- nonamedreturns
28+
- nosprintfhostport
29+
- predeclared
30+
- revive
31+
- staticcheck
32+
- tparallel
33+
- unconvert
34+
- unused
35+
- usestdlibvars
36+
- whitespace
37+
settings:
38+
exhaustive:
39+
default-signifies-exhaustive: true
40+
gocritic:
41+
enabled-checks:
42+
- ruleguard
43+
settings:
44+
ruleguard:
45+
rules: ${base-path}/tools/rules.go
46+
underef:
47+
skipRecvDeref: false
48+
govet:
49+
disable:
50+
- fieldalignment
51+
- shadow
52+
enable-all: true
53+
nakedret:
54+
max-func-lines: 0
55+
nolintlint:
56+
require-explanation: true
57+
require-specific: true
58+
allow-no-explanation:
59+
- forbidigo
60+
- tracecheck
61+
- gomnd
62+
- gochecknoinits
63+
- makezero
64+
revive:
65+
severity: error
66+
rules:
67+
- name: atomic
68+
- name: line-length-limit
69+
arguments:
70+
- 200
71+
- name: unhandled-error
72+
arguments:
73+
- fmt.Printf
74+
- fmt.Println
75+
- fmt.Fprint
76+
- fmt.Fprintf
77+
- fmt.Fprintln
78+
- os.Stderr.Sync
79+
- sb.WriteString
80+
- buf.WriteString
81+
- hasher.Write
82+
- os.Setenv
83+
- os.RemoveAll
84+
- name: var-naming
85+
arguments:
86+
- - ID
87+
- URL
88+
- HTTP
89+
- API
90+
- []
91+
exclusions:
92+
generated: lax
93+
presets:
94+
- comments
95+
- common-false-positives
96+
- legacy
97+
- std-error-handling
98+
rules:
99+
- linters:
100+
- godot
101+
source: (TODO)
102+
paths:
103+
- third_party$
104+
- builtin$
105+
- examples$
91106
issues:
92107
max-same-issues: 50
93-
exclude-rules:
94-
# Don't require TODO comments to end in a period
95-
- source: "(TODO)"
96-
linters: [godot]
108+
formatters:
109+
enable:
110+
- goimports
111+
exclusions:
112+
generated: lax
113+
paths:
114+
- third_party$
115+
- builtin$
116+
- examples$

pkg/connector/role.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ const (
2525
roleGuest = "guest"
2626
roleUser = "user"
2727
roleAdmin = "admin"
28+
roleOwner = "owner"
2829
)
2930

3031
var roles = []string{
3132
roleGuest,
3233
roleUser,
3334
roleAdmin,
35+
roleOwner,
3436
}
3537

3638
// Create a new connector resource for a Linear role.

pkg/connector/user.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func userResource(ctx context.Context, user *linear.User, parentResourceID *v2.R
3838

3939
var userRole string
4040
switch {
41+
case user.Owner:
42+
userRole = roleOwner
4143
case user.Admin:
4244
userRole = roleAdmin
4345
case user.Guest:

pkg/linear/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func (c *Client) GetUsers(ctx context.Context, getResourceVars GetResourcesVars)
170170
organization {
171171
id
172172
}
173+
owner
173174
}
174175
pageInfo {
175176
endCursor
@@ -299,6 +300,7 @@ func (c *Client) GetOrganization(ctx context.Context, paginationVars PaginationV
299300
id
300301
admin
301302
guest
303+
owner
302304
}
303305
pageInfo {
304306
hasPreviousPage
@@ -450,6 +452,7 @@ func (c *Client) Authorize(ctx context.Context) (ViewerPermissions, *http.Respon
450452
guest
451453
id
452454
admin
455+
owner
453456
}
454457
}`
455458
b := map[string]interface{}{

pkg/linear/models.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type User struct {
5757
Teams struct {
5858
Nodes []Team `json:"nodes"`
5959
} `json:"teams"`
60+
Owner bool `json:"owner"`
6061
}
6162

6263
type Team struct {
@@ -110,6 +111,7 @@ func (e *GraphQLError) Message() string {
110111
type ViewerPermissions struct {
111112
Guest bool `json:"guest"`
112113
Admin bool `json:"admin"`
114+
Owner bool `json:"owner"`
113115
ID string `json:"id"`
114116
}
115117

0 commit comments

Comments
 (0)