-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add skip-welcome-email and skip-invite options to bulk import user cmd
- Loading branch information
1 parent
f7e775b
commit a661947
Showing
2 changed files
with
15 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kind: Feature | ||
body: add skip-welcome-email and skip-invite options to bulk import user cmd | ||
time: 2024-09-30T15:03:05.541886-05:00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,7 @@ var importUsersCmd = &cobra.Command{ | |
Long: `Imports a list of users from a CSV file with the column headers: | ||
Name,Email,Role,Team`, | ||
Example: ` | ||
cat << EOF | opslevel import user -f - | ||
cat << EOF | opslevel import user --skip-send-invite --skip-welcome-email -f - | ||
Name,Email,Role,Team | ||
Kyle Rockman,[email protected],Admin,platform | ||
Edgar Ochoa,[email protected],Admin,platform | ||
|
@@ -175,6 +175,11 @@ EOF | |
Run: func(cmd *cobra.Command, args []string) { | ||
reader, err := readImportFilepathAsCSV() | ||
cobra.CheckErr(err) | ||
skipSendInvite, err := cmd.Flags().GetBool("skip-send-invite") | ||
cobra.CheckErr(err) | ||
skipWelcomeEmail, err := cmd.Flags().GetBool("skip-welcome-email") | ||
cobra.CheckErr(err) | ||
|
||
for reader.Rows() { | ||
name := reader.Text("Name") | ||
email := reader.Text("Email") | ||
|
@@ -188,10 +193,11 @@ EOF | |
userRole = opslevel.UserRole(role) | ||
} | ||
input := opslevel.UserInput{ | ||
Name: opslevel.RefOf(name), | ||
Role: opslevel.RefOf(userRole), | ||
Name: opslevel.RefOf(name), | ||
Role: opslevel.RefOf(userRole), | ||
SkipWelcomeEmail: opslevel.RefOf(skipWelcomeEmail), | ||
} | ||
user, err := getClientGQL().InviteUser(email, input, false) | ||
user, err := getClientGQL().InviteUser(email, input, !skipSendInvite) | ||
if err != nil { | ||
log.Error().Err(err).Msgf("error inviting user '%s' with email '%s'", name, email) | ||
continue | ||
|
@@ -223,6 +229,8 @@ EOF | |
func init() { | ||
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") | ||
importUsersCmd.Flags().Bool("skip-send-invite", false, "If this flag is set the welcome e-mail will be not be sent") | ||
importUsersCmd.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) | ||
|