Skip to content

Commit 9ad8fc6

Browse files
authored
feat: switch to go root ca certificates (#130)
1 parent f363c5d commit 9ad8fc6

File tree

17 files changed

+234
-45
lines changed

17 files changed

+234
-45
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@ updates:
1515
directory: /
1616
schedule:
1717
interval: weekly
18-
- package-ecosystem: docker
19-
directory: /
20-
schedule:
21-
interval: weekly

.github/workflows/tests.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ jobs:
1515
- uses: actions/setup-go@v6
1616
with:
1717
go-version-file: go.mod
18+
- run: echo ${{ secrets.SMOKE_TEST_CREDENTIALS_B64 }} | base64 -d > credentials.json
19+
shell: bash
1820
- run: make test
1921
shell: bash
20-
- name: Upload artifacts
21-
uses: actions/upload-artifact@v4
22-
with:
23-
name: coverage-artifacts
24-
path: build/coverage.*
25-
if-no-files-found: error
2622

2723
documentation-tests:
2824
name: Documentation tests

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
golang 1.24.2
1+
golang 1.25.3

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
FROM golang:alpine AS build
22
COPY . .
33
ARG VERSION
4-
RUN go build -trimpath -o /app/ \
5-
-ldflags "-s -w -X github.com/codereaper/lane/cmd.versionString=$VERSION"
4+
RUN go build -trimpath -o /app/ -ldflags "-s -w -X github.com/codereaper/lane/cmd.versionString=$VERSION"
65

76
FROM scratch
8-
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
97
COPY --from=build /app/lane /
108
ENTRYPOINT [ "/lane" ]

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,27 @@ endif
3636

3737
unit-tests:
3838
go test -timeout 10s -p 1 -coverprofile=build/coverage.out ./internal/...
39+
ifeq ($(strip $(GITHUB_STEP_SUMMARY)),)
3940
go tool cover -html=build/coverage.out -o build/coverage.html
41+
go tool cover -func=build/coverage.out
42+
else
43+
{ \
44+
echo '## Code Coverage'; \
45+
echo '|File|Method|Coverage|'; \
46+
echo '|---|---|--:|'; \
47+
go tool cover -func=build/coverage.out | awk -F'\t+' 'BEGIN {OFS=" | "} {print "| " $$1, $$2, $$3 " |"}'; \
48+
} | tee -a $(GITHUB_STEP_SUMMARY)
49+
endif
50+
51+
smoke-test:
52+
@if [ -f credentials.json ]; then \
53+
go run ./... translations list -c credentials.json; \
54+
fi
4055

4156
verify-version:
4257
ifneq ($(TOOL_VERSION),$(MOD_VERSION))
4358
@echo 'Mismatched go versions'
4459
@exit 1
4560
endif
46-
@exit 0
4761

48-
test: verify-version tidy unit-tests
62+
test: verify-version tidy unit-tests smoke-test

TODO.md

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

cmd/translations.go

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ package cmd
22

33
import (
44
"context"
5+
"fmt"
56

67
"github.com/codereaper/lane/internal/downloader"
78
"github.com/codereaper/lane/internal/translations"
89
"github.com/spf13/cobra"
910
)
1011

12+
var additionalHelpAboutAuthentication = `Authentication is done using a json file issued by Google. You get this json file by creating a "Service Account Key", which if you do not have a service account, requires you to first create a service account.
13+
14+
Creating both an account and a key is explaining here: https://developers.google.com/identity/protocols/oauth2/service-account#creatinganaccount
15+
16+
You may have to enable Google Drive API access when using it for the first time. The error message(s) should provide a direct link to enabling access.
17+
18+
Make sure to share the sheet with the 'client_email' assigned to your service account.
19+
`
20+
1121
func newTranslationsCommand() *cobra.Command {
1222
var cmd = &cobra.Command{
1323
Use: "translations",
@@ -16,23 +26,40 @@ func newTranslationsCommand() *cobra.Command {
1626
}
1727
cmd.AddCommand(newTranslationsDownloadCommand())
1828
cmd.AddCommand(newTranslationsGenerateCommand())
29+
cmd.AddCommand(newTranslationsListCommand())
1930
return cmd
2031
}
2132

22-
func newTranslationsDownloadCommand() *cobra.Command {
23-
var additionalHelp = `Authentication is done using a json file issued by Google. You get this json file by creating a "Service Account Key", which if you do not have a service account, requires you to first create a service account.
24-
25-
Creating both an account and a key is explaining here: https://developers.google.com/identity/protocols/oauth2/service-account#creatinganaccount
26-
27-
You may have to enable Google Drive API access when using it for the first time. The error message(s) should provide a direct link to enabling access.
33+
func newTranslationsListCommand() *cobra.Command {
34+
var credentials string
35+
var cmd = &cobra.Command{
36+
Use: "list",
37+
Short: "List google sheets",
38+
Long: additionalHelpAboutAuthentication,
39+
Example: " lane translations list -c google-api.json",
40+
RunE: func(cmd *cobra.Command, args []string) error {
41+
list, err := downloader.List(context.Background(), credentials)
42+
if err != nil {
43+
return err
44+
}
45+
fmt.Printf("Documents (count: %d):\n", len(list))
46+
for id, name := range list {
47+
fmt.Printf("Id: %s \tName: %s\n", id, name)
48+
}
49+
return nil
50+
},
51+
}
52+
cmd.Flags().StringVarP(&credentials, "credentials", "c", "", "A path to the credentials json file issued by Google (Required).")
53+
cmd.MarkFlagRequired("credentials")
54+
return cmd
55+
}
2856

29-
Make sure to share the sheet with the 'client_email' assigned to your service account.
30-
`
57+
func newTranslationsDownloadCommand() *cobra.Command {
3158
var flags downloader.Flags
3259
var cmd = &cobra.Command{
3360
Use: "download",
34-
Short: "Download translations",
35-
Long: additionalHelp,
61+
Short: "Download google sheets",
62+
Long: additionalHelpAboutAuthentication,
3663
Example: " lane translations download -o output.csv -c google-api.json -d 11p...ev7lc -f csv",
3764
RunE: func(cmd *cobra.Command, args []string) error {
3865
return downloader.Download(context.Background(), &flags)

docs/generated/lane_translations.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Download translations from google sheets and/or generate translations from local
1515
### SEE ALSO
1616

1717
* [lane](lane.md) - Automates common tasks
18-
* [lane translations download](lane_translations_download.md) - Download translations
18+
* [lane translations download](lane_translations_download.md) - Download google sheets
1919
* [lane translations generate](lane_translations_generate.md) - Generate translations files from a csv file
20+
* [lane translations list](lane_translations_list.md) - List google sheets
2021

docs/generated/lane_translations_download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## lane translations download
22

3-
Download translations
3+
Download google sheets
44

55
### Synopsis
66

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## lane translations list
2+
3+
List google sheets
4+
5+
### Synopsis
6+
7+
Authentication is done using a json file issued by Google. You get this json file by creating a "Service Account Key", which if you do not have a service account, requires you to first create a service account.
8+
9+
Creating both an account and a key is explaining here: https://developers.google.com/identity/protocols/oauth2/service-account#creatinganaccount
10+
11+
You may have to enable Google Drive API access when using it for the first time. The error message(s) should provide a direct link to enabling access.
12+
13+
Make sure to share the sheet with the 'client_email' assigned to your service account.
14+
15+
16+
```
17+
lane translations list [flags]
18+
```
19+
20+
### Examples
21+
22+
```
23+
lane translations list -c google-api.json
24+
```
25+
26+
### Options
27+
28+
```
29+
-c, --credentials string A path to the credentials json file issued by Google (Required).
30+
-h, --help help for list
31+
```
32+
33+
### SEE ALSO
34+
35+
* [lane translations](lane_translations.md) - Manage translations
36+

0 commit comments

Comments
 (0)