feat(cmd/influx): add flags for notification rule auth
parent
149cbcf0e6
commit
a6a7d3471d
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue