From 5553981b4dcc63d50eb262b83765406483569a52 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Thu, 5 Sep 2024 15:13:05 -0500 Subject: [PATCH 1/6] add --force-send-invite flag to user create cmd --- .changes/unreleased/Feature-20240905-151037.yaml | 3 +++ src/cmd/user.go | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .changes/unreleased/Feature-20240905-151037.yaml diff --git a/.changes/unreleased/Feature-20240905-151037.yaml b/.changes/unreleased/Feature-20240905-151037.yaml new file mode 100644 index 00000000..404381ae --- /dev/null +++ b/.changes/unreleased/Feature-20240905-151037.yaml @@ -0,0 +1,3 @@ +kind: Feature +body: new "--force-send-invite" flag for "user create" cmd sends invite emails when account notifications are disabled +time: 2024-09-05T15:10:37.336716-05:00 diff --git a/src/cmd/user.go b/src/cmd/user.go index 452135d6..ab1c9288 100644 --- a/src/cmd/user.go +++ b/src/cmd/user.go @@ -31,8 +31,10 @@ var createUserCmd = &cobra.Command{ Example: ` opslevel create user "john@example.com" "John Doe" opslevel create user "jane@example.com" "Jane Doe" Admin --skip-welcome-email +opslevel create user "jane@example.com" "Jane Doe" Admin --force-send-invite +opslevel create user "jane@example.com" "Jane Doe" Admin --force-send-invite --skip-welcome-email `, - Args: cobra.MinimumNArgs(2), + Args: cobra.RangeArgs(2, 4), Run: func(cmd *cobra.Command, args []string) { email := args[0] name := args[1] @@ -44,14 +46,17 @@ opslevel create user "jane@example.com" "Jane Doe" Admin --skip-welcome-email } } + forceSendInvite, err := cmd.Flags().GetBool("force-send-invite") + cobra.CheckErr(err) skipEmail, err := cmd.Flags().GetBool("skip-welcome-email") cobra.CheckErr(err) - resource, err := getClientGQL().InviteUser(email, opslevel.UserInput{ + userInput := opslevel.UserInput{ Name: opslevel.RefOf(name), Role: opslevel.RefOf(role), SkipWelcomeEmail: opslevel.RefOf(skipEmail), - }) + } + resource, err := getClientGQL().InviteUser(email, userInput, opslevel.RefOf(forceSendInvite)) cobra.CheckErr(err) fmt.Println(resource.Id) }, @@ -186,7 +191,7 @@ EOF Name: opslevel.RefOf(name), Role: opslevel.RefOf(userRole), } - user, err := getClientGQL().InviteUser(email, input) + user, err := getClientGQL().InviteUser(email, input, opslevel.RefOf(false)) if err != nil { log.Error().Err(err).Msgf("error inviting user '%s' with email '%s'", name, email) continue @@ -216,7 +221,8 @@ EOF } func init() { - createUserCmd.Flags().Bool("skip-welcome-email", false, "If this flag is set the welcome e-mail will be skipped from being sent") + createUserCmd.Flags().Bool("force-send-invite", false, "If this flag is set the welcome e-mail will be skipped from being sent") + createUserCmd.Flags().Bool("skip-welcome-email", false, "If this flag is set send an invite email even if notifications are disabled for the account") listUserCmd.Flags().Bool("ignore-deactivated", false, "If this flag is set only return active users") exampleCmd.AddCommand(exampleUserCmd) From 1c93fdfaad2bfaf4d93fe82bb71512e19daaa8af Mon Sep 17 00:00:00 2001 From: David Bloss Date: Wed, 18 Sep 2024 08:46:32 -0500 Subject: [PATCH 2/6] bump opslevel-go version to v2024.9.18 (#332) --- .../unreleased/Dependency-20240918-084053.yaml | 3 +++ src/go.mod | 14 +++++++------- src/go.sum | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 .changes/unreleased/Dependency-20240918-084053.yaml diff --git a/.changes/unreleased/Dependency-20240918-084053.yaml b/.changes/unreleased/Dependency-20240918-084053.yaml new file mode 100644 index 00000000..5e6f1b6e --- /dev/null +++ b/.changes/unreleased/Dependency-20240918-084053.yaml @@ -0,0 +1,3 @@ +kind: Dependency +body: bump opslevel-go version to v2024.9.18 +time: 2024-09-18T08:40:53.120335-05:00 diff --git a/src/go.mod b/src/go.mod index 3c92a25c..558aff0c 100644 --- a/src/go.mod +++ b/src/go.mod @@ -5,13 +5,13 @@ go 1.22 require ( github.com/creasty/defaults v1.8.0 github.com/go-git/go-git/v5 v5.12.0 - github.com/go-resty/resty/v2 v2.14.0 + github.com/go-resty/resty/v2 v2.15.0 github.com/gosimple/slug v1.14.0 github.com/itchyny/gojq v0.12.16 github.com/manifoldco/promptui v0.9.0 github.com/mitchellh/mapstructure v1.5.0 github.com/open-policy-agent/opa v0.67.1 - github.com/opslevel/opslevel-go/v2024 v2024.9.3 + github.com/opslevel/opslevel-go/v2024 v2024.9.18 github.com/relvacode/iso8601 v1.4.0 github.com/rocktavious/autopilot v0.1.5 github.com/rs/zerolog v1.33.0 @@ -44,7 +44,7 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.22.0 // indirect + github.com/go-playground/validator/v10 v10.22.1 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/uuid v1.6.0 // indirect @@ -91,10 +91,10 @@ require ( go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.26.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/src/go.sum b/src/go.sum index f7751090..4f427fe0 100644 --- a/src/go.sum +++ b/src/go.sum @@ -105,8 +105,12 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao= github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= +github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-resty/resty/v2 v2.14.0 h1:/rhkzsAqGQkozwfKS5aFAbb6TyKd3zyFRWcdRXLPCAU= github.com/go-resty/resty/v2 v2.14.0/go.mod h1:IW6mekUOsElt9C7oWr0XRt9BNSD6D5rr9mhk6NjmNHg= +github.com/go-resty/resty/v2 v2.15.0 h1:clPQLZ2x9h4yGY81IzpMPnty+xoGyFaDg0XMkCsHf90= +github.com/go-resty/resty/v2 v2.15.0/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -196,6 +200,8 @@ github.com/opslevel/moredefaults v0.0.0-20240529152742-17d1318a3c12 h1:OQZ3W8kby github.com/opslevel/moredefaults v0.0.0-20240529152742-17d1318a3c12/go.mod h1:g2GSXVP6LO+5+AIsnMRPN+BeV86OXuFRTX7HXCDtYeI= github.com/opslevel/opslevel-go/v2024 v2024.9.3 h1:r+OpGwtZlAtImSV8aLINu0fFZYl/o6eDmcqFJUx1p0w= github.com/opslevel/opslevel-go/v2024 v2024.9.3/go.mod h1:u1IIoWb2zUpbjoX9mxwXHqlj8vLHS3+96z7pyUd3fs4= +github.com/opslevel/opslevel-go/v2024 v2024.9.18 h1:fb2fDPU6VZ6it39z6FDz34uQEJ8e42XLQUkQtfzECkk= +github.com/opslevel/opslevel-go/v2024 v2024.9.18/go.mod h1:u1IIoWb2zUpbjoX9mxwXHqlj8vLHS3+96z7pyUd3fs4= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= @@ -308,6 +314,8 @@ golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -331,6 +339,8 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -362,6 +372,8 @@ golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -389,6 +401,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 6fe7457745b036844fd43788b74a0274f643ed20 Mon Sep 17 00:00:00 2001 From: OpsLevel Bots Date: Wed, 18 Sep 2024 13:47:50 +0000 Subject: [PATCH 3/6] Cut Release 'v2024.9.18' --- .changes/unreleased/Dependency-20240918-084053.yaml | 3 --- .changes/v2024.9.18.md | 6 ++++++ CHANGELOG.md | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) delete mode 100644 .changes/unreleased/Dependency-20240918-084053.yaml create mode 100644 .changes/v2024.9.18.md diff --git a/.changes/unreleased/Dependency-20240918-084053.yaml b/.changes/unreleased/Dependency-20240918-084053.yaml deleted file mode 100644 index 5e6f1b6e..00000000 --- a/.changes/unreleased/Dependency-20240918-084053.yaml +++ /dev/null @@ -1,3 +0,0 @@ -kind: Dependency -body: bump opslevel-go version to v2024.9.18 -time: 2024-09-18T08:40:53.120335-05:00 diff --git a/.changes/v2024.9.18.md b/.changes/v2024.9.18.md new file mode 100644 index 00000000..92de9a7b --- /dev/null +++ b/.changes/v2024.9.18.md @@ -0,0 +1,6 @@ +## [September 18, 2024](https://github.com/OpsLevel/cli/compare/v2024.9.3...v2024.9.18) +### Dependency +- bump opslevel-go version to v2024.9.18 +## Docker Image + + - `docker pull public.ecr.aws/opslevel/cli:v2024.9.18` diff --git a/CHANGELOG.md b/CHANGELOG.md index 28693107..6f8ab810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and is generated by [Changie](https://github.com/miniscruff/changie). +## [September 18, 2024](https://github.com/OpsLevel/cli/compare/v2024.9.3...v2024.9.18) +### Dependency +- bump opslevel-go version to v2024.9.18 +## Docker Image + + - `docker pull public.ecr.aws/opslevel/cli:v2024.9.18` ## [September 03, 2024](https://github.com/OpsLevel/cli/compare/v2024.8.19...v2024.9.3) ### Bugfix - graphql cmd correctly handles errors with field args From 7cfce79ddb1e1063bc3819076b29677004c8cfee Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 19 Sep 2024 12:00:05 -0500 Subject: [PATCH 4/6] Update go.mod --- src/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/go.mod b/src/go.mod index 558aff0c..330a56e3 100644 --- a/src/go.mod +++ b/src/go.mod @@ -1,6 +1,6 @@ module github.com/opslevel/cli -go 1.22 +go 1.23 require ( github.com/creasty/defaults v1.8.0 From 99c56b5a0d0aad79b8d3d5a7c1b834f38459ab32 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Mon, 30 Sep 2024 11:46:18 -0500 Subject: [PATCH 5/6] support adding users with option to skip sending invite email --- .changes/unreleased/Feature-20240930-114506.yaml | 3 +++ src/cmd/user.go | 12 ++++++------ src/submodules/opslevel-go | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 .changes/unreleased/Feature-20240930-114506.yaml diff --git a/.changes/unreleased/Feature-20240930-114506.yaml b/.changes/unreleased/Feature-20240930-114506.yaml new file mode 100644 index 00000000..a761b200 --- /dev/null +++ b/.changes/unreleased/Feature-20240930-114506.yaml @@ -0,0 +1,3 @@ +kind: Feature +body: added --skip-send-invite flag to "create user" cmd +time: 2024-09-30T11:45:06.210542-05:00 diff --git a/src/cmd/user.go b/src/cmd/user.go index ab1c9288..428d6cdf 100644 --- a/src/cmd/user.go +++ b/src/cmd/user.go @@ -30,9 +30,9 @@ var createUserCmd = &cobra.Command{ Long: "Create a User and optionally define the role (options `User`|`Admin`).", Example: ` opslevel create user "john@example.com" "John Doe" +opslevel create user "jane@example.com" "Jane Doe" Admin --skip-send-invite opslevel create user "jane@example.com" "Jane Doe" Admin --skip-welcome-email -opslevel create user "jane@example.com" "Jane Doe" Admin --force-send-invite -opslevel create user "jane@example.com" "Jane Doe" Admin --force-send-invite --skip-welcome-email +opslevel create user "jane@example.com" "Jane Doe" Admin --skip-send-invite --skip-welcome-email `, Args: cobra.RangeArgs(2, 4), Run: func(cmd *cobra.Command, args []string) { @@ -46,7 +46,7 @@ opslevel create user "jane@example.com" "Jane Doe" Admin --force-send-invite --s } } - forceSendInvite, err := cmd.Flags().GetBool("force-send-invite") + sendInvite, err := cmd.Flags().GetBool("skip-send-invite") cobra.CheckErr(err) skipEmail, err := cmd.Flags().GetBool("skip-welcome-email") cobra.CheckErr(err) @@ -56,7 +56,7 @@ opslevel create user "jane@example.com" "Jane Doe" Admin --force-send-invite --s Role: opslevel.RefOf(role), SkipWelcomeEmail: opslevel.RefOf(skipEmail), } - resource, err := getClientGQL().InviteUser(email, userInput, opslevel.RefOf(forceSendInvite)) + resource, err := getClientGQL().InviteUser(email, userInput, sendInvite) cobra.CheckErr(err) fmt.Println(resource.Id) }, @@ -191,7 +191,7 @@ EOF Name: opslevel.RefOf(name), Role: opslevel.RefOf(userRole), } - user, err := getClientGQL().InviteUser(email, input, opslevel.RefOf(false)) + user, err := getClientGQL().InviteUser(email, input, false) if err != nil { log.Error().Err(err).Msgf("error inviting user '%s' with email '%s'", name, email) continue @@ -221,7 +221,7 @@ EOF } func init() { - createUserCmd.Flags().Bool("force-send-invite", false, "If this flag is set the welcome e-mail will be skipped from being sent") + createUserCmd.Flags().Bool("skip-send-invite", false, "If this flag is set the welcome e-mail will be not be sent") createUserCmd.Flags().Bool("skip-welcome-email", false, "If this flag is set send an invite email even if notifications are disabled for the account") listUserCmd.Flags().Bool("ignore-deactivated", false, "If this flag is set only return active users") diff --git a/src/submodules/opslevel-go b/src/submodules/opslevel-go index f1283d61..a05d27a2 160000 --- a/src/submodules/opslevel-go +++ b/src/submodules/opslevel-go @@ -1 +1 @@ -Subproject commit f1283d6150ec3c85b7d00c7a8576bacb1c365f49 +Subproject commit a05d27a21d24d397ae28789b9b05a384bfa1f821 From 82f52b58cff793312a8f96cfc59425acd0cb79e3 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Mon, 30 Sep 2024 11:47:25 -0500 Subject: [PATCH 6/6] minor Taskfile message update --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 0754339d..4ff35cbd 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -93,7 +93,7 @@ tasks: echo "Using latest version of opslevel-go - {{.LATEST_OPSLEVEL_GO_VERSION}}"; else echo "WARNING: current version of opslevel-go is behind '{{.LATEST_OPSLEVEL_GO_VERSION}}'" - echo "Run 'task lintfix' to get latest version" + echo "Run 'task fix' to get latest version" exit 1 fi