diff --git a/go.mod b/go.mod index ef2f684d..d0adebc7 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/pkg/errors v0.9.1 - github.com/planetscale/planetscale-go v0.92.0 + github.com/planetscale/planetscale-go v0.93.0 github.com/planetscale/sql-proxy v0.13.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 @@ -30,7 +30,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/xelabs/go-mysqlstack v1.0.0 go.uber.org/zap v1.26.0 - golang.org/x/oauth2 v0.13.0 + golang.org/x/oauth2 v0.14.0 golang.org/x/sync v0.5.0 golang.org/x/sys v0.14.0 golang.org/x/text v0.14.0 diff --git a/go.sum b/go.sum index e6cba076..f76466c6 100644 --- a/go.sum +++ b/go.sum @@ -232,8 +232,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/planetscale/planetscale-go v0.51.0/go.mod h1:+rGpW2u7iQZZx4O/nFj4MZe4xIS22CVegEgl1IkTExQ= -github.com/planetscale/planetscale-go v0.92.0 h1:ifrZCSifooYuM2bG4v+RH34H2MeHQg5m+lu65EtZ9Bw= -github.com/planetscale/planetscale-go v0.92.0/go.mod h1:fZZ8IJEB1IMrQCt3eo7D4E+hx5zt8mM3z8/aL/p1fiA= +github.com/planetscale/planetscale-go v0.93.0 h1:cogKCS4pEbHqurZWiPROaEAo16ZEPmRTSdd2IZioa8A= +github.com/planetscale/planetscale-go v0.93.0/go.mod h1:MR+LZLhZTIzmi2x91nwLQyIedMFhn6sgQDAKs0wAGNQ= github.com/planetscale/sql-proxy v0.13.0 h1:NDjcdqgoNzwbZQTyoIDEoI+K7keC5RRKvdML2roAMn4= github.com/planetscale/sql-proxy v0.13.0/go.mod h1:4Sk6JdoBqQhHv9V4FCOC27YIM3EjU8cLIsw5HqxN8x4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -392,8 +392,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= +golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/internal/cmd/password/create.go b/internal/cmd/password/create.go index 75f6c14f..321f8fb9 100644 --- a/internal/cmd/password/create.go +++ b/internal/cmd/password/create.go @@ -71,5 +71,6 @@ func CreateCmd(ch *cmdutil.Helper) *cobra.Command { } cmd.PersistentFlags().StringVar(&flags.role, "role", "admin", "Role defines the access level, allowed values are : reader, writer, readwriter, admin. By default it is admin.") + cmd.PersistentFlags().IntVar(&createReq.TTL, "ttl", 0, "TTL defines the time to live for the password in seconds. By default it is 0 which means it will never expire.") return cmd } diff --git a/internal/cmd/password/password.go b/internal/cmd/password/password.go index 19626a01..3d020e03 100644 --- a/internal/cmd/password/password.go +++ b/internal/cmd/password/password.go @@ -39,6 +39,7 @@ type Password struct { Username string `header:"username" json:"username"` Role string `header:"role" json:"role"` RoleDesc string `header:"role description" json:"-"` + TTL int `header:"ttl" json:"ttl"` CreatedAt int64 `json:"created_at"` orig *ps.DatabaseBranchPassword } @@ -52,6 +53,7 @@ type PasswordWithPlainText struct { Role string `header:"role" json:"role"` RoleDesc string `header:"role description" json:"role_description"` PlainText string `header:"password" json:"password"` + TTL int `header:"ttl" json:"ttl"` ConnectionStrings ps.ConnectionStrings `json:"connection_strings"` orig *ps.DatabaseBranchPassword } @@ -87,6 +89,7 @@ func toPassword(password *ps.DatabaseBranchPassword) *Password { Username: password.Username, Role: password.Role, RoleDesc: toRoleDesc(password.Role), + TTL: password.TTL, CreatedAt: password.CreatedAt.UTC().UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond)), orig: password, } @@ -110,6 +113,7 @@ func toPasswordWithPlainText(password *ps.DatabaseBranchPassword) *PasswordWithP AccessHostUrl: password.Branch.AccessHostURL, Role: password.Role, RoleDesc: toRoleDesc(password.Role), + TTL: password.TTL, ConnectionStrings: password.ConnectionStrings, orig: password, }