Skip to content

Commit

Permalink
0.10.0 dev (#15)
Browse files Browse the repository at this point in the history
* rename variable

* only set mimeType to folder if empty

* update deps

* add setting for MaxElapsedTime

* remove old entries

* update deps

* update ci

* update version

* switch to universal binaries for mac

* update deps

* add commands to get the current default scopes and reset to current scopes to the defaults
  • Loading branch information
hanneshayashi committed Jun 25, 2023
1 parent c672f6b commit 7db1755
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 118 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3.5.3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4.0.1
with:
go-version: 1.20.3
go-version: 1.20.5
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5.1.0
uses: crazy-max/ghaction-import-gpg@v5.3.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v4.3.0
with:
version: latest
args: release --rm-dist
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ gsm.log
.vscode/settings.json
*.csv
*.ps1
gsmchat/
cmd/chat*
18 changes: 6 additions & 12 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ builds:
- arm64
archives:
- format: tar.gz
name_template: "{{ .ProjectName }}-{{ .Version }}_{{ .Os }}-{{ .Arch }}"
replacements:
darwin: mac
windows: win
name_template: '{{ .ProjectName }}-{{ .Version }}_{{- if eq .Os "windows" }}win{{- else }}{{ .Os }}{{ end }}-{{ .Arch }}'
format_overrides:
- goos: windows
format: zip
Expand All @@ -39,20 +36,17 @@ release:
draft: true
changelog:
skip: true

announce:
skip: true
universal_binaries:
- name_template: "{{ .ProjectName }}"
replace: true
nfpms:
# note that this is an array of nfpm configs
- # You can change the file name of the package.
# Default: `{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}`
file_name_template: "{{ .ProjectName }}-{{ .Version }}_{{ .Os }}-{{ .Arch }}"

# Replacements for GOOS and GOARCH in the package name.
# Keys should be valid GOOSs or GOARCHs.
# Values are the respective replacements.
# Default is empty.
replacements:
darwin: mac

# Template to your app's homepage.
# Default is empty.
homepage: https://gsm.hayashi-ke.online/
Expand Down
49 changes: 49 additions & 0 deletions cmd/configs_getdefaultscopes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright © 2020-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package cmd

import (
"fmt"
"strings"

"github.com/hanneshayashi/gsm/gsmconfig"
"github.com/hanneshayashi/gsm/gsmhelpers"

"github.com/spf13/cobra"
)

// configsGetDefaultScopesCmd represents the getDefaultScopes command
var configsGetDefaultScopesCmd = &cobra.Command{
Use: "getDefaultScopes",
Short: "Returns the default scopes.",
Long: `The default scopes may change with every GSM version as new APIs are added.
Use this command to see the current defaults.
Use "gsm configs resetScopes" to set the current default.`,
Annotations: map[string]string{
"crescendoOutput": "$args[0]",
},
DisableAutoGenTag: true,
Run: func(_ *cobra.Command, _ []string) {
result := gsmconfig.GetDefaultScopes()
fmt.Println(strings.Join(result, ","))
},
}

func init() {
gsmhelpers.InitCommand(configsCmd, configsGetDefaultScopesCmd, configFlags)
}
58 changes: 58 additions & 0 deletions cmd/configs_resetscopes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright © 2020-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package cmd

import (
"fmt"
"log"
"strings"

"github.com/hanneshayashi/gsm/gsmconfig"
"github.com/hanneshayashi/gsm/gsmhelpers"

"github.com/spf13/cobra"
)

// configsResetScopesCmd represents the resetScopes command
var configsResetScopesCmd = &cobra.Command{
Use: "resetScopes",
Short: "Resets the scopes of a config back to the defaults.",
Long: fmt.Sprintf(`Sets the the scopes of the specified config or the default config if not specified back to the defaults:
%s`, strings.Join(gsmconfig.GetDefaultScopes(), ",\n")),
Annotations: map[string]string{
"crescendoOutput": "$args[0]",
},
DisableAutoGenTag: true,
Run: func(_ *cobra.Command, _ []string) {
result, err := gsmconfig.UpdateConfig(&gsmconfig.GSMConfig{
Scopes: gsmconfig.GetDefaultScopes(),
}, cfgFile)
if err != nil {
fmt.Printf("Error resetting scopes: %v\n", err)
return
}
err = gsmhelpers.Output(result, "yaml", false)
if err != nil {
log.Fatalln(err)
}
},
}

func init() {
gsmhelpers.InitCommand(configsCmd, configsResetScopesCmd, configFlags)
}
2 changes: 1 addition & 1 deletion cmd/configs_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var configsUpdateCmd = &cobra.Command{
}
result, err := gsmconfig.UpdateConfig(c, cfgFile)
if err != nil {
fmt.Printf("Error creating config: %v\n", err)
fmt.Printf("Error updating config: %v\n", err)
return
}
err = gsmhelpers.Output(result, "yaml", false)
Expand Down
6 changes: 4 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var (
home string
standardDelay int
maxInterval int
maxElapsedTime int
redirectPort int
compressOutput bool
streamOutput bool
Expand Down Expand Up @@ -140,7 +141,7 @@ For documentation see https://gsm.hayashi-ke.online.`,
log.Fatalln(err)
}
},
Version: "v0.9.0",
Version: "v0.10.0",
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand All @@ -162,6 +163,7 @@ func init() {
rootCmd.PersistentFlags().BoolVar(&streamOutput, "streamOutput", false, `Setting this flag will cause GSM to output slice values to stdout one by one, instead of one large object`)
rootCmd.PersistentFlags().IntVar(&standardDelay, "delay", 0, "This delay (plus a random jitter between 0 and 50) will be applied after every command to avoid reaching quota and rate limits. Set to 0 to disable.")
rootCmd.PersistentFlags().IntVar(&maxInterval, "maxRetryInterval", 320, "This is the maximum interval that will be used between retry attempts in seconds.")
rootCmd.PersistentFlags().IntVar(&maxElapsedTime, "maxElapsedTime", 15, "This is the maximum total time that will be spent retrying a request in minutes.")
rootCmd.PersistentFlags().IntVar(&redirectPort, "redirectPort", 8081, "This is the TCP port on which GSM will create web server if you authenticate with a user account for the first time. This is necessary for the OAuth flow. See https://developers.google.com/identity/protocols/oauth2/native-app#redirect-uri_loopback")
rootCmd.PersistentFlags().StringVar(&logFile, "log", "", "Set the path of the log file. Default is either ~/gsm.log or defined in your config file")
rootCmd.PersistentFlags().IntSliceVar(&gsmhelpers.RetryOn, "retryOn", nil, "Specify the HTTP error code(s) that GSM should retry on. Note that GSM will always retry on HTTP 403 errors that indicate a quota / rate limit error")
Expand Down Expand Up @@ -198,7 +200,7 @@ func initConfig() {
} else {
standardDelay = viper.GetInt("standardDelay")
}
gsmhelpers.SetStandardRetrier(time.Duration(standardDelay)*time.Millisecond, time.Duration(maxInterval)*time.Second)
gsmhelpers.SetStandardRetrier(time.Duration(standardDelay)*time.Millisecond, time.Duration(maxInterval)*time.Second, time.Duration(maxElapsedTime)*time.Minute)
if streamOutput {
compressOutput = true
}
Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ require (
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.15.0
golang.org/x/net v0.9.0
golang.org/x/oauth2 v0.7.0
google.golang.org/api v0.120.0
github.com/spf13/viper v1.16.0
golang.org/x/net v0.11.0
golang.org/x/oauth2 v0.9.0
google.golang.org/api v0.128.0
gopkg.in/yaml.v3 v3.0.1
)

require (
cloud.google.com/go/compute v1.19.1 // indirect
cloud.google.com/go/compute v1.20.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/s2a-go v0.1.3 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.8.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.56.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
Loading

0 comments on commit 7db1755

Please sign in to comment.