Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --skip-send-invite flag to user create cmd #329

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changes/unreleased/Feature-20240905-151037.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Feature
body: new "--force-send-invite" flag for "user create" cmd sends invite emails when account notifications are disabled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you called the flag --skip-send-invite

time: 2024-09-05T15:10:37.336716-05:00
3 changes: 3 additions & 0 deletions .changes/unreleased/Feature-20240930-114506.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Feature
body: added --skip-send-invite flag to "create user" cmd
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems duplicative? should we remove this changie?

time: 2024-09-30T11:45:06.210542-05:00
6 changes: 6 additions & 0 deletions .changes/v2024.9.18.md
Original file line number Diff line number Diff line change
@@ -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`
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 11 additions & 5 deletions src/cmd/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ var createUserCmd = &cobra.Command{
Long: "Create a User and optionally define the role (options `User`|`Admin`).",
Example: `
opslevel create user "[email protected]" "John Doe"
opslevel create user "[email protected]" "Jane Doe" Admin --skip-send-invite
opslevel create user "[email protected]" "Jane Doe" Admin --skip-welcome-email
opslevel create user "[email protected]" "Jane Doe" Admin --skip-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]
Expand All @@ -44,14 +46,17 @@ opslevel create user "[email protected]" "Jane Doe" Admin --skip-welcome-email
}
}

sendInvite, err := cmd.Flags().GetBool("skip-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, sendInvite)
cobra.CheckErr(err)
fmt.Println(resource.Id)
},
Expand Down Expand Up @@ -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, false)
if err != nil {
log.Error().Err(err).Msgf("error inviting user '%s' with email '%s'", name, email)
continue
Expand Down Expand Up @@ -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("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")

exampleCmd.AddCommand(exampleUserCmd)
Expand Down
16 changes: 8 additions & 8 deletions src/go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module github.com/opslevel/cli

go 1.22
go 1.23

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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
Loading