feat(cmd/influx): add flags for notification rule auth

pull/14450/head
Kelvin Wang 2019-07-25 11:05:05 -04:00
parent 149cbcf0e6
commit a6a7d3471d
1 changed files with 22 additions and 0 deletions

View File

@ -44,6 +44,9 @@ type AuthorizationCreateFlags struct {
writeDashboardsPermission bool
readDashboardsPermission bool
writeNotificationRulePermission bool
readNotificationRulePermission bool
}
var authorizationCreateFlags AuthorizationCreateFlags
@ -81,6 +84,9 @@ func init() {
authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.writeDashboardsPermission, "write-dashboards", "", false, "Grants the permission to create dashboards")
authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.readDashboardsPermission, "read-dashboards", "", false, "Grants the permission to read dashboards")
authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.writeNotificationRulePermission, "write-notificationRules", "", false, "Grants the permission to create notificationRules")
authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.readNotificationRulePermission, "read-notificationRules", "", false, "Grants the permission to read notificationRules")
authorizationCmd.AddCommand(authorizationCreateCmd)
}
@ -221,6 +227,22 @@ func authorizationCreateF(cmd *cobra.Command, args []string) error {
permissions = append(permissions, *p)
}
if authorizationCreateFlags.writeNotificationRulePermission {
p, err := platform.NewPermission(platform.WriteAction, platform.NotificationRuleResourceType, o.ID)
if err != nil {
return err
}
permissions = append(permissions, *p)
}
if authorizationCreateFlags.readNotificationRulePermission {
p, err := platform.NewPermission(platform.ReadAction, platform.NotificationRuleResourceType, o.ID)
if err != nil {
return err
}
permissions = append(permissions, *p)
}
authorization := &platform.Authorization{
Permissions: permissions,
OrgID: o.ID,