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

Feature: add all supported notifications #268

Merged
merged 2 commits into from
Apr 4, 2023
Merged
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
14 changes: 10 additions & 4 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ var addCmd = &cobra.Command{
},
}

var addNotificationCmd = &cobra.Command{
Use: "notification",
Aliases: []string{"n"},
Short: "Add notifications or add notifications to projects",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
validateToken(lagoonCLIConfig.Current) // get a new token if the current one is invalid
},
}

func init() {
addCmd.AddCommand(addDeployTargetCmd)
addCmd.AddCommand(addGroupCmd)
addCmd.AddCommand(addProjectCmd)
addCmd.AddCommand(addProjectToGroupCmd)
addCmd.AddCommand(addProjectRocketChatNotificationCmd)
addCmd.AddCommand(addProjectSlackNotificationCmd)
addCmd.AddCommand(addRocketChatNotificationCmd)
addCmd.AddCommand(addSlackNotificationCmd)
addCmd.AddCommand(addNotificationCmd)
addCmd.AddCommand(addUserCmd)
addCmd.AddCommand(addUserToGroupCmd)
addCmd.AddCommand(addUserSSHKeyCmd)
Expand Down
14 changes: 10 additions & 4 deletions cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ var deleteCmd = &cobra.Command{
},
}

var deleteNotificationCmd = &cobra.Command{
Use: "notification",
Aliases: []string{"n"},
Short: "Delete notifications or delete notifications from projects",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
validateToken(lagoonCLIConfig.Current) // get a new token if the current one is invalid
},
}

func init() {
deleteCmd.AddCommand(deleteEnvCmd)
deleteCmd.AddCommand(deleteGroupCmd)
deleteCmd.AddCommand(deleteDeployTargetCmd)
deleteCmd.AddCommand(deleteProjectCmd)
deleteCmd.AddCommand(deleteProjectFromGroupCmd)
deleteCmd.AddCommand(deleteProjectRocketChatNotificationCmd)
deleteCmd.AddCommand(deleteProjectSlackNotificationCmd)
deleteCmd.AddCommand(deleteRocketChatNotificationCmd)
deleteCmd.AddCommand(deleteSlackNotificationCmd)
deleteCmd.AddCommand(deleteNotificationCmd)
deleteCmd.AddCommand(deleteUserCmd)
deleteCmd.AddCommand(deleteSSHKeyCmd)
deleteCmd.AddCommand(deleteUserFromGroupCmd)
Expand Down
12 changes: 10 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,23 @@ var listInvokableTasks = &cobra.Command{
},
}

var listNotificationCmd = &cobra.Command{
Use: "notification",
Aliases: []string{"n"},
Short: "List all notifications or notifications on projects",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
validateToken(lagoonCLIConfig.Current) // get a new token if the current one is invalid
},
}

func init() {
listCmd.AddCommand(listDeployTargetsCmd)
listCmd.AddCommand(listDeploymentsCmd)
listCmd.AddCommand(listGroupsCmd)
listCmd.AddCommand(listGroupProjectsCmd)
listCmd.AddCommand(listProjectCmd)
listCmd.AddCommand(listProjectsCmd)
listCmd.AddCommand(listRocketChatsCmd)
listCmd.AddCommand(listSlackCmd)
listCmd.AddCommand(listNotificationCmd)
listCmd.AddCommand(listTasksCmd)
listCmd.AddCommand(listUsersCmd)
listCmd.AddCommand(listVariablesCmd)
Expand Down
44 changes: 44 additions & 0 deletions cmd/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,47 @@ func parseNotificationFlags(flags pflag.FlagSet) NotificationFlags {
json.Unmarshal(jsonStr, &parsedFlags)
return parsedFlags
}

func init() {
addNotificationCmd.AddCommand(addProjectNotificationRocketChatCmd)
addNotificationCmd.AddCommand(addProjectNotificationSlackCmd)
addNotificationCmd.AddCommand(addProjectNotificationEmailCmd)
addNotificationCmd.AddCommand(addProjectNotificationMicrosoftTeamsCmd)
addNotificationCmd.AddCommand(addProjectNotificationWebhookCmd)

addNotificationCmd.AddCommand(addNotificationRocketchatCmd)
addNotificationCmd.AddCommand(addNotificationSlackCmd)
addNotificationCmd.AddCommand(addNotificationEmailCmd)
addNotificationCmd.AddCommand(addNotificationMicrosoftTeamsCmd)
addNotificationCmd.AddCommand(addNotificationWebhookCmd)

listNotificationCmd.AddCommand(listProjectSlacksCmd)
listNotificationCmd.AddCommand(listProjectRocketChatsCmd)
listNotificationCmd.AddCommand(listProjectEmailsCmd)
listNotificationCmd.AddCommand(listProjectMicrosoftTeamsCmd)
listNotificationCmd.AddCommand(listProjectWebhooksCmd)

listNotificationCmd.AddCommand(listAllSlacksCmd)
listNotificationCmd.AddCommand(listAllRocketChatsCmd)
listNotificationCmd.AddCommand(listAllEmailsCmd)
listNotificationCmd.AddCommand(listAllMicrosoftTeamsCmd)
listNotificationCmd.AddCommand(listAllWebhooksCmd)

deleteNotificationCmd.AddCommand(deleteProjectRocketChatNotificationCmd)
deleteNotificationCmd.AddCommand(deleteProjectSlackNotificationCmd)
deleteNotificationCmd.AddCommand(deleteProjectEmailNotificationCmd)
deleteNotificationCmd.AddCommand(deleteProjectMicrosoftTeamsNotificationCmd)
deleteNotificationCmd.AddCommand(deleteProjectWebhookNotificationCmd)

deleteNotificationCmd.AddCommand(deleteRocketChatNotificationCmd)
deleteNotificationCmd.AddCommand(deleteSlackNotificationCmd)
deleteNotificationCmd.AddCommand(deleteEmailNotificationCmd)
deleteNotificationCmd.AddCommand(deleteMicrosoftTeamsNotificationCmd)
deleteNotificationCmd.AddCommand(deleteWebhookNotificationCmd)

updateNotificationCmd.AddCommand(updateRocketChatNotificationCmd)
updateNotificationCmd.AddCommand(updateSlackNotificationCmd)
updateNotificationCmd.AddCommand(updateEmailNotificationCmd)
updateNotificationCmd.AddCommand(updateMicrosoftTeamsNotificationCmd)
updateNotificationCmd.AddCommand(updateWebhookNotificationCmd)
}
Loading