Skip to content

Commit f92856e

Browse files
authored
Merge pull request #497 from slashdevops/fix/issue#496
fix: panic on empty slices, data race, and code modernization (issue #496)
2 parents ab35963 + db3aba2 commit f92856e

33 files changed

Lines changed: 598 additions & 387 deletions

.github/copilot-instructions.md

Lines changed: 16 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Follows these guidelines precisely to ensure consistency and maintainability of
99

1010
## Stack
1111

12-
- Language: Go (Go 1.24+)
12+
- Language: Go (Go 1.26+)
1313
- Framework: Go standard library
1414
- Testing: Go's built-in testing package
1515
- Build Tool: `make` using the Makefile with all the targets defined to build, test, and run the application
@@ -21,101 +21,6 @@ Follows these guidelines precisely to ensure consistency and maintainability of
2121
- Database: PostgreSQL
2222
- Logging: `slog` package from the standard library
2323

24-
## Project Structure
25-
26-
This project implements a kind of Model-View-Controller (MVC) architecture, the main components are:
27-
28-
- Core: located in the `internal/core` package, it contains the business logic of the application.
29-
- Config: located in the `internal/config` package, it contains the configuration of the application
30-
- Model: located in the `internal/model` package, it contains the data structures or entities used in the application.
31-
- Repository: located in the `internal/repository` package, it contains the data access layer for interacting with the database.
32-
- Identity Provider conversion: located in the `internal/idp/` package, This is the glue between the logic into `internal/core` and the identity provider located at `pkg/google/` package.
33-
- SCIM conversion: located in the `internal/scim/` package, This is the glue between the logic into `internal/core` and the SCIM API located at `pkg/aws/` package.
34-
35-
The project structure is organized as follows:
36-
37-
```plaintext
38-
.
39-
├── build
40-
│   ├── coverage.txt
41-
│   ├── idpscim
42-
│   └── idpscimcli
43-
├── cmd
44-
│   ├── idpscim
45-
│   │   ├── cmd
46-
│   │   │   └── root.go
47-
│   │   └── main.go
48-
│   └── idpscimcli
49-
│   ├── cmd
50-
│   │   ├── aws.go
51-
│   │   ├── common.go
52-
│   │   ├── gws.go
53-
│   │   └── root.go
54-
│   └── main.go
55-
├── CODE_OF_CONDUCT.md
56-
├── CONTRIBUTING.md
57-
├── coverage.out
58-
├── DCO
59-
├── Dockerfile
60-
├── docs
61-
│   ├── AWS-SAM-Template.md
62-
│   ├── AWS-SAM.md
63-
│   ├── Configuration.md
64-
│   ├── Demo.md
65-
│   ├── Development.md
66-
│   ├── idpscim.md
67-
│   ├── idpscimcli.md
68-
│   ├── images
69-
│   │   ├── demo
70-
│   │   │   ├── aws-groups-developers.png
71-
│   │   │   ├── aws-groups.png
72-
│   │   │   ├── aws-s3-state-file.png
73-
│   │   │   ├── aws-users.png
74-
│   │   │   ├── gws-groups-developers.png
75-
│   │   │   ├── gws-groups.png
76-
│   │   │   ├── gws-users.png
77-
│   │   │   ├── idpscim-help.png
78-
│   │   │   ├── state-file.png
79-
│   │   │   ├── sync-1.png
80-
│   │   │   └── sync-2.png
81-
│   │   └── diagrams
82-
│   │   ├── idpscim--workflow.drawio.html
83-
│   │   ├── idpscim--workflow.drawio.png
84-
│   │   └── ipd-scim-sync.drawio.png
85-
│   ├── Release.md
86-
│   ├── State-File-example.md
87-
│   └── Using-SSO.md
88-
├── extras
89-
│   └── infra
90-
│   ├── 1_cfn-slashdevops-iam-oidc-github-provider.template
91-
│   ├── 2_cfn-slashdevops-iam-role-idp-scim-sync.template
92-
│   ├── 3_cfn-slashdevops-ecr-repo-idp-scim-sync.template
93-
│   ├── 4_cfn-slashdevops-iam-policy-idp-scim-sync-ecr.template
94-
│   ├── 4_cfn-slashdevops-s3-idp-scim-sync-sam.template
95-
│   ├── 5_cfn-slashdevops-iam-policy-idp-scim-sync-sam.template
96-
│   └── README.md
97-
├── go.mod
98-
├── go.sum
99-
├── internal
100-
│   ├── config
101-
│   ├── core
102-
│   ├── deepcopy
103-
│   ├── idp
104-
│   ├── model
105-
│   ├── repository
106-
│   ├── scim
107-
│   └── version
108-
├── LICENSE
109-
├── Makefile
110-
├── mocks
111-
├── pkg
112-
│   ├── aws
113-
│   └── google
114-
├── README.md
115-
├── SECURITY.md
116-
└── template.yaml
117-
```
118-
11924
## Code Style
12025

12126
- Follow Go's idiomatic style defined in
@@ -128,14 +33,19 @@ The project structure is organized as follows:
12833
- Use comments to explain complex logic or decisions.
12934
- Use dependency injection for services and repositories to facilitate testing and maintainability.
13035

131-
## Testing
36+
## Post-Change Checklist
37+
38+
Prefer the Make targets that the repo already defines after making changes:
39+
40+
```bash
41+
go fix ./... # Optional manual step for Go 1.26+ syntax
42+
make go-fmt # Format code
43+
make go-betteralign # Align struct fields for optimal memory layout
44+
golangci-lint run ./... # Run linter (also checks formatting, vet, and other issues)
45+
make build # Verify build
46+
make test # Run tests
47+
```
48+
49+
If you are intentionally modernizing syntax or APIs for Go 1.26+, run `go fix ./...` manually as a separate step.
13250

133-
- Write unit tests implementing test tables for all functions when applicable.
134-
- Use the `testing` package for writing tests.
135-
- Use `go test` to run tests.
136-
- Use `go test -cover` to check code coverage.
137-
- Use `go test -race` to check for race conditions.
138-
- Use `go test -bench` to run benchmarks.
139-
- Use `go test -v` for verbose output during testing.
140-
- Use `go test -run` to run specific tests.
141-
- Use `go test -short` to run short tests.
51+
Always keep `README.md` and `docs/` updated for any architectural changes, new commands/flags, removed flags, new packages, or changes to the development workflow. This includes command usage examples, flag tables, and CLI reference sections.

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"AWSS",
88
"AWSSCIM",
99
"Babs",
10+
"betteralign",
1011
"bjensen",
1112
"christiangda",
1213
"cmpopts",
@@ -87,5 +88,8 @@
8788
"usrs",
8889
"vuln",
8990
"Warnf"
90-
]
91+
],
92+
"chat.tools.terminal.autoApprove": {
93+
"$(go": true
94+
}
9195
}

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/copilot-instructions.md

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/copilot-instructions.md

