Skip to content

Commit

Permalink
Feature: add all supported notifications (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon authored Apr 4, 2023
1 parent 61b1984 commit c631e39
Show file tree
Hide file tree
Showing 96 changed files with 5,378 additions and 1,277 deletions.
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

0 comments on commit c631e39

Please sign in to comment.