go.mod

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
module github.com/slashdevops/idp-scim-sync
22

3-
go 1.25.5
3+
go 1.26.1
44

55
require (
6-
github.com/aws/aws-lambda-go v1.52.0
7-
github.com/aws/aws-sdk-go-v2 v1.41.1
8-
github.com/aws/aws-sdk-go-v2/config v1.32.7
9-
github.com/aws/aws-sdk-go-v2/credentials v1.19.7
10-
github.com/aws/aws-sdk-go-v2/service/s3 v1.95.1
11-
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.41.1
6+
github.com/aws/aws-lambda-go v1.54.0
7+
github.com/aws/aws-sdk-go-v2 v1.41.5
8+
github.com/aws/aws-sdk-go-v2/config v1.32.13
9+
github.com/aws/aws-sdk-go-v2/credentials v1.19.13
10+
github.com/aws/aws-sdk-go-v2/service/s3 v1.97.3
11+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.41.5
1212
github.com/google/go-cmp v0.7.0
1313
github.com/p2p-b2b/httpretrier v0.0.4
1414
github.com/pkg/errors v0.9.1
1515
github.com/spf13/cobra v1.10.2
1616
github.com/spf13/viper v1.21.0
1717
github.com/stretchr/testify v1.11.1
1818
go.uber.org/mock v0.6.0
19-
golang.org/x/oauth2 v0.34.0
20-
golang.org/x/sync v0.19.0
21-
google.golang.org/api v0.260.0
19+
golang.org/x/oauth2 v0.36.0
20+
golang.org/x/sync v0.20.0
21+
google.golang.org/api v0.273.0
2222
gopkg.in/yaml.v3 v3.0.1
2323
)
2424

2525
require (
26-
cloud.google.com/go/auth v0.18.0 // indirect
26+
cloud.google.com/go/auth v0.18.2 // indirect
2727
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
2828
cloud.google.com/go/compute/metadata v0.9.0 // indirect
29-
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.4 // indirect
30-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.17 // indirect
31-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.17 // indirect
32-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.17 // indirect
33-
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
34-
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.17 // indirect
35-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.4 // indirect
36-
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.8 // indirect
37-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.17 // indirect
38-
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.17 // indirect
39-
github.com/aws/aws-sdk-go-v2/service/signin v1.0.5 // indirect
40-
github.com/aws/aws-sdk-go-v2/service/sso v1.30.9 // indirect
41-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.13 // indirect
42-
github.com/aws/aws-sdk-go-v2/service/sts v1.41.6 // indirect
43-
github.com/aws/smithy-go v1.24.0 // indirect
29+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 // indirect
30+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.21 // indirect
31+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 // indirect
32+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 // indirect
33+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.6 // indirect
34+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.22 // indirect
35+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7 // indirect
36+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.13 // indirect
37+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21 // indirect
38+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.21 // indirect
39+
github.com/aws/aws-sdk-go-v2/service/signin v1.0.9 // indirect
40+
github.com/aws/aws-sdk-go-v2/service/sso v1.30.14 // indirect
41+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.18 // indirect
42+
github.com/aws/aws-sdk-go-v2/service/sts v1.41.10 // indirect
43+
github.com/aws/smithy-go v1.24.2 // indirect
4444
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4545
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4646
github.com/felixge/httpsnoop v1.0.4 // indirect
@@ -50,10 +50,10 @@ require (
5050
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
5151
github.com/google/s2a-go v0.1.9 // indirect
5252
github.com/google/uuid v1.6.0 // indirect
53-
github.com/googleapis/enterprise-certificate-proxy v0.3.9 // indirect
54-
github.com/googleapis/gax-go/v2 v2.16.0 // indirect
53+
github.com/googleapis/enterprise-certificate-proxy v0.3.14 // indirect
54+
github.com/googleapis/gax-go/v2 v2.19.0 // indirect
5555
github.com/inconshreveable/mousetrap v1.1.0 // indirect
56-
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
56+
github.com/pelletier/go-toml/v2 v2.3.0 // indirect
5757
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
5858
github.com/sagikazarmark/locafero v0.12.0 // indirect
5959
github.com/spf13/afero v1.15.0 // indirect
@@ -62,18 +62,18 @@ require (
6262
github.com/subosito/gotenv v1.6.0 // indirect
6363
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
6464
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect
65-
go.opentelemetry.io/otel v1.39.0 // indirect
66-
go.opentelemetry.io/otel/metric v1.39.0 // indirect
67-
go.opentelemetry.io/otel/trace v1.39.0 // indirect
65+
go.opentelemetry.io/otel v1.42.0 // indirect
66+
go.opentelemetry.io/otel/metric v1.42.0 // indirect
67+
go.opentelemetry.io/otel/trace v1.42.0 // indirect
6868
go.yaml.in/yaml/v3 v3.0.4 // indirect
69-
golang.org/x/crypto v0.46.0 // indirect
70-
golang.org/x/mod v0.31.0 // indirect
71-
golang.org/x/net v0.48.0 // indirect
72-
golang.org/x/sys v0.40.0 // indirect
73-
golang.org/x/text v0.33.0 // indirect
74-
golang.org/x/tools v0.40.0 // indirect
75-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
76-
google.golang.org/grpc v1.78.0 // indirect
69+
golang.org/x/crypto v0.49.0 // indirect
70+
golang.org/x/mod v0.33.0 // indirect
71+
golang.org/x/net v0.52.0 // indirect
72+
golang.org/x/sys v0.42.0 // indirect
73+
golang.org/x/text v0.35.0 // indirect
74+
golang.org/x/tools v0.42.0 // indirect
75+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260319201613-d00831a3d3e7 // indirect
76+
google.golang.org/grpc v1.79.3 // indirect
7777
google.golang.org/protobuf v1.36.11 // indirect
7878
)
7979

0 commit comments

Comments
 (0)