From 7bcfc67c1ea09ca55b7c21c0b41c3ecc2a49ee87 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Thu, 7 Nov 2024 20:56:03 -0500 Subject: [PATCH 01/49] created command --- commands/slash/openstack.go | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 commands/slash/openstack.go diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go new file mode 100644 index 0000000..601acbb --- /dev/null +++ b/commands/slash/openstack.go @@ -0,0 +1,75 @@ +package slash + +import ( + "github.com/bwmarrin/discordgo" + "github.com/ritsec/ops-bot-iii/commands/slash/permission" + "github.com/ritsec/ops-bot-iii/helpers" + "github.com/ritsec/ops-bot-iii/logging" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" +) + +func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) { + return &discordgo.ApplicationCommand{ + Name: "openstack self service", + Description: "Create or reset your openstack account", + DefaultMemberPermissions: &permission.Member, + Options: []*discordgo.ApplicationCommandOption{ + { + Type: discordgo.ApplicationCommandOptionString, + Name: "option", + Description: "Option of create or reset", + Required: true, + Choices: []*discordgo.ApplicationCommandOptionChoice{ + { + Name: "Create", + Value: "Create", + }, + { + Name: "Reset", + Value: "Reset", + }, + }, + }, + }, + }, + func(s *discordgo.Session, i *discordgo.InteractionCreate) { + span := tracer.StartSpan( + "commands.slash.openstack:Openstack", + tracer.ResourceName("/openstack"), + ) + defer span.Finish() + + ssOption := i.ApplicationCommandData().Options[0].StringValue() + + // CHECK IF USER IS DM'ABLE + err := helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account password will be sent here!", span.Context()) + if err != nil { + logging.Debug(s, "User's DMs are not open", i.Member.User, span) + err = s.InteractionRespond( + i.Interaction, + &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: "Your DMs are not open! Please open your DMs and run the command again", + Flags: discordgo.MessageFlagsEphemeral, + }, + }, + ) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + } + + // CHECK IF USER EXISTS ON OPENSTACK ALREADY + err, result = helpers.CheckIfExists() + + if ssOption == "Create" { + // CREATE THE ACCOUNT + } else if ssOption == "Reset" { + // RESET THE PASSWORD OF THE ACCOUNT + } else { + // GRACEFULLY CLOSE + logging.Error(s, "User somehow typed a different option for /openstack?", i.Member.User, span) + } + } +} From 6e0890f303a6dafd47c6ca22351d9454a1a90bb2 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Thu, 7 Nov 2024 20:57:01 -0500 Subject: [PATCH 02/49] created command runners --- helpers/openstack.go | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 helpers/openstack.go diff --git a/helpers/openstack.go b/helpers/openstack.go new file mode 100644 index 0000000..6f0aa6b --- /dev/null +++ b/helpers/openstack.go @@ -0,0 +1,68 @@ +package helpers + +import ( + "bytes" + "os/exec" + "strings" +) + +func Create(email string) (error error, username string, password string) { + createCmd := exec.Command("root/automated_new_member.sh", email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + createCmd.Stdout = stdout + createCmd.Stderr = stderr + + err := createCmd.Run() + if err != nil { + return err, "", "" + } + output := strings.Fields(stdout.String()) + + username = output[0] + password = output[1] + + return nil, username, password +} + +func Reset(email string) (error error, username string, password string) { + resetCmd := exec.Command("root/automated_reset_password.sh", email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + resetCmd.Stdout = stdout + resetCmd.Stderr = stderr + + err := resetCmd.Run() + if err != nil { + return err, "", "" + } + output := strings.Fields(stdout.String()) + + username = output[0] + password = output[1] + + return nil, username, password +} + +func CheckIfExists(email string) (error error, result bool) { + resetCmd := exec.Command("root/automated_reset_password.sh", email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + resetCmd.Stdout = stdout + resetCmd.Stderr = stderr + + err := resetCmd.Run() + if err != nil { + return err, false + } + output := stdout.String() + + if output == "1" { + return nil, true + } else { + return nil, false + } +} From bb45fda87e468a76562b2b2f63ccead62476e933 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Thu, 7 Nov 2024 22:45:28 -0500 Subject: [PATCH 03/49] Fixed comments --- data/user.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/user.go b/data/user.go index 3006418..37867ae 100644 --- a/data/user.go +++ b/data/user.go @@ -72,7 +72,7 @@ func (*user_s) SetEmail(id string, email string, ctx ddtrace.SpanContext) (*ent. Save(Ctx) } -// SetEmail sets the email for a user +// IncrementVerificationAttempts increments the verification attempts after user tries to verify func (*user_s) IncrementVerificationAttempts(id string, ctx ddtrace.SpanContext) (*ent.User, error) { span := tracer.StartSpan( "data.user:IncrementVerificationAttempts", @@ -91,7 +91,7 @@ func (*user_s) IncrementVerificationAttempts(id string, ctx ddtrace.SpanContext) Save(Ctx) } -// SetEmail sets the email for a user +// MarkVerified marks the user verified func (*user_s) MarkVerified(id string, ctx ddtrace.SpanContext) (*ent.User, error) { span := tracer.StartSpan( "data.user:MarkVerified", @@ -110,7 +110,7 @@ func (*user_s) MarkVerified(id string, ctx ddtrace.SpanContext) (*ent.User, erro Save(Ctx) } -// SetEmail sets the email for a user +// IsVerified checks to see if the user is verified func (*user_s) IsVerified(id string, ctx ddtrace.SpanContext) bool { span := tracer.StartSpan( "data.user:IsVerified", @@ -127,7 +127,7 @@ func (*user_s) IsVerified(id string, ctx ddtrace.SpanContext) bool { return entUser.Verified } -// SetEmail sets the email for a user +// EmailExists checks to see if the email exists for the user func (*user_s) EmailExists(id string, email string, ctx ddtrace.SpanContext) bool { span := tracer.StartSpan( "data.user:EmailExists", @@ -151,7 +151,7 @@ func (*user_s) EmailExists(id string, email string, ctx ddtrace.SpanContext) boo return exists } -// SetEmail sets the email for a user +// GetVerificationAttempts returns the amount of verification attempts the user has func (*user_s) GetVerificationAttempts(id string, ctx ddtrace.SpanContext) (int, error) { span := tracer.StartSpan( "data.user:GetVerificationAttempts", From 6862b84b1fc5f0e91d0e56cb1c205665b32b8c39 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Thu, 7 Nov 2024 22:48:50 -0500 Subject: [PATCH 04/49] Added GetEmail --- data/user.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/data/user.go b/data/user.go index 37867ae..227b741 100644 --- a/data/user.go +++ b/data/user.go @@ -167,3 +167,19 @@ func (*user_s) GetVerificationAttempts(id string, ctx ddtrace.SpanContext) (int, return int(entUser.VerificationAttempts), nil } + +func (*user_s) GetEmail(id string, ctx ddtrace.SpanContext) (string, error) { + span := tracer.StartSpan( + "data.user:GetEmail", + tracer.ResourceName("Data.User.GetEmail"), + tracer.ChildOf(ctx), + ) + defer span.Finish() + + entUser, err := User.Get(id, span.Context()) + if err != nil { + return "", err + } + + return entUser.Email, nil +} From 225b3ad5617fbae48a2da6b8526a16aee905add5 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 00:14:27 -0500 Subject: [PATCH 05/49] Openstack self-service --- commands/slash/openstack.go | 102 ++++++++++++++++++++++++++++++++++-- helpers/openstack.go | 22 ++++---- 2 files changed, 109 insertions(+), 15 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 601acbb..3571ad3 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -1,8 +1,11 @@ package slash import ( + "fmt" + "github.com/bwmarrin/discordgo" "github.com/ritsec/ops-bot-iii/commands/slash/permission" + "github.com/ritsec/ops-bot-iii/data" "github.com/ritsec/ops-bot-iii/helpers" "github.com/ritsec/ops-bot-iii/logging" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" @@ -42,7 +45,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d ssOption := i.ApplicationCommandData().Options[0].StringValue() // CHECK IF USER IS DM'ABLE - err := helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account password will be sent here!", span.Context()) + err := helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) if err != nil { logging.Debug(s, "User's DMs are not open", i.Member.User, span) err = s.InteractionRespond( @@ -50,7 +53,30 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ - Content: "Your DMs are not open! Please open your DMs and run the command again", + Content: "Your DMs are not open! Please open your DMs and run the command again.", + Flags: discordgo.MessageFlagsEphemeral, + }, + }, + ) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } + + // GET EMAIL AND CHECK IF IT IS VALID + email, err := data.User.GetEmail(i.Member.User.ID, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + if email == "" { + logging.Debug(s, "User has no email", i.Member.User, span) + err = s.InteractionRespond( + i.Interaction, + &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: "You have no verified email. Run /member and verify your email and run this command again.", Flags: discordgo.MessageFlagsEphemeral, }, }, @@ -58,18 +84,86 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } + return } // CHECK IF USER EXISTS ON OPENSTACK ALREADY - err, result = helpers.CheckIfExists() + exists, err := helpers.CheckIfExists(email) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } if ssOption == "Create" { + if exists { + logging.Debug(s, "User already has an openstack account and is trying to create one", i.Member.User, span) + err = s.InteractionRespond( + i.Interaction, + &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: "Openstack account already exisits. Run the reset option if you forgot your password.", + Flags: discordgo.MessageFlagsEphemeral, + }, + }, + ) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } + // CREATE THE ACCOUNT + username, password, err := helpers.Create(email) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + + // SEND THE USERNAME AND PASSWORD TO THE USER VIA DM + message := fmt.Sprintf("Thank you for reaching out to us!\nHere are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) + err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } } else if ssOption == "Reset" { + // CHECK IF USER IS TRYING TO RESET PASSWORD ON NON-EXISTENT ACCOUNT + if !exists { + logging.Debug(s, "User does not have an openstack account and is trying to reset the password on it", i.Member.User, span) + err = s.InteractionRespond( + i.Interaction, + &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: "Openstack account does not exist and you are trying to reset it.", + Flags: discordgo.MessageFlagsEphemeral, + }, + }, + ) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } + // RESET THE PASSWORD OF THE ACCOUNT + username, password, err := helpers.Reset(email) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + + message := fmt.Sprintf("Thank you for reaching out to us!\nHere are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) + err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } } else { // GRACEFULLY CLOSE - logging.Error(s, "User somehow typed a different option for /openstack?", i.Member.User, span) + logging.Error(s, "User somehow got here?", i.Member.User, span) + return } } } diff --git a/helpers/openstack.go b/helpers/openstack.go index 6f0aa6b..e553656 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -6,7 +6,7 @@ import ( "strings" ) -func Create(email string) (error error, username string, password string) { +func Create(email string) (username string, password string, error error) { createCmd := exec.Command("root/automated_new_member.sh", email) stdout := &bytes.Buffer{} @@ -16,17 +16,17 @@ func Create(email string) (error error, username string, password string) { err := createCmd.Run() if err != nil { - return err, "", "" + return "", "", err } output := strings.Fields(stdout.String()) username = output[0] password = output[1] - return nil, username, password + return username, password, nil } -func Reset(email string) (error error, username string, password string) { +func Reset(email string) (username string, password string, error error) { resetCmd := exec.Command("root/automated_reset_password.sh", email) stdout := &bytes.Buffer{} @@ -36,18 +36,18 @@ func Reset(email string) (error error, username string, password string) { err := resetCmd.Run() if err != nil { - return err, "", "" + return "", "", err } output := strings.Fields(stdout.String()) username = output[0] password = output[1] - return nil, username, password + return username, password, nil } -func CheckIfExists(email string) (error error, result bool) { - resetCmd := exec.Command("root/automated_reset_password.sh", email) +func CheckIfExists(email string) (result bool, error error) { + resetCmd := exec.Command("root/automated_check_if_exists.sh", email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -56,13 +56,13 @@ func CheckIfExists(email string) (error error, result bool) { err := resetCmd.Run() if err != nil { - return err, false + return false, err } output := stdout.String() if output == "1" { - return nil, true + return true, nil } else { - return nil, false + return false, nil } } From 29a82fb4fe308c06d905615f1c7010cb65f9415d Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 00:50:54 -0500 Subject: [PATCH 06/49] enabled command --- commands/enabled.go | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/enabled.go b/commands/enabled.go index 54bbeb0..86ef3e3 100644 --- a/commands/enabled.go +++ b/commands/enabled.go @@ -35,6 +35,7 @@ func populateSlashCommands(ctx ddtrace.SpanContext) { SlashCommands["dquery"] = slash.DQuery SlashCommands["attendance"] = slash.Attendance SlashCommands["attendanceof"] = slash.Attendanceof + SlashCommands["openstack"] = slash.Openstack } // populateHandlers populates the Handlers map with all of the handlers From e856e45fc04b2c15f6dfc10d457283e32051d90e Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 00:55:43 -0500 Subject: [PATCH 07/49] changed command name --- commands/slash/openstack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 3571ad3..16e0f60 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -13,7 +13,7 @@ import ( func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) { return &discordgo.ApplicationCommand{ - Name: "openstack self service", + Name: "openstack", Description: "Create or reset your openstack account", DefaultMemberPermissions: &permission.Member, Options: []*discordgo.ApplicationCommandOption{ From 5b441471caf75f2eee9c98d836047f294ff9255c Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 01:01:48 -0500 Subject: [PATCH 08/49] added missing slashes for filepaths --- helpers/openstack.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index e553656..3ebffa7 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -7,7 +7,7 @@ import ( ) func Create(email string) (username string, password string, error error) { - createCmd := exec.Command("root/automated_new_member.sh", email) + createCmd := exec.Command("/root/automated_new_member.sh", email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -27,7 +27,7 @@ func Create(email string) (username string, password string, error error) { } func Reset(email string) (username string, password string, error error) { - resetCmd := exec.Command("root/automated_reset_password.sh", email) + resetCmd := exec.Command("/root/automated_reset_password.sh", email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -47,7 +47,7 @@ func Reset(email string) (username string, password string, error error) { } func CheckIfExists(email string) (result bool, error error) { - resetCmd := exec.Command("root/automated_check_if_exists.sh", email) + resetCmd := exec.Command("/root/automated_check_if_exists.sh", email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} From 5f35392b47e992eda4f822bece3e1b3c3d08e12b Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 01:15:35 -0500 Subject: [PATCH 09/49] Added function to source on openrc.sh --- commands/slash/openstack.go | 7 ++++++- helpers/openstack.go | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 16e0f60..aca181f 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -44,8 +44,13 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d ssOption := i.ApplicationCommandData().Options[0].StringValue() + err := helpers.SourceOpenRC() + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + // CHECK IF USER IS DM'ABLE - err := helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) if err != nil { logging.Debug(s, "User's DMs are not open", i.Member.User, span) err = s.InteractionRespond( diff --git a/helpers/openstack.go b/helpers/openstack.go index 3ebffa7..a1a5e92 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -66,3 +66,16 @@ func CheckIfExists(email string) (result bool, error error) { return false, nil } } + +func SourceOpenRC() error { + sourceCmd := exec.Command("source", "/root/ops-openrc.sh") + + stderr := &bytes.Buffer{} + sourceCmd.Stderr = stderr + + err := sourceCmd.Run() + if err != nil { + return err + } + return nil +} From f0a1ad0fc9015284882d9aa8758642db731ff294 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 01:22:09 -0500 Subject: [PATCH 10/49] Added sh -c --- helpers/openstack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index a1a5e92..fe0054f 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -68,7 +68,7 @@ func CheckIfExists(email string) (result bool, error error) { } func SourceOpenRC() error { - sourceCmd := exec.Command("source", "/root/ops-openrc.sh") + sourceCmd := exec.Command("sh", "-c", "source /root/ops-openrc.sh") stderr := &bytes.Buffer{} sourceCmd.Stderr = stderr From 4cde432f2ef40d0ecd42fc36a41ccf3bd3a114f3 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 01:26:19 -0500 Subject: [PATCH 11/49] sh -> bash --- helpers/openstack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index fe0054f..481ac62 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -68,7 +68,7 @@ func CheckIfExists(email string) (result bool, error error) { } func SourceOpenRC() error { - sourceCmd := exec.Command("sh", "-c", "source /root/ops-openrc.sh") + sourceCmd := exec.Command("bash", "-c", "source /root/ops-openrc.sh") stderr := &bytes.Buffer{} sourceCmd.Stderr = stderr From 07cdb332d9457de207bae4ce1dbd8dd77a3bb15a Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 11:21:42 -0500 Subject: [PATCH 12/49] Added debugcreate --- commands/slash/openstack.go | 2 +- helpers/openstack.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index aca181f..c465fc2 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -119,7 +119,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // CREATE THE ACCOUNT - username, password, err := helpers.Create(email) + username, password, err := helpers.DebugCreate(s, i.Member.User, span, email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return diff --git a/helpers/openstack.go b/helpers/openstack.go index 481ac62..8fb6a7e 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -2,10 +2,42 @@ package helpers import ( "bytes" + "io" "os/exec" "strings" + + "github.com/bwmarrin/discordgo" + "github.com/ritsec/ops-bot-iii/logging" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace" ) +func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, email string) (username string, password string, error error) { + createCmd := exec.Command("/root/automated_new_member.sh", email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + createCmd.Stdout = stdout + createCmd.Stderr = stderr + + combinedOutput := &bytes.Buffer{} + createCmd.Stdout = io.MultiWriter(stdout, combinedOutput) + createCmd.Stderr = io.MultiWriter(stderr, combinedOutput) + + err := createCmd.Run() + if err != nil { + logging.Error(s, combinedOutput.String(), user, span) + return "", "", err + } + + logging.Debug(s, combinedOutput.String(), user, span) + output := strings.Fields(stdout.String()) + + username = output[0] + password = output[1] + + return username, password, nil +} + func Create(email string) (username string, password string, error error) { createCmd := exec.Command("/root/automated_new_member.sh", email) From cf86b07b811bc9dda12464c469e2f7653b6c1cb7 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 11:31:20 -0500 Subject: [PATCH 13/49] Changed run to start and wait --- commands/slash/openstack.go | 2 +- helpers/openstack.go | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index c465fc2..aca181f 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -119,7 +119,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // CREATE THE ACCOUNT - username, password, err := helpers.DebugCreate(s, i.Member.User, span, email) + username, password, err := helpers.Create(email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return diff --git a/helpers/openstack.go b/helpers/openstack.go index 8fb6a7e..09cd7a9 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -2,12 +2,10 @@ package helpers import ( "bytes" - "io" "os/exec" "strings" "github.com/bwmarrin/discordgo" - "github.com/ritsec/ops-bot-iii/logging" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace" ) @@ -19,17 +17,11 @@ func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, createCmd.Stdout = stdout createCmd.Stderr = stderr - combinedOutput := &bytes.Buffer{} - createCmd.Stdout = io.MultiWriter(stdout, combinedOutput) - createCmd.Stderr = io.MultiWriter(stderr, combinedOutput) - - err := createCmd.Run() + err := createCmd.Start() if err != nil { - logging.Error(s, combinedOutput.String(), user, span) return "", "", err } - logging.Debug(s, combinedOutput.String(), user, span) output := strings.Fields(stdout.String()) username = output[0] @@ -46,7 +38,11 @@ func Create(email string) (username string, password string, error error) { createCmd.Stdout = stdout createCmd.Stderr = stderr - err := createCmd.Run() + err := createCmd.Start() + if err != nil { + return "", "", err + } + err = createCmd.Wait() if err != nil { return "", "", err } From 8ed659a764b8f887b3d3346b63b060aea3f9c57d Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 12:46:54 -0500 Subject: [PATCH 14/49] removed redundant debugging --- commands/slash/openstack.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index aca181f..7800484 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -166,8 +166,6 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d return } } else { - // GRACEFULLY CLOSE - logging.Error(s, "User somehow got here?", i.Member.User, span) return } } From fc57194459f28eb7231c0f320b02f37edd5cbeed Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 13:09:23 -0500 Subject: [PATCH 15/49] debug the commands --- commands/slash/openstack.go | 8 +++-- helpers/openstack.go | 62 ++++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 7800484..f49e206 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -44,7 +44,8 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d ssOption := i.ApplicationCommandData().Options[0].StringValue() - err := helpers.SourceOpenRC() + // err := helpers.SourceOpenRC() + err := helpers.DebugSourceOpenRC(s, i.Member.User, span) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } @@ -93,7 +94,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // CHECK IF USER EXISTS ON OPENSTACK ALREADY - exists, err := helpers.CheckIfExists(email) + exists, err := helpers.DebugCheckIfExists(s, i.Member.User, span, email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return @@ -119,7 +120,8 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // CREATE THE ACCOUNT - username, password, err := helpers.Create(email) + // username, password, err := helpers.Create(email) + username, password, err := helpers.DebugCreate(s, i.Member.User, span, email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return diff --git a/helpers/openstack.go b/helpers/openstack.go index 09cd7a9..c59cedd 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -2,10 +2,12 @@ package helpers import ( "bytes" + "io" "os/exec" "strings" "github.com/bwmarrin/discordgo" + "github.com/ritsec/ops-bot-iii/logging" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace" ) @@ -17,11 +19,19 @@ func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, createCmd.Stdout = stdout createCmd.Stderr = stderr - err := createCmd.Start() + // Create a combined output buffer + combinedOutput := &bytes.Buffer{} + createCmd.Stdout = io.MultiWriter(stdout, combinedOutput) + createCmd.Stderr = io.MultiWriter(stderr, combinedOutput) + + err := createCmd.Run() if err != nil { + logging.Debug(s, combinedOutput.String(), user, span) return "", "", err } + logging.Debug(s, combinedOutput.String(), user, span) + output := strings.Fields(stdout.String()) username = output[0] @@ -74,6 +84,34 @@ func Reset(email string) (username string, password string, error error) { return username, password, nil } +func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, email string) (result bool, error error) { + checkIfExistsCmd := exec.Command("/root/automated_check_if_exists.sh", email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + checkIfExistsCmd.Stdout = stdout + checkIfExistsCmd.Stderr = stderr + // Create a combined output buffer + combinedOutput := &bytes.Buffer{} + checkIfExistsCmd.Stdout = io.MultiWriter(stdout, combinedOutput) + checkIfExistsCmd.Stderr = io.MultiWriter(stderr, combinedOutput) + + err := checkIfExistsCmd.Run() + if err != nil { + logging.Debug(s, combinedOutput.String(), user, span) + return false, err + } + + logging.Debug(s, combinedOutput.String(), user, span) + output := stdout.String() + + if output == "1" { + return true, nil + } else { + return false, nil + } +} + func CheckIfExists(email string) (result bool, error error) { resetCmd := exec.Command("/root/automated_check_if_exists.sh", email) @@ -95,6 +133,28 @@ func CheckIfExists(email string) (result bool, error error) { } } +func DebugSourceOpenRC(s *discordgo.Session, user *discordgo.User, span ddtrace.Span) error { + sourceCmd := exec.Command("bash", "-c", "source /root/ops-openrc.sh") + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + sourceCmd.Stdout = stdout + sourceCmd.Stderr = stderr + // Create a combined output buffer + combinedOutput := &bytes.Buffer{} + sourceCmd.Stdout = io.MultiWriter(stdout, combinedOutput) + sourceCmd.Stderr = io.MultiWriter(stderr, combinedOutput) + + err := sourceCmd.Run() + if err != nil { + logging.Debug(s, combinedOutput.String(), user, span) + return err + } + + logging.Debug(s, combinedOutput.String(), user, span) + return nil +} + func SourceOpenRC() error { sourceCmd := exec.Command("bash", "-c", "source /root/ops-openrc.sh") From f4229fa1cd31ba4604f82fd06e893c2a44c507bf Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 16:20:44 -0500 Subject: [PATCH 16/49] Added values for openstack environment variables and paths of scripts --- config_example.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/config_example.yml b/config_example.yml index b5e89e0..b6e8cb4 100644 --- a/config_example.yml +++ b/config_example.yml @@ -52,4 +52,20 @@ commands: channel_id: vote: url: http(s)://example.com(:port) - \ No newline at end of file +openstack: + ENV: + OS_AUTH_URL: + OS_PROJECT_ID: + OS_PROJECT_NAME: + OS_USER_DOMAIN_NAME: + OS_PROJECT_DOMAIN_ID: + OS_USERNAME: + OS_PASSWORD: + OS_REGION_NAME: + OS_INTERFACE: + OS_IDENTITY_API_VERSION: + # Absolute paths + SCRIPTS: + new_member: + reset_password: + check_if_exists: \ No newline at end of file From 5c4f8ef7739b3ba7f5e465c540ce7b7e3fb11821 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 16:21:48 -0500 Subject: [PATCH 17/49] deleted sourceRc and just did setenvs for openstack variables --- helpers/openstack.go | 77 ++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index c59cedd..d5623c4 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -3,16 +3,37 @@ package helpers import ( "bytes" "io" + "os" "os/exec" "strings" "github.com/bwmarrin/discordgo" + "github.com/ritsec/ops-bot-iii/config" "github.com/ritsec/ops-bot-iii/logging" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace" ) +var ( + // Environment variables required for openstack CLI + OS_AUTH_URL string = config.GetString("openstack.ENV.OS_AUTH_URL") + OS_PROJECT_ID string = config.GetString("openstack.ENV.OS_PROJECT_ID") + OS_PROJECT_NAME string = config.GetString("openstack.ENV.OS_PROJECT_NAME") + OS_USER_DOMAIN_NAME string = config.GetString("openstack.ENV.OS_USER_DOMAIN_NAME") + OS_PROJECT_DOMAIN_ID string = config.GetString("openstack.ENV.OS_PROJECT_DOMAIN_ID") + OS_USERNAME string = config.GetString("openstack.ENV.OS_USERNAME") + OS_PASSWORD string = config.GetString("openstack.ENV.OS_PASSWORD") + OS_REGION_NAME string = config.GetString("openstack.ENV.OS_REGION_NAME") + OS_INTERFACE string = config.GetString("openstack.ENV.OS_INTERFACE") + OS_IDENTITY_API_VERSION string = config.GetString("openstack.ENV.OS_IDENTITY_API_VERSION") + + // Paths for scripts to automate openstack user management + new_member string = config.GetString("openstack.SCRIPTS.new_member") + reset_password string = config.GetString("openstack.SCRIPTS.reset_password") + check_if_exists string = config.GetString("openstack.SCRIPTS.check_if_exists") +) + func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, email string) (username string, password string, error error) { - createCmd := exec.Command("/root/automated_new_member.sh", email) + createCmd := exec.Command(new_member, email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -41,7 +62,7 @@ func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, } func Create(email string) (username string, password string, error error) { - createCmd := exec.Command("/root/automated_new_member.sh", email) + createCmd := exec.Command(new_member, email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -65,7 +86,7 @@ func Create(email string) (username string, password string, error error) { } func Reset(email string) (username string, password string, error error) { - resetCmd := exec.Command("/root/automated_reset_password.sh", email) + resetCmd := exec.Command(reset_password, email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -85,7 +106,9 @@ func Reset(email string) (username string, password string, error error) { } func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, email string) (result bool, error error) { - checkIfExistsCmd := exec.Command("/root/automated_check_if_exists.sh", email) + checkIfExistsCmd := exec.Command(reset_password, email) + + logging.Debug(s, checkIfExistsCmd.String(), user, span) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -113,7 +136,7 @@ func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace } func CheckIfExists(email string) (result bool, error error) { - resetCmd := exec.Command("/root/automated_check_if_exists.sh", email) + resetCmd := exec.Command(check_if_exists, email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -133,37 +156,15 @@ func CheckIfExists(email string) (result bool, error error) { } } -func DebugSourceOpenRC(s *discordgo.Session, user *discordgo.User, span ddtrace.Span) error { - sourceCmd := exec.Command("bash", "-c", "source /root/ops-openrc.sh") - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - sourceCmd.Stdout = stdout - sourceCmd.Stderr = stderr - // Create a combined output buffer - combinedOutput := &bytes.Buffer{} - sourceCmd.Stdout = io.MultiWriter(stdout, combinedOutput) - sourceCmd.Stderr = io.MultiWriter(stderr, combinedOutput) - - err := sourceCmd.Run() - if err != nil { - logging.Debug(s, combinedOutput.String(), user, span) - return err - } - - logging.Debug(s, combinedOutput.String(), user, span) - return nil -} - -func SourceOpenRC() error { - sourceCmd := exec.Command("bash", "-c", "source /root/ops-openrc.sh") - - stderr := &bytes.Buffer{} - sourceCmd.Stderr = stderr - - err := sourceCmd.Run() - if err != nil { - return err - } - return nil +func SetOpenstackRC() { + os.Setenv("OS_AUTH_URL", OS_AUTH_URL) + os.Setenv("OS_PROJECT_ID", OS_PROJECT_ID) + os.Setenv("OS_PROJECT_NAME", OS_PROJECT_NAME) + os.Setenv("OS_USER_DOMAIN_NAME", OS_USER_DOMAIN_NAME) + os.Setenv("OS_PROJECT_DOMAIN_ID", OS_PROJECT_DOMAIN_ID) + os.Setenv("OS_USERNAME", OS_USERNAME) + os.Setenv("OS_PASSWORD", OS_PASSWORD) + os.Setenv("OS_REGION_NAME", OS_REGION_NAME) + os.Setenv("OS_INTERFACE", OS_INTERFACE) + os.Setenv("OS_IDENTITY_API_VERSION", OS_IDENTITY_API_VERSION) } From 58c2ca84f831e4613f4f64e58281f941e2b6b175 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 8 Nov 2024 16:22:10 -0500 Subject: [PATCH 18/49] refactored with updated helpers --- commands/slash/openstack.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index f49e206..bec01e9 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -44,14 +44,10 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d ssOption := i.ApplicationCommandData().Options[0].StringValue() - // err := helpers.SourceOpenRC() - err := helpers.DebugSourceOpenRC(s, i.Member.User, span) - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } + helpers.SetOpenstackRC() // CHECK IF USER IS DM'ABLE - err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + err := helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) if err != nil { logging.Debug(s, "User's DMs are not open", i.Member.User, span) err = s.InteractionRespond( @@ -101,6 +97,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } if ssOption == "Create" { + // USER TRYING TO CREATE ACCOUNT WHEN ALREADY HAS ONE if exists { logging.Debug(s, "User already has an openstack account and is trying to create one", i.Member.User, span) err = s.InteractionRespond( From 46dd69eb2e8d8b02aad113c351e0b38c75013a72 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 17:52:32 -0500 Subject: [PATCH 19/49] Fixed typo, was running wrong script --- helpers/openstack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index d5623c4..198580a 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -106,7 +106,7 @@ func Reset(email string) (username string, password string, error error) { } func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, email string) (result bool, error error) { - checkIfExistsCmd := exec.Command(reset_password, email) + checkIfExistsCmd := exec.Command(check_if_exists, email) logging.Debug(s, checkIfExistsCmd.String(), user, span) From 3300f7e8c433b42053d112f97e33bece5edf3ae4 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 18:18:08 -0500 Subject: [PATCH 20/49] Debugging messages --- commands/slash/openstack.go | 2 ++ helpers/openstack.go | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index bec01e9..6d85d15 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -91,6 +91,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d // CHECK IF USER EXISTS ON OPENSTACK ALREADY exists, err := helpers.DebugCheckIfExists(s, i.Member.User, span, email) + logging.Debug(s, fmt.Sprintf("Email: %s\nExists: %t", email, exists), i.Member.User, span) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return @@ -126,6 +127,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d // SEND THE USERNAME AND PASSWORD TO THE USER VIA DM message := fmt.Sprintf("Thank you for reaching out to us!\nHere are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) + logging.Debug(s, "Sent username and password to member", i.Member.User, span) err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) diff --git a/helpers/openstack.go b/helpers/openstack.go index 198580a..c6c1370 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -128,10 +128,10 @@ func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace logging.Debug(s, combinedOutput.String(), user, span) output := stdout.String() - if output == "1" { - return true, nil - } else { + if output == "0" { return false, nil + } else { + return true, nil } } From fde69485a02643348c28d9db4a739a4aa10adf37 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 18:23:03 -0500 Subject: [PATCH 21/49] Converted output to string for comparison --- helpers/openstack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index c6c1370..77c6c1f 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -128,7 +128,7 @@ func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace logging.Debug(s, combinedOutput.String(), user, span) output := stdout.String() - if output == "0" { + if string(output) == "0" { return false, nil } else { return true, nil From e3e15022b561f5dedff5ea320ab81c673f72bc0c Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 18:33:50 -0500 Subject: [PATCH 22/49] debug --- helpers/openstack.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/helpers/openstack.go b/helpers/openstack.go index 77c6c1f..72344b8 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -2,6 +2,7 @@ package helpers import ( "bytes" + "fmt" "io" "os" "os/exec" @@ -126,7 +127,9 @@ func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace } logging.Debug(s, combinedOutput.String(), user, span) + logging.Debug(s, fmt.Sprintf("combinedOutput type: %T", combinedOutput.String()), user, span) output := stdout.String() + logging.Debug(s, fmt.Sprintf("Output type: %T", output), user, span) if string(output) == "0" { return false, nil From f2375f43dff816a56a1c2b23fd15ebd1feed2366 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 18:40:51 -0500 Subject: [PATCH 23/49] Trim whitespace of output --- helpers/openstack.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index 72344b8..31832ac 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -2,7 +2,6 @@ package helpers import ( "bytes" - "fmt" "io" "os" "os/exec" @@ -127,11 +126,9 @@ func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace } logging.Debug(s, combinedOutput.String(), user, span) - logging.Debug(s, fmt.Sprintf("combinedOutput type: %T", combinedOutput.String()), user, span) - output := stdout.String() - logging.Debug(s, fmt.Sprintf("Output type: %T", output), user, span) + output := strings.TrimSpace(stdout.String()) - if string(output) == "0" { + if output == "0" { return false, nil } else { return true, nil From cf6a69476dfac006563ae891cd5091e9e3bc344a Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 19:21:21 -0500 Subject: [PATCH 24/49] Fixed reset --- commands/slash/openstack.go | 7 +++---- helpers/openstack.go | 33 ++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 6d85d15..9f3692f 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -90,7 +90,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // CHECK IF USER EXISTS ON OPENSTACK ALREADY - exists, err := helpers.DebugCheckIfExists(s, i.Member.User, span, email) + exists, err := helpers.CheckIfExists(email) logging.Debug(s, fmt.Sprintf("Email: %s\nExists: %t", email, exists), i.Member.User, span) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) @@ -118,8 +118,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // CREATE THE ACCOUNT - // username, password, err := helpers.Create(email) - username, password, err := helpers.DebugCreate(s, i.Member.User, span, email) + username, password, err := helpers.Create(email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return @@ -160,7 +159,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d return } - message := fmt.Sprintf("Thank you for reaching out to us!\nHere are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) + message := fmt.Sprintf("Thank you for reaching out to us!\n Here are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) diff --git a/helpers/openstack.go b/helpers/openstack.go index 31832ac..d9ebd43 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -45,9 +45,12 @@ func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, createCmd.Stdout = io.MultiWriter(stdout, combinedOutput) createCmd.Stderr = io.MultiWriter(stderr, combinedOutput) - err := createCmd.Run() + err := createCmd.Start() + if err != nil { + return "", "", err + } + err = createCmd.Wait() if err != nil { - logging.Debug(s, combinedOutput.String(), user, span) return "", "", err } @@ -77,8 +80,8 @@ func Create(email string) (username string, password string, error error) { if err != nil { return "", "", err } - output := strings.Fields(stdout.String()) + output := strings.Fields(stdout.String()) username = output[0] password = output[1] @@ -93,12 +96,16 @@ func Reset(email string) (username string, password string, error error) { resetCmd.Stdout = stdout resetCmd.Stderr = stderr - err := resetCmd.Run() + err := resetCmd.Start() + if err != nil { + return "", "", err + } + err = resetCmd.Wait() if err != nil { return "", "", err } - output := strings.Fields(stdout.String()) + output := strings.Fields(stdout.String()) username = output[0] password = output[1] @@ -136,23 +143,23 @@ func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace } func CheckIfExists(email string) (result bool, error error) { - resetCmd := exec.Command(check_if_exists, email) + checkIfExistsCmd := exec.Command(check_if_exists, email) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} - resetCmd.Stdout = stdout - resetCmd.Stderr = stderr + checkIfExistsCmd.Stdout = stdout + checkIfExistsCmd.Stderr = stderr - err := resetCmd.Run() + err := checkIfExistsCmd.Run() if err != nil { return false, err } - output := stdout.String() - if output == "1" { - return true, nil - } else { + output := strings.TrimSpace(stdout.String()) + if output == "0" { return false, nil + } else { + return true, nil } } From 1d44e96d7d31645667f9a901557af436581f1aae Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 19:26:33 -0500 Subject: [PATCH 25/49] Removed debug code --- helpers/openstack.go | 66 -------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/helpers/openstack.go b/helpers/openstack.go index d9ebd43..b5f7fd7 100644 --- a/helpers/openstack.go +++ b/helpers/openstack.go @@ -2,15 +2,11 @@ package helpers import ( "bytes" - "io" "os" "os/exec" "strings" - "github.com/bwmarrin/discordgo" "github.com/ritsec/ops-bot-iii/config" - "github.com/ritsec/ops-bot-iii/logging" - "gopkg.in/DataDog/dd-trace-go.v1/ddtrace" ) var ( @@ -32,38 +28,6 @@ var ( check_if_exists string = config.GetString("openstack.SCRIPTS.check_if_exists") ) -func DebugCreate(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, email string) (username string, password string, error error) { - createCmd := exec.Command(new_member, email) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - createCmd.Stdout = stdout - createCmd.Stderr = stderr - - // Create a combined output buffer - combinedOutput := &bytes.Buffer{} - createCmd.Stdout = io.MultiWriter(stdout, combinedOutput) - createCmd.Stderr = io.MultiWriter(stderr, combinedOutput) - - err := createCmd.Start() - if err != nil { - return "", "", err - } - err = createCmd.Wait() - if err != nil { - return "", "", err - } - - logging.Debug(s, combinedOutput.String(), user, span) - - output := strings.Fields(stdout.String()) - - username = output[0] - password = output[1] - - return username, password, nil -} - func Create(email string) (username string, password string, error error) { createCmd := exec.Command(new_member, email) @@ -112,36 +76,6 @@ func Reset(email string) (username string, password string, error error) { return username, password, nil } -func DebugCheckIfExists(s *discordgo.Session, user *discordgo.User, span ddtrace.Span, email string) (result bool, error error) { - checkIfExistsCmd := exec.Command(check_if_exists, email) - - logging.Debug(s, checkIfExistsCmd.String(), user, span) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - checkIfExistsCmd.Stdout = stdout - checkIfExistsCmd.Stderr = stderr - // Create a combined output buffer - combinedOutput := &bytes.Buffer{} - checkIfExistsCmd.Stdout = io.MultiWriter(stdout, combinedOutput) - checkIfExistsCmd.Stderr = io.MultiWriter(stderr, combinedOutput) - - err := checkIfExistsCmd.Run() - if err != nil { - logging.Debug(s, combinedOutput.String(), user, span) - return false, err - } - - logging.Debug(s, combinedOutput.String(), user, span) - output := strings.TrimSpace(stdout.String()) - - if output == "0" { - return false, nil - } else { - return true, nil - } -} - func CheckIfExists(email string) (result bool, error error) { checkIfExistsCmd := exec.Command(check_if_exists, email) From d73784e8aaeafb19539e7f7b0ff17d27564b9d9b Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 19:57:40 -0500 Subject: [PATCH 26/49] Created InitialMessage and UpdateMessage --- helpers/message.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 helpers/message.go diff --git a/helpers/message.go b/helpers/message.go new file mode 100644 index 0000000..ccc074d --- /dev/null +++ b/helpers/message.go @@ -0,0 +1,21 @@ +package helpers + +import "github.com/bwmarrin/discordgo" + +func InitialMessage(s *discordgo.Session, i *discordgo.InteractionCreate, message string) (error error) { + err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Flags: discordgo.MessageFlagsEphemeral, + Content: message, + }, + }) + return err +} + +func UpdateMessage(s *discordgo.Session, i *discordgo.InteractionCreate, message string) (error error) { + _, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{ + Content: &message, + }) + return err +} From df548d262806f632224bc3a9ddae3a648ebd55a8 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 19:57:56 -0500 Subject: [PATCH 27/49] Refactored with new helpers and cleaned up --- commands/slash/openstack.go | 72 ++++++++++++------------------------- 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 9f3692f..694a5da 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -2,6 +2,7 @@ package slash import ( "fmt" + "strings" "github.com/bwmarrin/discordgo" "github.com/ritsec/ops-bot-iii/commands/slash/permission" @@ -43,88 +44,67 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d defer span.Finish() ssOption := i.ApplicationCommandData().Options[0].StringValue() + helpers.InitialMessage(s, i, fmt.Sprintf("You ran the /openstack command to %s your account!", strings.ToLower(ssOption))) + // Initialize the environment variables for Openstack CLI helpers.SetOpenstackRC() - // CHECK IF USER IS DM'ABLE - err := helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + err := helpers.UpdateMessage(s, i, "Checking if your DMs are open...") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + + // Checking if the user is DM'able + err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) if err != nil { logging.Debug(s, "User's DMs are not open", i.Member.User, span) - err = s.InteractionRespond( - i.Interaction, - &discordgo.InteractionResponse{ - Type: discordgo.InteractionResponseChannelMessageWithSource, - Data: &discordgo.InteractionResponseData{ - Content: "Your DMs are not open! Please open your DMs and run the command again.", - Flags: discordgo.MessageFlagsEphemeral, - }, - }, - ) + err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } return } - // GET EMAIL AND CHECK IF IT IS VALID + // Get email and check if it is an actual email email, err := data.User.GetEmail(i.Member.User.ID, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } if email == "" { logging.Debug(s, "User has no email", i.Member.User, span) - err = s.InteractionRespond( - i.Interaction, - &discordgo.InteractionResponse{ - Type: discordgo.InteractionResponseChannelMessageWithSource, - Data: &discordgo.InteractionResponseData{ - Content: "You have no verified email. Run /member and verify your email and run this command again.", - Flags: discordgo.MessageFlagsEphemeral, - }, - }, - ) + err = helpers.UpdateMessage(s, i, "You have no verified email. Run /member and verify your email and run this command again.") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } return } - // CHECK IF USER EXISTS ON OPENSTACK ALREADY + // Check if user exists on Openstack already exists, err := helpers.CheckIfExists(email) - logging.Debug(s, fmt.Sprintf("Email: %s\nExists: %t", email, exists), i.Member.User, span) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return } if ssOption == "Create" { - // USER TRYING TO CREATE ACCOUNT WHEN ALREADY HAS ONE + // Check if user trying to create an account when it already has one if exists { logging.Debug(s, "User already has an openstack account and is trying to create one", i.Member.User, span) - err = s.InteractionRespond( - i.Interaction, - &discordgo.InteractionResponse{ - Type: discordgo.InteractionResponseChannelMessageWithSource, - Data: &discordgo.InteractionResponseData{ - Content: "Openstack account already exisits. Run the reset option if you forgot your password.", - Flags: discordgo.MessageFlagsEphemeral, - }, - }, - ) + err = helpers.UpdateMessage(s, i, "Openstack account already exisits. Run the reset option if you forgot your password.") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } return } - // CREATE THE ACCOUNT + // Create the account username, password, err := helpers.Create(email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return } - // SEND THE USERNAME AND PASSWORD TO THE USER VIA DM + // Send the username and password to the usuer via DM message := fmt.Sprintf("Thank you for reaching out to us!\nHere are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) logging.Debug(s, "Sent username and password to member", i.Member.User, span) err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) @@ -133,27 +113,19 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d return } } else if ssOption == "Reset" { - // CHECK IF USER IS TRYING TO RESET PASSWORD ON NON-EXISTENT ACCOUNT + // Check if the user is trying to reset password on non-existent account if !exists { logging.Debug(s, "User does not have an openstack account and is trying to reset the password on it", i.Member.User, span) - err = s.InteractionRespond( - i.Interaction, - &discordgo.InteractionResponse{ - Type: discordgo.InteractionResponseChannelMessageWithSource, - Data: &discordgo.InteractionResponseData{ - Content: "Openstack account does not exist and you are trying to reset it.", - Flags: discordgo.MessageFlagsEphemeral, - }, - }, - ) + err = helpers.UpdateMessage(s, i, "Openstack account does not exist and you are trying to reset it.") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } return } - // RESET THE PASSWORD OF THE ACCOUNT + // Reset the password of the account username, password, err := helpers.Reset(email) + logging.Debug(s, "User has the openstack account password reset", i.Member.User, span) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return From c0a9220d296d76e4d32c1121432bb5ed62d00704 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 20:01:45 -0500 Subject: [PATCH 28/49] Added missing return var --- commands/slash/openstack.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 694a5da..44a0bcf 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -44,12 +44,15 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d defer span.Finish() ssOption := i.ApplicationCommandData().Options[0].StringValue() - helpers.InitialMessage(s, i, fmt.Sprintf("You ran the /openstack command to %s your account!", strings.ToLower(ssOption))) + err := helpers.InitialMessage(s, i, fmt.Sprintf("You ran the /openstack command to %s your account!", strings.ToLower(ssOption))) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } // Initialize the environment variables for Openstack CLI helpers.SetOpenstackRC() - err := helpers.UpdateMessage(s, i, "Checking if your DMs are open...") + err = helpers.UpdateMessage(s, i, "Checking if your DMs are open...") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } From 865e84ba4958e5c093372abc48da9abc5954b126 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Sat, 9 Nov 2024 20:26:53 -0500 Subject: [PATCH 29/49] Refactored and combined into one file --- commands/slash/openstack.go | 167 ++++++++++++++++++++++++++++++++---- helpers/openstack.go | 111 ------------------------ 2 files changed, 150 insertions(+), 128 deletions(-) delete mode 100644 helpers/openstack.go diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 44a0bcf..d72e3b8 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -1,17 +1,40 @@ package slash import ( + "bytes" "fmt" + "os" + "os/exec" "strings" "github.com/bwmarrin/discordgo" "github.com/ritsec/ops-bot-iii/commands/slash/permission" + "github.com/ritsec/ops-bot-iii/config" "github.com/ritsec/ops-bot-iii/data" "github.com/ritsec/ops-bot-iii/helpers" "github.com/ritsec/ops-bot-iii/logging" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) +var ( + // Environment variables required for openstack CLI + OS_AUTH_URL string = config.GetString("openstack.ENV.OS_AUTH_URL") + OS_PROJECT_ID string = config.GetString("openstack.ENV.OS_PROJECT_ID") + OS_PROJECT_NAME string = config.GetString("openstack.ENV.OS_PROJECT_NAME") + OS_USER_DOMAIN_NAME string = config.GetString("openstack.ENV.OS_USER_DOMAIN_NAME") + OS_PROJECT_DOMAIN_ID string = config.GetString("openstack.ENV.OS_PROJECT_DOMAIN_ID") + OS_USERNAME string = config.GetString("openstack.ENV.OS_USERNAME") + OS_PASSWORD string = config.GetString("openstack.ENV.OS_PASSWORD") + OS_REGION_NAME string = config.GetString("openstack.ENV.OS_REGION_NAME") + OS_INTERFACE string = config.GetString("openstack.ENV.OS_INTERFACE") + OS_IDENTITY_API_VERSION string = config.GetString("openstack.ENV.OS_IDENTITY_API_VERSION") + + // Paths for scripts to automate openstack user management + new_member string = config.GetString("openstack.SCRIPTS.new_member") + reset_password string = config.GetString("openstack.SCRIPTS.reset_password") + check_if_exists string = config.GetString("openstack.SCRIPTS.check_if_exists") +) + func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) { return &discordgo.ApplicationCommand{ Name: "openstack", @@ -50,24 +73,12 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // Initialize the environment variables for Openstack CLI - helpers.SetOpenstackRC() + SetOpenstackRC() - err = helpers.UpdateMessage(s, i, "Checking if your DMs are open...") + err = helpers.UpdateMessage(s, i, "Checking your email...") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } - - // Checking if the user is DM'able - err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) - if err != nil { - logging.Debug(s, "User's DMs are not open", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - return - } - // Get email and check if it is an actual email email, err := data.User.GetEmail(i.Member.User.ID, span.Context()) if err != nil { @@ -83,7 +94,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // Check if user exists on Openstack already - exists, err := helpers.CheckIfExists(email) + exists, err := CheckIfExists(email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return @@ -100,8 +111,23 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d return } + // Checking if the user is DM'able + err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + if err != nil { + logging.Debug(s, "User's DMs are not open", i.Member.User, span) + err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } + // Create the account - username, password, err := helpers.Create(email) + err = helpers.UpdateMessage(s, i, "Creating your account...") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + username, password, err := Create(email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return @@ -115,6 +141,11 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d logging.Error(s, err.Error(), i.Member.User, span) return } + + err = helpers.UpdateMessage(s, i, "Sent the username and password to your DMs, check your DMs!") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } } else if ssOption == "Reset" { // Check if the user is trying to reset password on non-existent account if !exists { @@ -126,8 +157,23 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d return } + // Checking if the user is DM'able + err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + if err != nil { + logging.Debug(s, "User's DMs are not open", i.Member.User, span) + err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } + // Reset the password of the account - username, password, err := helpers.Reset(email) + err = helpers.UpdateMessage(s, i, "Resetting your account...") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + username, password, err := Reset(email) logging.Debug(s, "User has the openstack account password reset", i.Member.User, span) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) @@ -140,8 +186,95 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d logging.Error(s, err.Error(), i.Member.User, span) return } + + err = helpers.UpdateMessage(s, i, "Sent the username and password to your DMs, check your DMs!") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } } else { return } } } + +func Create(email string) (username string, password string, error error) { + createCmd := exec.Command(new_member, email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + createCmd.Stdout = stdout + createCmd.Stderr = stderr + + err := createCmd.Start() + if err != nil { + return "", "", err + } + err = createCmd.Wait() + if err != nil { + return "", "", err + } + + output := strings.Fields(stdout.String()) + username = output[0] + password = output[1] + + return username, password, nil +} + +func Reset(email string) (username string, password string, error error) { + resetCmd := exec.Command(reset_password, email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + resetCmd.Stdout = stdout + resetCmd.Stderr = stderr + + err := resetCmd.Start() + if err != nil { + return "", "", err + } + err = resetCmd.Wait() + if err != nil { + return "", "", err + } + + output := strings.Fields(stdout.String()) + username = output[0] + password = output[1] + + return username, password, nil +} + +func CheckIfExists(email string) (result bool, error error) { + checkIfExistsCmd := exec.Command(check_if_exists, email) + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + checkIfExistsCmd.Stdout = stdout + checkIfExistsCmd.Stderr = stderr + + err := checkIfExistsCmd.Run() + if err != nil { + return false, err + } + + output := strings.TrimSpace(stdout.String()) + if output == "0" { + return false, nil + } else { + return true, nil + } +} + +func SetOpenstackRC() { + os.Setenv("OS_AUTH_URL", OS_AUTH_URL) + os.Setenv("OS_PROJECT_ID", OS_PROJECT_ID) + os.Setenv("OS_PROJECT_NAME", OS_PROJECT_NAME) + os.Setenv("OS_USER_DOMAIN_NAME", OS_USER_DOMAIN_NAME) + os.Setenv("OS_PROJECT_DOMAIN_ID", OS_PROJECT_DOMAIN_ID) + os.Setenv("OS_USERNAME", OS_USERNAME) + os.Setenv("OS_PASSWORD", OS_PASSWORD) + os.Setenv("OS_REGION_NAME", OS_REGION_NAME) + os.Setenv("OS_INTERFACE", OS_INTERFACE) + os.Setenv("OS_IDENTITY_API_VERSION", OS_IDENTITY_API_VERSION) +} diff --git a/helpers/openstack.go b/helpers/openstack.go deleted file mode 100644 index b5f7fd7..0000000 --- a/helpers/openstack.go +++ /dev/null @@ -1,111 +0,0 @@ -package helpers - -import ( - "bytes" - "os" - "os/exec" - "strings" - - "github.com/ritsec/ops-bot-iii/config" -) - -var ( - // Environment variables required for openstack CLI - OS_AUTH_URL string = config.GetString("openstack.ENV.OS_AUTH_URL") - OS_PROJECT_ID string = config.GetString("openstack.ENV.OS_PROJECT_ID") - OS_PROJECT_NAME string = config.GetString("openstack.ENV.OS_PROJECT_NAME") - OS_USER_DOMAIN_NAME string = config.GetString("openstack.ENV.OS_USER_DOMAIN_NAME") - OS_PROJECT_DOMAIN_ID string = config.GetString("openstack.ENV.OS_PROJECT_DOMAIN_ID") - OS_USERNAME string = config.GetString("openstack.ENV.OS_USERNAME") - OS_PASSWORD string = config.GetString("openstack.ENV.OS_PASSWORD") - OS_REGION_NAME string = config.GetString("openstack.ENV.OS_REGION_NAME") - OS_INTERFACE string = config.GetString("openstack.ENV.OS_INTERFACE") - OS_IDENTITY_API_VERSION string = config.GetString("openstack.ENV.OS_IDENTITY_API_VERSION") - - // Paths for scripts to automate openstack user management - new_member string = config.GetString("openstack.SCRIPTS.new_member") - reset_password string = config.GetString("openstack.SCRIPTS.reset_password") - check_if_exists string = config.GetString("openstack.SCRIPTS.check_if_exists") -) - -func Create(email string) (username string, password string, error error) { - createCmd := exec.Command(new_member, email) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - createCmd.Stdout = stdout - createCmd.Stderr = stderr - - err := createCmd.Start() - if err != nil { - return "", "", err - } - err = createCmd.Wait() - if err != nil { - return "", "", err - } - - output := strings.Fields(stdout.String()) - username = output[0] - password = output[1] - - return username, password, nil -} - -func Reset(email string) (username string, password string, error error) { - resetCmd := exec.Command(reset_password, email) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - resetCmd.Stdout = stdout - resetCmd.Stderr = stderr - - err := resetCmd.Start() - if err != nil { - return "", "", err - } - err = resetCmd.Wait() - if err != nil { - return "", "", err - } - - output := strings.Fields(stdout.String()) - username = output[0] - password = output[1] - - return username, password, nil -} - -func CheckIfExists(email string) (result bool, error error) { - checkIfExistsCmd := exec.Command(check_if_exists, email) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - checkIfExistsCmd.Stdout = stdout - checkIfExistsCmd.Stderr = stderr - - err := checkIfExistsCmd.Run() - if err != nil { - return false, err - } - - output := strings.TrimSpace(stdout.String()) - if output == "0" { - return false, nil - } else { - return true, nil - } -} - -func SetOpenstackRC() { - os.Setenv("OS_AUTH_URL", OS_AUTH_URL) - os.Setenv("OS_PROJECT_ID", OS_PROJECT_ID) - os.Setenv("OS_PROJECT_NAME", OS_PROJECT_NAME) - os.Setenv("OS_USER_DOMAIN_NAME", OS_USER_DOMAIN_NAME) - os.Setenv("OS_PROJECT_DOMAIN_ID", OS_PROJECT_DOMAIN_ID) - os.Setenv("OS_USERNAME", OS_USERNAME) - os.Setenv("OS_PASSWORD", OS_PASSWORD) - os.Setenv("OS_REGION_NAME", OS_REGION_NAME) - os.Setenv("OS_INTERFACE", OS_INTERFACE) - os.Setenv("OS_IDENTITY_API_VERSION", OS_IDENTITY_API_VERSION) -} From dbd7447cceade7c51d8ca79448c1529c1c3b9967 Mon Sep 17 00:00:00 2001 From: c0unt <39505290+c0untingNumbers@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:47:49 -0500 Subject: [PATCH 30/49] Refactor into gophercloud (#151) --- .github/workflows/checks.yaml | 8 +- commands/slash/openstack.go | 312 ++++++----------- config/main.go | 12 + config_example.yml | 20 +- ent/birthday.go | 8 +- ent/birthday/where.go | 23 +- ent/birthday_create.go | 6 +- ent/birthday_delete.go | 2 +- ent/birthday_query.go | 21 +- ent/birthday_update.go | 36 +- ent/client.go | 107 +++++- ent/ent.go | 2 +- ent/runtime/runtime.go | 4 +- ent/shitpost.go | 8 +- ent/shitpost/where.go | 23 +- ent/shitpost_create.go | 6 +- ent/shitpost_delete.go | 2 +- ent/shitpost_query.go | 21 +- ent/shitpost_update.go | 36 +- ent/signin.go | 8 +- ent/signin/where.go | 23 +- ent/signin_create.go | 8 +- ent/signin_delete.go | 2 +- ent/signin_query.go | 21 +- ent/signin_update.go | 24 +- ent/user.go | 8 +- ent/user/where.go | 23 +- ent/user_create.go | 6 +- ent/user_delete.go | 2 +- ent/user_query.go | 29 +- ent/user_update.go | 4 +- ent/vote.go | 8 +- ent/vote/where.go | 23 +- ent/vote_create.go | 8 +- ent/vote_delete.go | 2 +- ent/vote_query.go | 21 +- ent/vote_update.go | 56 ++- ent/voteresult/where.go | 23 +- ent/voteresult_create.go | 6 +- ent/voteresult_delete.go | 2 +- ent/voteresult_query.go | 21 +- ent/voteresult_update.go | 52 ++- go.mod | 123 ++++--- go.sum | 624 +++++++++------------------------- osclient/main.go | 59 ++++ osclient/user.go | 204 +++++++++++ structs/openstack.go | 13 + 47 files changed, 1062 insertions(+), 998 deletions(-) create mode 100644 osclient/main.go create mode 100644 osclient/user.go create mode 100644 structs/openstack.go diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 09f0f25..eb727f5 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -13,14 +13,16 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.23.0' cache: false + - name: download dependencies + run: go mod tidy - name: Compile run: go build main.go - name: Unit Tests run: go test -v ./... - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: - version: v1.54 + version: v1.62 args: --timeout=10m \ No newline at end of file diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index d72e3b8..b2707da 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -1,10 +1,7 @@ package slash import ( - "bytes" "fmt" - "os" - "os/exec" "strings" "github.com/bwmarrin/discordgo" @@ -13,28 +10,10 @@ import ( "github.com/ritsec/ops-bot-iii/data" "github.com/ritsec/ops-bot-iii/helpers" "github.com/ritsec/ops-bot-iii/logging" + "github.com/ritsec/ops-bot-iii/osclient" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) -var ( - // Environment variables required for openstack CLI - OS_AUTH_URL string = config.GetString("openstack.ENV.OS_AUTH_URL") - OS_PROJECT_ID string = config.GetString("openstack.ENV.OS_PROJECT_ID") - OS_PROJECT_NAME string = config.GetString("openstack.ENV.OS_PROJECT_NAME") - OS_USER_DOMAIN_NAME string = config.GetString("openstack.ENV.OS_USER_DOMAIN_NAME") - OS_PROJECT_DOMAIN_ID string = config.GetString("openstack.ENV.OS_PROJECT_DOMAIN_ID") - OS_USERNAME string = config.GetString("openstack.ENV.OS_USERNAME") - OS_PASSWORD string = config.GetString("openstack.ENV.OS_PASSWORD") - OS_REGION_NAME string = config.GetString("openstack.ENV.OS_REGION_NAME") - OS_INTERFACE string = config.GetString("openstack.ENV.OS_INTERFACE") - OS_IDENTITY_API_VERSION string = config.GetString("openstack.ENV.OS_IDENTITY_API_VERSION") - - // Paths for scripts to automate openstack user management - new_member string = config.GetString("openstack.SCRIPTS.new_member") - reset_password string = config.GetString("openstack.SCRIPTS.reset_password") - check_if_exists string = config.GetString("openstack.SCRIPTS.check_if_exists") -) - func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) { return &discordgo.ApplicationCommand{ Name: "openstack", @@ -60,221 +39,138 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d }, }, func(s *discordgo.Session, i *discordgo.InteractionCreate) { - span := tracer.StartSpan( - "commands.slash.openstack:Openstack", - tracer.ResourceName("/openstack"), - ) - defer span.Finish() - - ssOption := i.ApplicationCommandData().Options[0].StringValue() - err := helpers.InitialMessage(s, i, fmt.Sprintf("You ran the /openstack command to %s your account!", strings.ToLower(ssOption))) - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - - // Initialize the environment variables for Openstack CLI - SetOpenstackRC() - - err = helpers.UpdateMessage(s, i, "Checking your email...") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - // Get email and check if it is an actual email - email, err := data.User.GetEmail(i.Member.User.ID, span.Context()) - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - if email == "" { - logging.Debug(s, "User has no email", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "You have no verified email. Run /member and verify your email and run this command again.") + if config.Openstack.Enabled { + span := tracer.StartSpan( + "commands.slash.openstack:Openstack", + tracer.ResourceName("/openstack"), + ) + defer span.Finish() + + ssOption := i.ApplicationCommandData().Options[0].StringValue() + err := helpers.InitialMessage(s, i, fmt.Sprintf("You ran the /openstack command to %s your account!", strings.ToLower(ssOption))) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } - return - } - - // Check if user exists on Openstack already - exists, err := CheckIfExists(email) - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - return - } - if ssOption == "Create" { - // Check if user trying to create an account when it already has one - if exists { - logging.Debug(s, "User already has an openstack account and is trying to create one", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "Openstack account already exisits. Run the reset option if you forgot your password.") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - return + err = helpers.UpdateMessage(s, i, "Checking your email...") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) } - - // Checking if the user is DM'able - err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + // Get email and check if it is an actual email + email, err := data.User.GetEmail(i.Member.User.ID, span.Context()) if err != nil { - logging.Debug(s, "User's DMs are not open", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") + logging.Error(s, err.Error(), i.Member.User, span) + } + if email == "" { + logging.Debug(s, "User has no email", i.Member.User, span) + err = helpers.UpdateMessage(s, i, "You have no verified email. Run /member and verify your email and run this command again.") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } return } - // Create the account - err = helpers.UpdateMessage(s, i, "Creating your account...") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - username, password, err := Create(email) + // Check if user exists on Openstack already + exists, err := osclient.CheckUserExists(email) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return } - // Send the username and password to the usuer via DM - message := fmt.Sprintf("Thank you for reaching out to us!\nHere are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) - logging.Debug(s, "Sent username and password to member", i.Member.User, span) - err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - return - } + if ssOption == "Create" { + // Stop here if user trying to create an account when it already has one + if exists { + logging.Debug(s, "User already has an openstack account and is trying to create one", i.Member.User, span) + err = helpers.UpdateMessage(s, i, "Openstack account already exisits. Run the reset option if you forgot your password.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } - err = helpers.UpdateMessage(s, i, "Sent the username and password to your DMs, check your DMs!") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - } else if ssOption == "Reset" { - // Check if the user is trying to reset password on non-existent account - if !exists { - logging.Debug(s, "User does not have an openstack account and is trying to reset the password on it", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "Openstack account does not exist and you are trying to reset it.") + // Checking if the user is DM'able + err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + if err != nil { + logging.Debug(s, "User's DMs are not open", i.Member.User, span) + err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } + + // Create the account + err = helpers.UpdateMessage(s, i, "Creating your account...") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } - return - } + username, password, err := osclient.Create(email) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } - // Checking if the user is DM'able - err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) - if err != nil { - logging.Debug(s, "User's DMs are not open", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") + // Send the username and password to the usuer via DM + message := fmt.Sprintf("Thank you for reaching out to us!\nHere are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) + logging.Debug(s, "Sent username and password to member", i.Member.User, span) + err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) + return } - return - } - // Reset the password of the account - err = helpers.UpdateMessage(s, i, "Resetting your account...") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - } - username, password, err := Reset(email) - logging.Debug(s, "User has the openstack account password reset", i.Member.User, span) - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - return - } + err = helpers.UpdateMessage(s, i, "Sent the username and password to your DMs, check your DMs!") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + } else if ssOption == "Reset" { + // Check if the user is trying to reset password on non-existent account + if !exists { + logging.Debug(s, "User does not have an openstack account and is trying to reset the password on it", i.Member.User, span) + err = helpers.UpdateMessage(s, i, "Openstack account does not exist and you are trying to reset it.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } - message := fmt.Sprintf("Thank you for reaching out to us!\n Here are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) - err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - return - } + // Checking if the user is DM'able + err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) + if err != nil { + logging.Debug(s, "User's DMs are not open", i.Member.User, span) + err = helpers.UpdateMessage(s, i, "Your DMs are not open! Please open your DMs and run the command again.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return + } - err = helpers.UpdateMessage(s, i, "Sent the username and password to your DMs, check your DMs!") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) + // // Reset the password of the account + err = helpers.UpdateMessage(s, i, "Resetting your account...") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + username, password, err := osclient.Reset(email) + logging.Debug(s, "User has the openstack account password reset", i.Member.User, span) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + + message := fmt.Sprintf("Thank you for reaching out to us!\n Here are your credentials for RITSEC's Openstack:\n\nUsername: %s\nTemporary Password: %s\n\nPlease change the password\nOpenstack link: stack.ritsec.cloud", username, password) + err = helpers.SendDirectMessage(s, i.Member.User.ID, message, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + + err = helpers.UpdateMessage(s, i, "Sent the username and password to your DMs, check your DMs!") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + } else { + return } - } else { - return } } } - -func Create(email string) (username string, password string, error error) { - createCmd := exec.Command(new_member, email) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - createCmd.Stdout = stdout - createCmd.Stderr = stderr - - err := createCmd.Start() - if err != nil { - return "", "", err - } - err = createCmd.Wait() - if err != nil { - return "", "", err - } - - output := strings.Fields(stdout.String()) - username = output[0] - password = output[1] - - return username, password, nil -} - -func Reset(email string) (username string, password string, error error) { - resetCmd := exec.Command(reset_password, email) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - resetCmd.Stdout = stdout - resetCmd.Stderr = stderr - - err := resetCmd.Start() - if err != nil { - return "", "", err - } - err = resetCmd.Wait() - if err != nil { - return "", "", err - } - - output := strings.Fields(stdout.String()) - username = output[0] - password = output[1] - - return username, password, nil -} - -func CheckIfExists(email string) (result bool, error error) { - checkIfExistsCmd := exec.Command(check_if_exists, email) - - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - checkIfExistsCmd.Stdout = stdout - checkIfExistsCmd.Stderr = stderr - - err := checkIfExistsCmd.Run() - if err != nil { - return false, err - } - - output := strings.TrimSpace(stdout.String()) - if output == "0" { - return false, nil - } else { - return true, nil - } -} - -func SetOpenstackRC() { - os.Setenv("OS_AUTH_URL", OS_AUTH_URL) - os.Setenv("OS_PROJECT_ID", OS_PROJECT_ID) - os.Setenv("OS_PROJECT_NAME", OS_PROJECT_NAME) - os.Setenv("OS_USER_DOMAIN_NAME", OS_USER_DOMAIN_NAME) - os.Setenv("OS_PROJECT_DOMAIN_ID", OS_PROJECT_DOMAIN_ID) - os.Setenv("OS_USERNAME", OS_USERNAME) - os.Setenv("OS_PASSWORD", OS_PASSWORD) - os.Setenv("OS_REGION_NAME", OS_REGION_NAME) - os.Setenv("OS_INTERFACE", OS_INTERFACE) - os.Setenv("OS_IDENTITY_API_VERSION", OS_IDENTITY_API_VERSION) -} diff --git a/config/main.go b/config/main.go index 2e9cae4..362dc8d 100644 --- a/config/main.go +++ b/config/main.go @@ -33,6 +33,9 @@ var ( // Environment is the environment the application is running in Environment string + + // Openstack is the openstack configuration + Openstack structs.OpenstackConfig ) func init() { @@ -63,12 +66,21 @@ func UpdateConfigs() { GuildID = viper.GetString("guild_id") ServiceName = viper.GetString("name") Environment = viper.GetString("env") + Openstack = openstack() Logging = logging() Google = google() Web = web() MailGun = mailgun() } +func openstack() structs.OpenstackConfig { + return structs.OpenstackConfig{ + Enabled: viper.GetBool("openstack.enabled"), + MemberID: viper.GetString("openstack.member_id"), + CloudsPath: viper.GetString("openstack.clouds_path"), + } +} + // web returns the web configuration func web() structs.WebConfig { return structs.WebConfig{ diff --git a/config_example.yml b/config_example.yml index b6e8cb4..28c87ef 100644 --- a/config_example.yml +++ b/config_example.yml @@ -53,19 +53,7 @@ commands: vote: url: http(s)://example.com(:port) openstack: - ENV: - OS_AUTH_URL: - OS_PROJECT_ID: - OS_PROJECT_NAME: - OS_USER_DOMAIN_NAME: - OS_PROJECT_DOMAIN_ID: - OS_USERNAME: - OS_PASSWORD: - OS_REGION_NAME: - OS_INTERFACE: - OS_IDENTITY_API_VERSION: - # Absolute paths - SCRIPTS: - new_member: - reset_password: - check_if_exists: \ No newline at end of file + # Must have a clouds.yaml if set to true, otherwise it will crash + enabled: false + member_id: + clouds_path: \ No newline at end of file diff --git a/ent/birthday.go b/ent/birthday.go index bced089..c021311 100644 --- a/ent/birthday.go +++ b/ent/birthday.go @@ -40,12 +40,10 @@ type BirthdayEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e BirthdayEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/ent/birthday/where.go b/ent/birthday/where.go index 8ede7c4..4069efe 100644 --- a/ent/birthday/where.go +++ b/ent/birthday/where.go @@ -168,32 +168,15 @@ func HasUserWith(preds ...predicate.User) predicate.Birthday { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Birthday) predicate.Birthday { - return predicate.Birthday(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Birthday(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Birthday) predicate.Birthday { - return predicate.Birthday(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Birthday(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Birthday) predicate.Birthday { - return predicate.Birthday(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Birthday(sql.NotPredicates(p)) } diff --git a/ent/birthday_create.go b/ent/birthday_create.go index 62b1306..423ad25 100644 --- a/ent/birthday_create.go +++ b/ent/birthday_create.go @@ -58,7 +58,7 @@ func (bc *BirthdayCreate) Mutation() *BirthdayMutation { // Save creates the Birthday in the database. func (bc *BirthdayCreate) Save(ctx context.Context) (*Birthday, error) { - return withHooks[*Birthday, BirthdayMutation](ctx, bc.sqlSave, bc.mutation, bc.hooks) + return withHooks(ctx, bc.sqlSave, bc.mutation, bc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -158,11 +158,15 @@ func (bc *BirthdayCreate) createSpec() (*Birthday, *sqlgraph.CreateSpec) { // BirthdayCreateBulk is the builder for creating many Birthday entities in bulk. type BirthdayCreateBulk struct { config + err error builders []*BirthdayCreate } // Save creates the Birthday entities in the database. func (bcb *BirthdayCreateBulk) Save(ctx context.Context) ([]*Birthday, error) { + if bcb.err != nil { + return nil, bcb.err + } specs := make([]*sqlgraph.CreateSpec, len(bcb.builders)) nodes := make([]*Birthday, len(bcb.builders)) mutators := make([]Mutator, len(bcb.builders)) diff --git a/ent/birthday_delete.go b/ent/birthday_delete.go index 1eca6e0..e446033 100644 --- a/ent/birthday_delete.go +++ b/ent/birthday_delete.go @@ -27,7 +27,7 @@ func (bd *BirthdayDelete) Where(ps ...predicate.Birthday) *BirthdayDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (bd *BirthdayDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, BirthdayMutation](ctx, bd.sqlExec, bd.mutation, bd.hooks) + return withHooks(ctx, bd.sqlExec, bd.mutation, bd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/ent/birthday_query.go b/ent/birthday_query.go index 31fde05..a3241ce 100644 --- a/ent/birthday_query.go +++ b/ent/birthday_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -85,7 +86,7 @@ func (bq *BirthdayQuery) QueryUser() *UserQuery { // First returns the first Birthday entity from the query. // Returns a *NotFoundError when no Birthday was found. func (bq *BirthdayQuery) First(ctx context.Context) (*Birthday, error) { - nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, "First")) + nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -108,7 +109,7 @@ func (bq *BirthdayQuery) FirstX(ctx context.Context) *Birthday { // Returns a *NotFoundError when no Birthday ID was found. func (bq *BirthdayQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, "FirstID")); err != nil { + if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -131,7 +132,7 @@ func (bq *BirthdayQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Birthday entity is found. // Returns a *NotFoundError when no Birthday entities are found. func (bq *BirthdayQuery) Only(ctx context.Context) (*Birthday, error) { - nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, "Only")) + nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -159,7 +160,7 @@ func (bq *BirthdayQuery) OnlyX(ctx context.Context) *Birthday { // Returns a *NotFoundError when no entities are found. func (bq *BirthdayQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, "OnlyID")); err != nil { + if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -184,7 +185,7 @@ func (bq *BirthdayQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Birthdays. func (bq *BirthdayQuery) All(ctx context.Context) ([]*Birthday, error) { - ctx = setContextOp(ctx, bq.ctx, "All") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryAll) if err := bq.prepareQuery(ctx); err != nil { return nil, err } @@ -206,7 +207,7 @@ func (bq *BirthdayQuery) IDs(ctx context.Context) (ids []int, err error) { if bq.ctx.Unique == nil && bq.path != nil { bq.Unique(true) } - ctx = setContextOp(ctx, bq.ctx, "IDs") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryIDs) if err = bq.Select(birthday.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -224,7 +225,7 @@ func (bq *BirthdayQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (bq *BirthdayQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, bq.ctx, "Count") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryCount) if err := bq.prepareQuery(ctx); err != nil { return 0, err } @@ -242,7 +243,7 @@ func (bq *BirthdayQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (bq *BirthdayQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, bq.ctx, "Exist") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryExist) switch _, err := bq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -536,7 +537,7 @@ func (bgb *BirthdayGroupBy) Aggregate(fns ...AggregateFunc) *BirthdayGroupBy { // Scan applies the selector query and scans the result into the given value. func (bgb *BirthdayGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, bgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, bgb.build.ctx, ent.OpQueryGroupBy) if err := bgb.build.prepareQuery(ctx); err != nil { return err } @@ -584,7 +585,7 @@ func (bs *BirthdaySelect) Aggregate(fns ...AggregateFunc) *BirthdaySelect { // Scan applies the selector query and scans the result into the given value. func (bs *BirthdaySelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, bs.ctx, "Select") + ctx = setContextOp(ctx, bs.ctx, ent.OpQuerySelect) if err := bs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/birthday_update.go b/ent/birthday_update.go index 1a9b9c7..d17ba6c 100644 --- a/ent/birthday_update.go +++ b/ent/birthday_update.go @@ -35,6 +35,14 @@ func (bu *BirthdayUpdate) SetDay(i int) *BirthdayUpdate { return bu } +// SetNillableDay sets the "day" field if the given value is not nil. +func (bu *BirthdayUpdate) SetNillableDay(i *int) *BirthdayUpdate { + if i != nil { + bu.SetDay(*i) + } + return bu +} + // AddDay adds i to the "day" field. func (bu *BirthdayUpdate) AddDay(i int) *BirthdayUpdate { bu.mutation.AddDay(i) @@ -48,6 +56,14 @@ func (bu *BirthdayUpdate) SetMonth(i int) *BirthdayUpdate { return bu } +// SetNillableMonth sets the "month" field if the given value is not nil. +func (bu *BirthdayUpdate) SetNillableMonth(i *int) *BirthdayUpdate { + if i != nil { + bu.SetMonth(*i) + } + return bu +} + // AddMonth adds i to the "month" field. func (bu *BirthdayUpdate) AddMonth(i int) *BirthdayUpdate { bu.mutation.AddMonth(i) @@ -86,7 +102,7 @@ func (bu *BirthdayUpdate) ClearUser() *BirthdayUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (bu *BirthdayUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, BirthdayMutation](ctx, bu.sqlSave, bu.mutation, bu.hooks) + return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -206,6 +222,14 @@ func (buo *BirthdayUpdateOne) SetDay(i int) *BirthdayUpdateOne { return buo } +// SetNillableDay sets the "day" field if the given value is not nil. +func (buo *BirthdayUpdateOne) SetNillableDay(i *int) *BirthdayUpdateOne { + if i != nil { + buo.SetDay(*i) + } + return buo +} + // AddDay adds i to the "day" field. func (buo *BirthdayUpdateOne) AddDay(i int) *BirthdayUpdateOne { buo.mutation.AddDay(i) @@ -219,6 +243,14 @@ func (buo *BirthdayUpdateOne) SetMonth(i int) *BirthdayUpdateOne { return buo } +// SetNillableMonth sets the "month" field if the given value is not nil. +func (buo *BirthdayUpdateOne) SetNillableMonth(i *int) *BirthdayUpdateOne { + if i != nil { + buo.SetMonth(*i) + } + return buo +} + // AddMonth adds i to the "month" field. func (buo *BirthdayUpdateOne) AddMonth(i int) *BirthdayUpdateOne { buo.mutation.AddMonth(i) @@ -270,7 +302,7 @@ func (buo *BirthdayUpdateOne) Select(field string, fields ...string) *BirthdayUp // Save executes the query and returns the updated Birthday entity. func (buo *BirthdayUpdateOne) Save(ctx context.Context) (*Birthday, error) { - return withHooks[*Birthday, BirthdayMutation](ctx, buo.sqlSave, buo.mutation, buo.hooks) + return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/ent/client.go b/ent/client.go index 917eb79..9886986 100644 --- a/ent/client.go +++ b/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "github.com/ritsec/ops-bot-iii/ent/migrate" @@ -43,9 +44,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -78,6 +77,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -125,11 +131,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -269,6 +278,21 @@ func (c *BirthdayClient) CreateBulk(builders ...*BirthdayCreate) *BirthdayCreate return &BirthdayCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BirthdayClient) MapCreateBulk(slice any, setFunc func(*BirthdayCreate, int)) *BirthdayCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BirthdayCreateBulk{err: fmt.Errorf("calling to BirthdayClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BirthdayCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BirthdayCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Birthday. func (c *BirthdayClient) Update() *BirthdayUpdate { mutation := newBirthdayMutation(c.config, OpUpdate) @@ -403,6 +427,21 @@ func (c *ShitpostClient) CreateBulk(builders ...*ShitpostCreate) *ShitpostCreate return &ShitpostCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ShitpostClient) MapCreateBulk(slice any, setFunc func(*ShitpostCreate, int)) *ShitpostCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ShitpostCreateBulk{err: fmt.Errorf("calling to ShitpostClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ShitpostCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ShitpostCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Shitpost. func (c *ShitpostClient) Update() *ShitpostUpdate { mutation := newShitpostMutation(c.config, OpUpdate) @@ -537,6 +576,21 @@ func (c *SigninClient) CreateBulk(builders ...*SigninCreate) *SigninCreateBulk { return &SigninCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *SigninClient) MapCreateBulk(slice any, setFunc func(*SigninCreate, int)) *SigninCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &SigninCreateBulk{err: fmt.Errorf("calling to SigninClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*SigninCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &SigninCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Signin. func (c *SigninClient) Update() *SigninUpdate { mutation := newSigninMutation(c.config, OpUpdate) @@ -671,6 +725,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) @@ -853,6 +922,21 @@ func (c *VoteClient) CreateBulk(builders ...*VoteCreate) *VoteCreateBulk { return &VoteCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *VoteClient) MapCreateBulk(slice any, setFunc func(*VoteCreate, int)) *VoteCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VoteCreateBulk{err: fmt.Errorf("calling to VoteClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VoteCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VoteCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Vote. func (c *VoteClient) Update() *VoteUpdate { mutation := newVoteMutation(c.config, OpUpdate) @@ -987,6 +1071,21 @@ func (c *VoteResultClient) CreateBulk(builders ...*VoteResultCreate) *VoteResult return &VoteResultCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *VoteResultClient) MapCreateBulk(slice any, setFunc func(*VoteResultCreate, int)) *VoteResultCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VoteResultCreateBulk{err: fmt.Errorf("calling to VoteResultClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VoteResultCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VoteResultCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for VoteResult. func (c *VoteResultClient) Update() *VoteResultUpdate { mutation := newVoteResultMutation(c.config, OpUpdate) diff --git a/ent/ent.go b/ent/ent.go index 0424ed6..3914f93 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -74,7 +74,7 @@ var ( columnCheck sql.ColumnCheck ) -// columnChecker checks if the column exists in the given table. +// checkColumn checks if the column exists in the given table. func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go index 955e496..632005b 100644 --- a/ent/runtime/runtime.go +++ b/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in github.com/ritsec/ops-bot-iii/ent/runtime.go const ( - Version = "v0.12.1" // Version of ent codegen. - Sum = "h1:bqK+WMwfjpTsFiXx9tQSEZMNLyAADSx5Y1xySjT4Tm8=" // Sum of ent codegen. + Version = "v0.14.1" // Version of ent codegen. + Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. ) diff --git a/ent/shitpost.go b/ent/shitpost.go index d623ced..5d5920e 100644 --- a/ent/shitpost.go +++ b/ent/shitpost.go @@ -41,12 +41,10 @@ type ShitpostEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e ShitpostEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/ent/shitpost/where.go b/ent/shitpost/where.go index f95826d..86433a7 100644 --- a/ent/shitpost/where.go +++ b/ent/shitpost/where.go @@ -203,32 +203,15 @@ func HasUserWith(preds ...predicate.User) predicate.Shitpost { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Shitpost) predicate.Shitpost { - return predicate.Shitpost(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Shitpost(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Shitpost) predicate.Shitpost { - return predicate.Shitpost(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Shitpost(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Shitpost) predicate.Shitpost { - return predicate.Shitpost(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Shitpost(sql.NotPredicates(p)) } diff --git a/ent/shitpost_create.go b/ent/shitpost_create.go index fd0f055..3df565e 100644 --- a/ent/shitpost_create.go +++ b/ent/shitpost_create.go @@ -64,7 +64,7 @@ func (sc *ShitpostCreate) Mutation() *ShitpostMutation { // Save creates the Shitpost in the database. func (sc *ShitpostCreate) Save(ctx context.Context) (*Shitpost, error) { - return withHooks[*Shitpost, ShitpostMutation](ctx, sc.sqlSave, sc.mutation, sc.hooks) + return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -173,11 +173,15 @@ func (sc *ShitpostCreate) createSpec() (*Shitpost, *sqlgraph.CreateSpec) { // ShitpostCreateBulk is the builder for creating many Shitpost entities in bulk. type ShitpostCreateBulk struct { config + err error builders []*ShitpostCreate } // Save creates the Shitpost entities in the database. func (scb *ShitpostCreateBulk) Save(ctx context.Context) ([]*Shitpost, error) { + if scb.err != nil { + return nil, scb.err + } specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) nodes := make([]*Shitpost, len(scb.builders)) mutators := make([]Mutator, len(scb.builders)) diff --git a/ent/shitpost_delete.go b/ent/shitpost_delete.go index 78cf5a2..ca8f2d1 100644 --- a/ent/shitpost_delete.go +++ b/ent/shitpost_delete.go @@ -27,7 +27,7 @@ func (sd *ShitpostDelete) Where(ps ...predicate.Shitpost) *ShitpostDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (sd *ShitpostDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, ShitpostMutation](ctx, sd.sqlExec, sd.mutation, sd.hooks) + return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/ent/shitpost_query.go b/ent/shitpost_query.go index 2300c7a..0fc421e 100644 --- a/ent/shitpost_query.go +++ b/ent/shitpost_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -85,7 +86,7 @@ func (sq *ShitpostQuery) QueryUser() *UserQuery { // First returns the first Shitpost entity from the query. // Returns a *NotFoundError when no Shitpost was found. func (sq *ShitpostQuery) First(ctx context.Context) (*Shitpost, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -108,7 +109,7 @@ func (sq *ShitpostQuery) FirstX(ctx context.Context) *Shitpost { // Returns a *NotFoundError when no Shitpost ID was found. func (sq *ShitpostQuery) FirstID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -131,7 +132,7 @@ func (sq *ShitpostQuery) FirstIDX(ctx context.Context) string { // Returns a *NotSingularError when more than one Shitpost entity is found. // Returns a *NotFoundError when no Shitpost entities are found. func (sq *ShitpostQuery) Only(ctx context.Context) (*Shitpost, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -159,7 +160,7 @@ func (sq *ShitpostQuery) OnlyX(ctx context.Context) *Shitpost { // Returns a *NotFoundError when no entities are found. func (sq *ShitpostQuery) OnlyID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -184,7 +185,7 @@ func (sq *ShitpostQuery) OnlyIDX(ctx context.Context) string { // All executes the query and returns a list of Shitposts. func (sq *ShitpostQuery) All(ctx context.Context) ([]*Shitpost, error) { - ctx = setContextOp(ctx, sq.ctx, "All") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryAll) if err := sq.prepareQuery(ctx); err != nil { return nil, err } @@ -206,7 +207,7 @@ func (sq *ShitpostQuery) IDs(ctx context.Context) (ids []string, err error) { if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } - ctx = setContextOp(ctx, sq.ctx, "IDs") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryIDs) if err = sq.Select(shitpost.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -224,7 +225,7 @@ func (sq *ShitpostQuery) IDsX(ctx context.Context) []string { // Count returns the count of the given query. func (sq *ShitpostQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryCount) if err := sq.prepareQuery(ctx); err != nil { return 0, err } @@ -242,7 +243,7 @@ func (sq *ShitpostQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (sq *ShitpostQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryExist) switch _, err := sq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -536,7 +537,7 @@ func (sgb *ShitpostGroupBy) Aggregate(fns ...AggregateFunc) *ShitpostGroupBy { // Scan applies the selector query and scans the result into the given value. func (sgb *ShitpostGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, sgb.build.ctx, ent.OpQueryGroupBy) if err := sgb.build.prepareQuery(ctx); err != nil { return err } @@ -584,7 +585,7 @@ func (ss *ShitpostSelect) Aggregate(fns ...AggregateFunc) *ShitpostSelect { // Scan applies the selector query and scans the result into the given value. func (ss *ShitpostSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") + ctx = setContextOp(ctx, ss.ctx, ent.OpQuerySelect) if err := ss.prepareQuery(ctx); err != nil { return err } diff --git a/ent/shitpost_update.go b/ent/shitpost_update.go index 2a4b03d..ecc9676 100644 --- a/ent/shitpost_update.go +++ b/ent/shitpost_update.go @@ -34,6 +34,14 @@ func (su *ShitpostUpdate) SetChannelID(s string) *ShitpostUpdate { return su } +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (su *ShitpostUpdate) SetNillableChannelID(s *string) *ShitpostUpdate { + if s != nil { + su.SetChannelID(*s) + } + return su +} + // SetCount sets the "count" field. func (su *ShitpostUpdate) SetCount(i int) *ShitpostUpdate { su.mutation.ResetCount() @@ -41,6 +49,14 @@ func (su *ShitpostUpdate) SetCount(i int) *ShitpostUpdate { return su } +// SetNillableCount sets the "count" field if the given value is not nil. +func (su *ShitpostUpdate) SetNillableCount(i *int) *ShitpostUpdate { + if i != nil { + su.SetCount(*i) + } + return su +} + // AddCount adds i to the "count" field. func (su *ShitpostUpdate) AddCount(i int) *ShitpostUpdate { su.mutation.AddCount(i) @@ -79,7 +95,7 @@ func (su *ShitpostUpdate) ClearUser() *ShitpostUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (su *ShitpostUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, ShitpostMutation](ctx, su.sqlSave, su.mutation, su.hooks) + return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -190,6 +206,14 @@ func (suo *ShitpostUpdateOne) SetChannelID(s string) *ShitpostUpdateOne { return suo } +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (suo *ShitpostUpdateOne) SetNillableChannelID(s *string) *ShitpostUpdateOne { + if s != nil { + suo.SetChannelID(*s) + } + return suo +} + // SetCount sets the "count" field. func (suo *ShitpostUpdateOne) SetCount(i int) *ShitpostUpdateOne { suo.mutation.ResetCount() @@ -197,6 +221,14 @@ func (suo *ShitpostUpdateOne) SetCount(i int) *ShitpostUpdateOne { return suo } +// SetNillableCount sets the "count" field if the given value is not nil. +func (suo *ShitpostUpdateOne) SetNillableCount(i *int) *ShitpostUpdateOne { + if i != nil { + suo.SetCount(*i) + } + return suo +} + // AddCount adds i to the "count" field. func (suo *ShitpostUpdateOne) AddCount(i int) *ShitpostUpdateOne { suo.mutation.AddCount(i) @@ -248,7 +280,7 @@ func (suo *ShitpostUpdateOne) Select(field string, fields ...string) *ShitpostUp // Save executes the query and returns the updated Shitpost entity. func (suo *ShitpostUpdateOne) Save(ctx context.Context) (*Shitpost, error) { - return withHooks[*Shitpost, ShitpostMutation](ctx, suo.sqlSave, suo.mutation, suo.hooks) + return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/ent/signin.go b/ent/signin.go index dbb013c..1cf9f10 100644 --- a/ent/signin.go +++ b/ent/signin.go @@ -41,12 +41,10 @@ type SigninEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e SigninEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/ent/signin/where.go b/ent/signin/where.go index 63e6104..9ae1213 100644 --- a/ent/signin/where.go +++ b/ent/signin/where.go @@ -145,32 +145,15 @@ func HasUserWith(preds ...predicate.User) predicate.Signin { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Signin) predicate.Signin { - return predicate.Signin(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Signin(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Signin) predicate.Signin { - return predicate.Signin(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Signin(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Signin) predicate.Signin { - return predicate.Signin(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Signin(sql.NotPredicates(p)) } diff --git a/ent/signin_create.go b/ent/signin_create.go index 31ecf37..914325a 100644 --- a/ent/signin_create.go +++ b/ent/signin_create.go @@ -60,7 +60,7 @@ func (sc *SigninCreate) Mutation() *SigninMutation { // Save creates the Signin in the database. func (sc *SigninCreate) Save(ctx context.Context) (*Signin, error) { sc.defaults() - return withHooks[*Signin, SigninMutation](ctx, sc.sqlSave, sc.mutation, sc.hooks) + return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -106,7 +106,7 @@ func (sc *SigninCreate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Signin.type": %w`, err)} } } - if _, ok := sc.mutation.UserID(); !ok { + if len(sc.mutation.UserIDs()) == 0 { return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Signin.user"`)} } return nil @@ -166,11 +166,15 @@ func (sc *SigninCreate) createSpec() (*Signin, *sqlgraph.CreateSpec) { // SigninCreateBulk is the builder for creating many Signin entities in bulk. type SigninCreateBulk struct { config + err error builders []*SigninCreate } // Save creates the Signin entities in the database. func (scb *SigninCreateBulk) Save(ctx context.Context) ([]*Signin, error) { + if scb.err != nil { + return nil, scb.err + } specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) nodes := make([]*Signin, len(scb.builders)) mutators := make([]Mutator, len(scb.builders)) diff --git a/ent/signin_delete.go b/ent/signin_delete.go index 19df342..bdd4efd 100644 --- a/ent/signin_delete.go +++ b/ent/signin_delete.go @@ -27,7 +27,7 @@ func (sd *SigninDelete) Where(ps ...predicate.Signin) *SigninDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (sd *SigninDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, SigninMutation](ctx, sd.sqlExec, sd.mutation, sd.hooks) + return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/ent/signin_query.go b/ent/signin_query.go index 6e7719d..8593fd2 100644 --- a/ent/signin_query.go +++ b/ent/signin_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -85,7 +86,7 @@ func (sq *SigninQuery) QueryUser() *UserQuery { // First returns the first Signin entity from the query. // Returns a *NotFoundError when no Signin was found. func (sq *SigninQuery) First(ctx context.Context) (*Signin, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -108,7 +109,7 @@ func (sq *SigninQuery) FirstX(ctx context.Context) *Signin { // Returns a *NotFoundError when no Signin ID was found. func (sq *SigninQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -131,7 +132,7 @@ func (sq *SigninQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Signin entity is found. // Returns a *NotFoundError when no Signin entities are found. func (sq *SigninQuery) Only(ctx context.Context) (*Signin, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -159,7 +160,7 @@ func (sq *SigninQuery) OnlyX(ctx context.Context) *Signin { // Returns a *NotFoundError when no entities are found. func (sq *SigninQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -184,7 +185,7 @@ func (sq *SigninQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Signins. func (sq *SigninQuery) All(ctx context.Context) ([]*Signin, error) { - ctx = setContextOp(ctx, sq.ctx, "All") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryAll) if err := sq.prepareQuery(ctx); err != nil { return nil, err } @@ -206,7 +207,7 @@ func (sq *SigninQuery) IDs(ctx context.Context) (ids []int, err error) { if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } - ctx = setContextOp(ctx, sq.ctx, "IDs") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryIDs) if err = sq.Select(signin.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -224,7 +225,7 @@ func (sq *SigninQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (sq *SigninQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryCount) if err := sq.prepareQuery(ctx); err != nil { return 0, err } @@ -242,7 +243,7 @@ func (sq *SigninQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (sq *SigninQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryExist) switch _, err := sq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -536,7 +537,7 @@ func (sgb *SigninGroupBy) Aggregate(fns ...AggregateFunc) *SigninGroupBy { // Scan applies the selector query and scans the result into the given value. func (sgb *SigninGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, sgb.build.ctx, ent.OpQueryGroupBy) if err := sgb.build.prepareQuery(ctx); err != nil { return err } @@ -584,7 +585,7 @@ func (ss *SigninSelect) Aggregate(fns ...AggregateFunc) *SigninSelect { // Scan applies the selector query and scans the result into the given value. func (ss *SigninSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") + ctx = setContextOp(ctx, ss.ctx, ent.OpQuerySelect) if err := ss.prepareQuery(ctx); err != nil { return err } diff --git a/ent/signin_update.go b/ent/signin_update.go index dc1814b..51c3307 100644 --- a/ent/signin_update.go +++ b/ent/signin_update.go @@ -49,6 +49,14 @@ func (su *SigninUpdate) SetType(s signin.Type) *SigninUpdate { return su } +// SetNillableType sets the "type" field if the given value is not nil. +func (su *SigninUpdate) SetNillableType(s *signin.Type) *SigninUpdate { + if s != nil { + su.SetType(*s) + } + return su +} + // SetUserID sets the "user" edge to the User entity by ID. func (su *SigninUpdate) SetUserID(id string) *SigninUpdate { su.mutation.SetUserID(id) @@ -73,7 +81,7 @@ func (su *SigninUpdate) ClearUser() *SigninUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (su *SigninUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, SigninMutation](ctx, su.sqlSave, su.mutation, su.hooks) + return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -105,7 +113,7 @@ func (su *SigninUpdate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Signin.type": %w`, err)} } } - if _, ok := su.mutation.UserID(); su.mutation.UserCleared() && !ok { + if su.mutation.UserCleared() && len(su.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Signin.user"`) } return nil @@ -198,6 +206,14 @@ func (suo *SigninUpdateOne) SetType(s signin.Type) *SigninUpdateOne { return suo } +// SetNillableType sets the "type" field if the given value is not nil. +func (suo *SigninUpdateOne) SetNillableType(s *signin.Type) *SigninUpdateOne { + if s != nil { + suo.SetType(*s) + } + return suo +} + // SetUserID sets the "user" edge to the User entity by ID. func (suo *SigninUpdateOne) SetUserID(id string) *SigninUpdateOne { suo.mutation.SetUserID(id) @@ -235,7 +251,7 @@ func (suo *SigninUpdateOne) Select(field string, fields ...string) *SigninUpdate // Save executes the query and returns the updated Signin entity. func (suo *SigninUpdateOne) Save(ctx context.Context) (*Signin, error) { - return withHooks[*Signin, SigninMutation](ctx, suo.sqlSave, suo.mutation, suo.hooks) + return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -267,7 +283,7 @@ func (suo *SigninUpdateOne) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Signin.type": %w`, err)} } } - if _, ok := suo.mutation.UserID(); suo.mutation.UserCleared() && !ok { + if suo.mutation.UserCleared() && len(suo.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Signin.user"`) } return nil diff --git a/ent/user.go b/ent/user.go index 45bba09..1033bce 100644 --- a/ent/user.go +++ b/ent/user.go @@ -75,12 +75,10 @@ func (e UserEdges) ShitpostsOrErr() ([]*Shitpost, error) { // BirthdayOrErr returns the Birthday value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserEdges) BirthdayOrErr() (*Birthday, error) { - if e.loadedTypes[3] { - if e.Birthday == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: birthday.Label} - } + if e.Birthday != nil { return e.Birthday, nil + } else if e.loadedTypes[3] { + return nil, &NotFoundError{label: birthday.Label} } return nil, &NotLoadedError{edge: "birthday"} } diff --git a/ent/user/where.go b/ent/user/where.go index 61a2c91..972fbc4 100644 --- a/ent/user/where.go +++ b/ent/user/where.go @@ -287,32 +287,15 @@ func HasBirthdayWith(preds ...predicate.Birthday) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/ent/user_create.go b/ent/user_create.go index 1983877..42dbbf2 100644 --- a/ent/user_create.go +++ b/ent/user_create.go @@ -143,7 +143,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { uc.defaults() - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -322,11 +322,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/ent/user_delete.go b/ent/user_delete.go index 1ebe617..3d40406 100644 --- a/ent/user_delete.go +++ b/ent/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/ent/user_query.go b/ent/user_query.go index 8748cc9..06d6a7c 100644 --- a/ent/user_query.go +++ b/ent/user_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -157,7 +158,7 @@ func (uq *UserQuery) QueryBirthday() *BirthdayQuery { // First returns the first User entity from the query. // Returns a *NotFoundError when no User was found. func (uq *UserQuery) First(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First")) + nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -180,7 +181,7 @@ func (uq *UserQuery) FirstX(ctx context.Context) *User { // Returns a *NotFoundError when no User ID was found. func (uq *UserQuery) FirstID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil { + if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -203,7 +204,7 @@ func (uq *UserQuery) FirstIDX(ctx context.Context) string { // Returns a *NotSingularError when more than one User entity is found. // Returns a *NotFoundError when no User entities are found. func (uq *UserQuery) Only(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only")) + nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -231,7 +232,7 @@ func (uq *UserQuery) OnlyX(ctx context.Context) *User { // Returns a *NotFoundError when no entities are found. func (uq *UserQuery) OnlyID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil { + if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -256,7 +257,7 @@ func (uq *UserQuery) OnlyIDX(ctx context.Context) string { // All executes the query and returns a list of Users. func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { - ctx = setContextOp(ctx, uq.ctx, "All") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryAll) if err := uq.prepareQuery(ctx); err != nil { return nil, err } @@ -278,7 +279,7 @@ func (uq *UserQuery) IDs(ctx context.Context) (ids []string, err error) { if uq.ctx.Unique == nil && uq.path != nil { uq.Unique(true) } - ctx = setContextOp(ctx, uq.ctx, "IDs") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryIDs) if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -296,7 +297,7 @@ func (uq *UserQuery) IDsX(ctx context.Context) []string { // Count returns the count of the given query. func (uq *UserQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, uq.ctx, "Count") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryCount) if err := uq.prepareQuery(ctx); err != nil { return 0, err } @@ -314,7 +315,7 @@ func (uq *UserQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, uq.ctx, "Exist") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryExist) switch _, err := uq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -558,7 +559,7 @@ func (uq *UserQuery) loadSignins(ctx context.Context, query *SigninQuery, nodes } node, ok := nodeids[*fk] if !ok { - return fmt.Errorf(`unexpected foreign-key "user_signins" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "user_signins" returned %v for node %v`, *fk, n.ID) } assign(node, n) } @@ -589,7 +590,7 @@ func (uq *UserQuery) loadVotes(ctx context.Context, query *VoteQuery, nodes []*U } node, ok := nodeids[*fk] if !ok { - return fmt.Errorf(`unexpected foreign-key "user_votes" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "user_votes" returned %v for node %v`, *fk, n.ID) } assign(node, n) } @@ -620,7 +621,7 @@ func (uq *UserQuery) loadShitposts(ctx context.Context, query *ShitpostQuery, no } node, ok := nodeids[*fk] if !ok { - return fmt.Errorf(`unexpected foreign-key "user_shitposts" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "user_shitposts" returned %v for node %v`, *fk, n.ID) } assign(node, n) } @@ -648,7 +649,7 @@ func (uq *UserQuery) loadBirthday(ctx context.Context, query *BirthdayQuery, nod } node, ok := nodeids[*fk] if !ok { - return fmt.Errorf(`unexpected foreign-key "user_birthday" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "user_birthday" returned %v for node %v`, *fk, n.ID) } assign(node, n) } @@ -750,7 +751,7 @@ func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { // Scan applies the selector query and scans the result into the given value. func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, ugb.build.ctx, ent.OpQueryGroupBy) if err := ugb.build.prepareQuery(ctx); err != nil { return err } @@ -798,7 +799,7 @@ func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { // Scan applies the selector query and scans the result into the given value. func (us *UserSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, us.ctx, "Select") + ctx = setContextOp(ctx, us.ctx, ent.OpQuerySelect) if err := us.prepareQuery(ctx); err != nil { return err } diff --git a/ent/user_update.go b/ent/user_update.go index c45671e..c04a7a7 100644 --- a/ent/user_update.go +++ b/ent/user_update.go @@ -220,7 +220,7 @@ func (uu *UserUpdate) ClearBirthday() *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -665,7 +665,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/ent/vote.go b/ent/vote.go index df2e8b4..e96bd9d 100644 --- a/ent/vote.go +++ b/ent/vote.go @@ -42,12 +42,10 @@ type VoteEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e VoteEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/ent/vote/where.go b/ent/vote/where.go index 5143b55..f28953b 100644 --- a/ent/vote/where.go +++ b/ent/vote/where.go @@ -263,32 +263,15 @@ func HasUserWith(preds ...predicate.User) predicate.Vote { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Vote) predicate.Vote { - return predicate.Vote(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Vote(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Vote) predicate.Vote { - return predicate.Vote(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Vote(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Vote) predicate.Vote { - return predicate.Vote(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Vote(sql.NotPredicates(p)) } diff --git a/ent/vote_create.go b/ent/vote_create.go index 32adb4c..fd1fc81 100644 --- a/ent/vote_create.go +++ b/ent/vote_create.go @@ -56,7 +56,7 @@ func (vc *VoteCreate) Mutation() *VoteMutation { // Save creates the Vote in the database. func (vc *VoteCreate) Save(ctx context.Context) (*Vote, error) { - return withHooks[*Vote, VoteMutation](ctx, vc.sqlSave, vc.mutation, vc.hooks) + return withHooks(ctx, vc.sqlSave, vc.mutation, vc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -107,7 +107,7 @@ func (vc *VoteCreate) check() error { return &ValidationError{Name: "vote_id", err: fmt.Errorf(`ent: validator failed for field "Vote.vote_id": %w`, err)} } } - if _, ok := vc.mutation.UserID(); !ok { + if len(vc.mutation.UserIDs()) == 0 { return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Vote.user"`)} } return nil @@ -171,11 +171,15 @@ func (vc *VoteCreate) createSpec() (*Vote, *sqlgraph.CreateSpec) { // VoteCreateBulk is the builder for creating many Vote entities in bulk. type VoteCreateBulk struct { config + err error builders []*VoteCreate } // Save creates the Vote entities in the database. func (vcb *VoteCreateBulk) Save(ctx context.Context) ([]*Vote, error) { + if vcb.err != nil { + return nil, vcb.err + } specs := make([]*sqlgraph.CreateSpec, len(vcb.builders)) nodes := make([]*Vote, len(vcb.builders)) mutators := make([]Mutator, len(vcb.builders)) diff --git a/ent/vote_delete.go b/ent/vote_delete.go index cb4a88b..8be0828 100644 --- a/ent/vote_delete.go +++ b/ent/vote_delete.go @@ -27,7 +27,7 @@ func (vd *VoteDelete) Where(ps ...predicate.Vote) *VoteDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (vd *VoteDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, VoteMutation](ctx, vd.sqlExec, vd.mutation, vd.hooks) + return withHooks(ctx, vd.sqlExec, vd.mutation, vd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/ent/vote_query.go b/ent/vote_query.go index ebb340d..c362532 100644 --- a/ent/vote_query.go +++ b/ent/vote_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -85,7 +86,7 @@ func (vq *VoteQuery) QueryUser() *UserQuery { // First returns the first Vote entity from the query. // Returns a *NotFoundError when no Vote was found. func (vq *VoteQuery) First(ctx context.Context) (*Vote, error) { - nodes, err := vq.Limit(1).All(setContextOp(ctx, vq.ctx, "First")) + nodes, err := vq.Limit(1).All(setContextOp(ctx, vq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -108,7 +109,7 @@ func (vq *VoteQuery) FirstX(ctx context.Context) *Vote { // Returns a *NotFoundError when no Vote ID was found. func (vq *VoteQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = vq.Limit(1).IDs(setContextOp(ctx, vq.ctx, "FirstID")); err != nil { + if ids, err = vq.Limit(1).IDs(setContextOp(ctx, vq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -131,7 +132,7 @@ func (vq *VoteQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Vote entity is found. // Returns a *NotFoundError when no Vote entities are found. func (vq *VoteQuery) Only(ctx context.Context) (*Vote, error) { - nodes, err := vq.Limit(2).All(setContextOp(ctx, vq.ctx, "Only")) + nodes, err := vq.Limit(2).All(setContextOp(ctx, vq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -159,7 +160,7 @@ func (vq *VoteQuery) OnlyX(ctx context.Context) *Vote { // Returns a *NotFoundError when no entities are found. func (vq *VoteQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = vq.Limit(2).IDs(setContextOp(ctx, vq.ctx, "OnlyID")); err != nil { + if ids, err = vq.Limit(2).IDs(setContextOp(ctx, vq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -184,7 +185,7 @@ func (vq *VoteQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Votes. func (vq *VoteQuery) All(ctx context.Context) ([]*Vote, error) { - ctx = setContextOp(ctx, vq.ctx, "All") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryAll) if err := vq.prepareQuery(ctx); err != nil { return nil, err } @@ -206,7 +207,7 @@ func (vq *VoteQuery) IDs(ctx context.Context) (ids []int, err error) { if vq.ctx.Unique == nil && vq.path != nil { vq.Unique(true) } - ctx = setContextOp(ctx, vq.ctx, "IDs") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryIDs) if err = vq.Select(vote.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -224,7 +225,7 @@ func (vq *VoteQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (vq *VoteQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, vq.ctx, "Count") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryCount) if err := vq.prepareQuery(ctx); err != nil { return 0, err } @@ -242,7 +243,7 @@ func (vq *VoteQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (vq *VoteQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, vq.ctx, "Exist") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryExist) switch _, err := vq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -536,7 +537,7 @@ func (vgb *VoteGroupBy) Aggregate(fns ...AggregateFunc) *VoteGroupBy { // Scan applies the selector query and scans the result into the given value. func (vgb *VoteGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, vgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, vgb.build.ctx, ent.OpQueryGroupBy) if err := vgb.build.prepareQuery(ctx); err != nil { return err } @@ -584,7 +585,7 @@ func (vs *VoteSelect) Aggregate(fns ...AggregateFunc) *VoteSelect { // Scan applies the selector query and scans the result into the given value. func (vs *VoteSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, vs.ctx, "Select") + ctx = setContextOp(ctx, vs.ctx, ent.OpQuerySelect) if err := vs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/vote_update.go b/ent/vote_update.go index 94810f4..530df1d 100644 --- a/ent/vote_update.go +++ b/ent/vote_update.go @@ -34,6 +34,14 @@ func (vu *VoteUpdate) SetSelection(s string) *VoteUpdate { return vu } +// SetNillableSelection sets the "selection" field if the given value is not nil. +func (vu *VoteUpdate) SetNillableSelection(s *string) *VoteUpdate { + if s != nil { + vu.SetSelection(*s) + } + return vu +} + // SetRank sets the "rank" field. func (vu *VoteUpdate) SetRank(i int) *VoteUpdate { vu.mutation.ResetRank() @@ -41,6 +49,14 @@ func (vu *VoteUpdate) SetRank(i int) *VoteUpdate { return vu } +// SetNillableRank sets the "rank" field if the given value is not nil. +func (vu *VoteUpdate) SetNillableRank(i *int) *VoteUpdate { + if i != nil { + vu.SetRank(*i) + } + return vu +} + // AddRank adds i to the "rank" field. func (vu *VoteUpdate) AddRank(i int) *VoteUpdate { vu.mutation.AddRank(i) @@ -53,6 +69,14 @@ func (vu *VoteUpdate) SetVoteID(s string) *VoteUpdate { return vu } +// SetNillableVoteID sets the "vote_id" field if the given value is not nil. +func (vu *VoteUpdate) SetNillableVoteID(s *string) *VoteUpdate { + if s != nil { + vu.SetVoteID(*s) + } + return vu +} + // SetUserID sets the "user" edge to the User entity by ID. func (vu *VoteUpdate) SetUserID(id string) *VoteUpdate { vu.mutation.SetUserID(id) @@ -77,7 +101,7 @@ func (vu *VoteUpdate) ClearUser() *VoteUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (vu *VoteUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, VoteMutation](ctx, vu.sqlSave, vu.mutation, vu.hooks) + return withHooks(ctx, vu.sqlSave, vu.mutation, vu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -119,7 +143,7 @@ func (vu *VoteUpdate) check() error { return &ValidationError{Name: "vote_id", err: fmt.Errorf(`ent: validator failed for field "Vote.vote_id": %w`, err)} } } - if _, ok := vu.mutation.UserID(); vu.mutation.UserCleared() && !ok { + if vu.mutation.UserCleared() && len(vu.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Vote.user"`) } return nil @@ -204,6 +228,14 @@ func (vuo *VoteUpdateOne) SetSelection(s string) *VoteUpdateOne { return vuo } +// SetNillableSelection sets the "selection" field if the given value is not nil. +func (vuo *VoteUpdateOne) SetNillableSelection(s *string) *VoteUpdateOne { + if s != nil { + vuo.SetSelection(*s) + } + return vuo +} + // SetRank sets the "rank" field. func (vuo *VoteUpdateOne) SetRank(i int) *VoteUpdateOne { vuo.mutation.ResetRank() @@ -211,6 +243,14 @@ func (vuo *VoteUpdateOne) SetRank(i int) *VoteUpdateOne { return vuo } +// SetNillableRank sets the "rank" field if the given value is not nil. +func (vuo *VoteUpdateOne) SetNillableRank(i *int) *VoteUpdateOne { + if i != nil { + vuo.SetRank(*i) + } + return vuo +} + // AddRank adds i to the "rank" field. func (vuo *VoteUpdateOne) AddRank(i int) *VoteUpdateOne { vuo.mutation.AddRank(i) @@ -223,6 +263,14 @@ func (vuo *VoteUpdateOne) SetVoteID(s string) *VoteUpdateOne { return vuo } +// SetNillableVoteID sets the "vote_id" field if the given value is not nil. +func (vuo *VoteUpdateOne) SetNillableVoteID(s *string) *VoteUpdateOne { + if s != nil { + vuo.SetVoteID(*s) + } + return vuo +} + // SetUserID sets the "user" edge to the User entity by ID. func (vuo *VoteUpdateOne) SetUserID(id string) *VoteUpdateOne { vuo.mutation.SetUserID(id) @@ -260,7 +308,7 @@ func (vuo *VoteUpdateOne) Select(field string, fields ...string) *VoteUpdateOne // Save executes the query and returns the updated Vote entity. func (vuo *VoteUpdateOne) Save(ctx context.Context) (*Vote, error) { - return withHooks[*Vote, VoteMutation](ctx, vuo.sqlSave, vuo.mutation, vuo.hooks) + return withHooks(ctx, vuo.sqlSave, vuo.mutation, vuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -302,7 +350,7 @@ func (vuo *VoteUpdateOne) check() error { return &ValidationError{Name: "vote_id", err: fmt.Errorf(`ent: validator failed for field "Vote.vote_id": %w`, err)} } } - if _, ok := vuo.mutation.UserID(); vuo.mutation.UserCleared() && !ok { + if vuo.mutation.UserCleared() && len(vuo.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Vote.user"`) } return nil diff --git a/ent/voteresult/where.go b/ent/voteresult/where.go index d6abb2f..005a4ae 100644 --- a/ent/voteresult/where.go +++ b/ent/voteresult/where.go @@ -264,32 +264,15 @@ func VoteIDContainsFold(v string) predicate.VoteResult { // And groups predicates with the AND operator between them. func And(predicates ...predicate.VoteResult) predicate.VoteResult { - return predicate.VoteResult(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VoteResult(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.VoteResult) predicate.VoteResult { - return predicate.VoteResult(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VoteResult(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.VoteResult) predicate.VoteResult { - return predicate.VoteResult(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.VoteResult(sql.NotPredicates(p)) } diff --git a/ent/voteresult_create.go b/ent/voteresult_create.go index 6b70b8a..b6bd663 100644 --- a/ent/voteresult_create.go +++ b/ent/voteresult_create.go @@ -44,7 +44,7 @@ func (vrc *VoteResultCreate) Mutation() *VoteResultMutation { // Save creates the VoteResult in the database. func (vrc *VoteResultCreate) Save(ctx context.Context) (*VoteResult, error) { - return withHooks[*VoteResult, VoteResultMutation](ctx, vrc.sqlSave, vrc.mutation, vrc.hooks) + return withHooks(ctx, vrc.sqlSave, vrc.mutation, vrc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -129,11 +129,15 @@ func (vrc *VoteResultCreate) createSpec() (*VoteResult, *sqlgraph.CreateSpec) { // VoteResultCreateBulk is the builder for creating many VoteResult entities in bulk. type VoteResultCreateBulk struct { config + err error builders []*VoteResultCreate } // Save creates the VoteResult entities in the database. func (vrcb *VoteResultCreateBulk) Save(ctx context.Context) ([]*VoteResult, error) { + if vrcb.err != nil { + return nil, vrcb.err + } specs := make([]*sqlgraph.CreateSpec, len(vrcb.builders)) nodes := make([]*VoteResult, len(vrcb.builders)) mutators := make([]Mutator, len(vrcb.builders)) diff --git a/ent/voteresult_delete.go b/ent/voteresult_delete.go index db68289..04030cf 100644 --- a/ent/voteresult_delete.go +++ b/ent/voteresult_delete.go @@ -27,7 +27,7 @@ func (vrd *VoteResultDelete) Where(ps ...predicate.VoteResult) *VoteResultDelete // Exec executes the deletion query and returns how many vertices were deleted. func (vrd *VoteResultDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, VoteResultMutation](ctx, vrd.sqlExec, vrd.mutation, vrd.hooks) + return withHooks(ctx, vrd.sqlExec, vrd.mutation, vrd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/ent/voteresult_query.go b/ent/voteresult_query.go index 0455ce9..42d8f1c 100644 --- a/ent/voteresult_query.go +++ b/ent/voteresult_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (vrq *VoteResultQuery) Order(o ...voteresult.OrderOption) *VoteResultQuery // First returns the first VoteResult entity from the query. // Returns a *NotFoundError when no VoteResult was found. func (vrq *VoteResultQuery) First(ctx context.Context) (*VoteResult, error) { - nodes, err := vrq.Limit(1).All(setContextOp(ctx, vrq.ctx, "First")) + nodes, err := vrq.Limit(1).All(setContextOp(ctx, vrq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (vrq *VoteResultQuery) FirstX(ctx context.Context) *VoteResult { // Returns a *NotFoundError when no VoteResult ID was found. func (vrq *VoteResultQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = vrq.Limit(1).IDs(setContextOp(ctx, vrq.ctx, "FirstID")); err != nil { + if ids, err = vrq.Limit(1).IDs(setContextOp(ctx, vrq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (vrq *VoteResultQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one VoteResult entity is found. // Returns a *NotFoundError when no VoteResult entities are found. func (vrq *VoteResultQuery) Only(ctx context.Context) (*VoteResult, error) { - nodes, err := vrq.Limit(2).All(setContextOp(ctx, vrq.ctx, "Only")) + nodes, err := vrq.Limit(2).All(setContextOp(ctx, vrq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (vrq *VoteResultQuery) OnlyX(ctx context.Context) *VoteResult { // Returns a *NotFoundError when no entities are found. func (vrq *VoteResultQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = vrq.Limit(2).IDs(setContextOp(ctx, vrq.ctx, "OnlyID")); err != nil { + if ids, err = vrq.Limit(2).IDs(setContextOp(ctx, vrq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (vrq *VoteResultQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of VoteResults. func (vrq *VoteResultQuery) All(ctx context.Context) ([]*VoteResult, error) { - ctx = setContextOp(ctx, vrq.ctx, "All") + ctx = setContextOp(ctx, vrq.ctx, ent.OpQueryAll) if err := vrq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (vrq *VoteResultQuery) IDs(ctx context.Context) (ids []int, err error) { if vrq.ctx.Unique == nil && vrq.path != nil { vrq.Unique(true) } - ctx = setContextOp(ctx, vrq.ctx, "IDs") + ctx = setContextOp(ctx, vrq.ctx, ent.OpQueryIDs) if err = vrq.Select(voteresult.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (vrq *VoteResultQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (vrq *VoteResultQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, vrq.ctx, "Count") + ctx = setContextOp(ctx, vrq.ctx, ent.OpQueryCount) if err := vrq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (vrq *VoteResultQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (vrq *VoteResultQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, vrq.ctx, "Exist") + ctx = setContextOp(ctx, vrq.ctx, ent.OpQueryExist) switch _, err := vrq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (vrgb *VoteResultGroupBy) Aggregate(fns ...AggregateFunc) *VoteResultGroupB // Scan applies the selector query and scans the result into the given value. func (vrgb *VoteResultGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, vrgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, vrgb.build.ctx, ent.OpQueryGroupBy) if err := vrgb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (vrs *VoteResultSelect) Aggregate(fns ...AggregateFunc) *VoteResultSelect { // Scan applies the selector query and scans the result into the given value. func (vrs *VoteResultSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, vrs.ctx, "Select") + ctx = setContextOp(ctx, vrs.ctx, ent.OpQuerySelect) if err := vrs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/voteresult_update.go b/ent/voteresult_update.go index 3a7a54a..7ff8717 100644 --- a/ent/voteresult_update.go +++ b/ent/voteresult_update.go @@ -33,18 +33,42 @@ func (vru *VoteResultUpdate) SetHTML(s string) *VoteResultUpdate { return vru } +// SetNillableHTML sets the "html" field if the given value is not nil. +func (vru *VoteResultUpdate) SetNillableHTML(s *string) *VoteResultUpdate { + if s != nil { + vru.SetHTML(*s) + } + return vru +} + // SetPlain sets the "plain" field. func (vru *VoteResultUpdate) SetPlain(s string) *VoteResultUpdate { vru.mutation.SetPlain(s) return vru } +// SetNillablePlain sets the "plain" field if the given value is not nil. +func (vru *VoteResultUpdate) SetNillablePlain(s *string) *VoteResultUpdate { + if s != nil { + vru.SetPlain(*s) + } + return vru +} + // SetVoteID sets the "vote_id" field. func (vru *VoteResultUpdate) SetVoteID(s string) *VoteResultUpdate { vru.mutation.SetVoteID(s) return vru } +// SetNillableVoteID sets the "vote_id" field if the given value is not nil. +func (vru *VoteResultUpdate) SetNillableVoteID(s *string) *VoteResultUpdate { + if s != nil { + vru.SetVoteID(*s) + } + return vru +} + // Mutation returns the VoteResultMutation object of the builder. func (vru *VoteResultUpdate) Mutation() *VoteResultMutation { return vru.mutation @@ -52,7 +76,7 @@ func (vru *VoteResultUpdate) Mutation() *VoteResultMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (vru *VoteResultUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, VoteResultMutation](ctx, vru.sqlSave, vru.mutation, vru.hooks) + return withHooks(ctx, vru.sqlSave, vru.mutation, vru.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -134,18 +158,42 @@ func (vruo *VoteResultUpdateOne) SetHTML(s string) *VoteResultUpdateOne { return vruo } +// SetNillableHTML sets the "html" field if the given value is not nil. +func (vruo *VoteResultUpdateOne) SetNillableHTML(s *string) *VoteResultUpdateOne { + if s != nil { + vruo.SetHTML(*s) + } + return vruo +} + // SetPlain sets the "plain" field. func (vruo *VoteResultUpdateOne) SetPlain(s string) *VoteResultUpdateOne { vruo.mutation.SetPlain(s) return vruo } +// SetNillablePlain sets the "plain" field if the given value is not nil. +func (vruo *VoteResultUpdateOne) SetNillablePlain(s *string) *VoteResultUpdateOne { + if s != nil { + vruo.SetPlain(*s) + } + return vruo +} + // SetVoteID sets the "vote_id" field. func (vruo *VoteResultUpdateOne) SetVoteID(s string) *VoteResultUpdateOne { vruo.mutation.SetVoteID(s) return vruo } +// SetNillableVoteID sets the "vote_id" field if the given value is not nil. +func (vruo *VoteResultUpdateOne) SetNillableVoteID(s *string) *VoteResultUpdateOne { + if s != nil { + vruo.SetVoteID(*s) + } + return vruo +} + // Mutation returns the VoteResultMutation object of the builder. func (vruo *VoteResultUpdateOne) Mutation() *VoteResultMutation { return vruo.mutation @@ -166,7 +214,7 @@ func (vruo *VoteResultUpdateOne) Select(field string, fields ...string) *VoteRes // Save executes the query and returns the updated VoteResult entity. func (vruo *VoteResultUpdateOne) Save(ctx context.Context) (*VoteResult, error) { - return withHooks[*VoteResult, VoteResultMutation](ctx, vruo.sqlSave, vruo.mutation, vruo.hooks) + return withHooks(ctx, vruo.sqlSave, vruo.mutation, vruo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/go.mod b/go.mod index 25a278e..8954499 100644 --- a/go.mod +++ b/go.mod @@ -1,28 +1,49 @@ module github.com/ritsec/ops-bot-iii -go 1.20 +go 1.23.0 + +toolchain go1.23.1 require ( - entgo.io/ent v0.12.1 + entgo.io/ent v0.14.1 github.com/bwmarrin/discordgo v0.28.1 - github.com/fsnotify/fsnotify v1.6.0 - github.com/gin-gonic/gin v1.9.1 - github.com/google/uuid v1.3.0 - github.com/mackerelio/go-osstat v0.2.4 + github.com/fsnotify/fsnotify v1.8.0 + github.com/gin-gonic/gin v1.10.0 + github.com/google/uuid v1.6.0 + github.com/mackerelio/go-osstat v0.2.5 github.com/mailgun/mailgun-go v2.0.0+incompatible - github.com/mattn/go-sqlite3 v1.14.16 + github.com/mattn/go-sqlite3 v1.14.24 github.com/robfig/cron v1.2.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/viper v1.15.0 - golang.org/x/oauth2 v0.7.0 - google.golang.org/api v0.121.0 + golang.org/x/oauth2 v0.21.0 + google.golang.org/api v0.188.0 gopkg.in/DataDog/dd-trace-go.v1 v1.52.0 ) require ( - ariga.io/atlas v0.10.0 // indirect - cloud.google.com/go/compute v1.19.1 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/auth v0.7.0 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/tools v0.24.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) + +require ( + ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect + cloud.google.com/go/compute/metadata v0.4.0 // indirect github.com/DataDog/appsec-internal-go v1.0.0 // indirect github.com/DataDog/datadog-agent/pkg/obfuscate v0.45.0-rc.1 // indirect github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.45.0 // indirect @@ -32,74 +53,70 @@ require ( github.com/DataDog/sketches-go v1.2.1 // indirect github.com/Microsoft/go-winio v0.5.2 // indirect github.com/agext/levenshtein v1.2.1 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/bytedance/sonic v1.9.1 // indirect + github.com/bytedance/sonic v1.11.6 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gabriel-vasile/mimetype v1.4.6 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-openapi/inflect v0.19.0 // indirect + github.com/go-openapi/inflect v0.21.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/go-playground/validator/v10 v10.22.1 // indirect github.com/gobuffalo/envy v1.10.2 // indirect - github.com/goccy/go-json v0.10.2 // indirect + github.com/goccy/go-json v0.10.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/s2a-go v0.1.3 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect - github.com/googleapis/gax-go/v2 v2.8.0 // indirect - github.com/gorilla/websocket v1.5.1 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/hcl/v2 v2.13.0 // indirect - github.com/joho/godotenv v1.4.0 // indirect + github.com/google/s2a-go v0.1.8 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect + github.com/googleapis/gax-go/v2 v2.13.0 // indirect + github.com/gophercloud/gophercloud/v2 v2.2.0 + github.com/gorilla/websocket v1.5.3 // indirect + github.com/hashicorp/hcl v1.0.1-vault-7 // indirect + github.com/hashicorp/hcl/v2 v2.22.0 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/leodido/go-urn v1.2.4 // indirect + github.com/klauspost/cpuid/v2 v2.2.9 // indirect + github.com/leodido/go-urn v1.4.0 // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/gomega v1.27.6 // indirect - github.com/outcaste-io/ristretto v0.2.1 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/philhofer/fwd v1.1.1 // indirect + github.com/outcaste-io/ristretto v0.2.3 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect + github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect - github.com/secure-systems-lab/go-securesystemslib v0.6.0 // indirect - github.com/spf13/afero v1.9.3 // indirect - github.com/spf13/cast v1.5.0 // indirect + github.com/rogpeppe/go-internal v1.13.1 // indirect + github.com/secure-systems-lab/go-securesystemslib v0.8.0 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.7.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/subosito/gotenv v1.4.2 // indirect - github.com/tinylib/msgp v1.1.6 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/tinylib/msgp v1.2.4 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - github.com/zclconf/go-cty v1.8.0 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect + github.com/zclconf/go-cty v1.15.0 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/atomic v1.10.0 // indirect go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect - golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/mod v0.19.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/time v0.3.0 // indirect + golang.org/x/arch v0.8.0 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/mod v0.20.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 + golang.org/x/time v0.5.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/grpc v1.64.1 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect inet.af/netaddr v0.0.0-20220811202034-502d2d690317 // indirect diff --git a/go.sum b/go.sum index ba3363b..cf55955 100644 --- a/go.sum +++ b/go.sum @@ -1,54 +1,17 @@ -ariga.io/atlas v0.10.0 h1:B1aCP6gSDQET6j8ybn7m6MArjQuoLH5d4DQBT+NP5k8= -ariga.io/atlas v0.10.0/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk= +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14= +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= -cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -entgo.io/ent v0.12.1 h1:bqK+WMwfjpTsFiXx9tQSEZMNLyAADSx5Y1xySjT4Tm8= -entgo.io/ent v0.12.1/go.mod h1:OA1Y5bNE8EtlxKv4IyzWwt4jgvGbkoKMcwp668iEKQE= +cloud.google.com/go/auth v0.7.0 h1:kf/x9B3WTbBUHkC+1VS8wwwli9TzhSt0vSTVBmMR8Ts= +cloud.google.com/go/auth v0.7.0/go.mod h1:D+WqdrpcjmiCgWrXmLLxOVq1GACoE36chW6KXoEvuIw= +cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= +cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= +cloud.google.com/go/compute/metadata v0.4.0 h1:vHzJCWaM4g8XIcm8kopr3XmDA4Gy/lblD3EhhSux05c= +cloud.google.com/go/compute/metadata v0.4.0/go.mod h1:SIQh1Kkb4ZJ8zJ874fqVkslA29PRXuleyj6vOzlbK7M= +entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s= +entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/appsec-internal-go v1.0.0 h1:2u5IkF4DBj3KVeQn5Vg2vjPUtt513zxEYglcqnd500U= github.com/DataDog/appsec-internal-go v1.0.0/go.mod h1:+Y+4klVWKPOnZx6XESG7QHydOaUGEXyH2j/vSg9JiNM= github.com/DataDog/datadog-agent/pkg/obfuscate v0.45.0-rc.1 h1:XyYvstMFpSyZtfJHWJm1Sf1meNyCdfhKJrjB6+rUNOk= @@ -62,6 +25,7 @@ github.com/DataDog/go-libddwaf v1.2.0/go.mod h1:DI5y8obPajk+Tvy2o+nZc2g/5Ria/Rfq github.com/DataDog/go-tuf v0.3.0--fix-localmeta-fork h1:yBq5PrAtrM4yVeSzQ+bn050+Ysp++RKF1QmtkL4VqvU= github.com/DataDog/go-tuf v0.3.0--fix-localmeta-fork/go.mod h1:yA5JwkZsHTLuqq3zaRgUQf35DfDkpOZqgtBqHKpwrBs= github.com/DataDog/gostackparse v0.5.0 h1:jb72P6GFHPHz2W0onsN51cS3FkaMDcjb0QzgxxA4gDk= +github.com/DataDog/gostackparse v0.5.0/go.mod h1:lTfqcJKqS9KnXQGnyQMCugq3u1FP6UZMfWR0aitKFMM= github.com/DataDog/sketches-go v1.2.1 h1:qTBzWLnZ3kM2kw39ymh6rMcnN+5VULwFs++lEYUUsro= github.com/DataDog/sketches-go v1.2.1/go.mod h1:1xYmPLY1So10AwxV6MJV0J53XVH+WL9Ad1KetxVivVI= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= @@ -70,32 +34,27 @@ github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VM github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4= github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= +github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -108,9 +67,6 @@ github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= @@ -118,57 +74,51 @@ github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojt github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flynn/go-docopt v0.0.0-20140912013429-f6dd2ebbb31e/go.mod h1:HyVoz1Mz5Co8TFO8EupIdlcpwShBmY98dkT2xeHkvEI= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc= +github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= -github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= +github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= +github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-openapi/inflect v0.21.0 h1:FoBjBTQEcbg2cJUWX6uwL9OyIW8eqc9k4KhN4lfbeYk= +github.com/go-openapi/inflect v0.21.0/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= +github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gobuffalo/envy v1.10.2 h1:EIi03p9c3yeuRCFPOKcSfajzkLb3hrRjEpHGI8I2Wo4= github.com/gobuffalo/envy v1.10.2/go.mod h1:qGAGwdvDsaEtPhfBzb3o0SfDea8ByGn9j8bKmVft9z8= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -179,104 +129,74 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230509042627-b1315fad0c5a h1:PEOGDI1kkyW37YqPWHLHc+D20D9+87Wt12TCcfTUo5Q= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/s2a-go v0.1.3 h1:FAgZmpLl/SXurPEZyCMPBIiiYeTbqfjlbdnCNTAkbGE= -github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/pprof v0.0.0-20230509042627-b1315fad0c5a/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM= +github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= -github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.8.0 h1:UBtEZqx1bjXtOQ5BVTkuYghXrr3N4V123VKJK67vJZc= -github.com/googleapis/gax-go/v2 v2.8.0/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gTgghdIA6Stxb52D5RnLI1SLyw= +github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA= +github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s= +github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= +github.com/gophercloud/gophercloud/v2 v2.2.0 h1:STqqnSXuhcg1OPBOZ14z6JDm8fKIN13H2bJg6bBuHp8= +github.com/gophercloud/gophercloud/v2 v2.2.0/go.mod h1:f2hMRC7Kakbv5vM7wSGHrIPZh6JZR60GVHryJlF/K44= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= -github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/hcl v1.0.1-vault-7 h1:ag5OxFVy3QYTFTJODRzTKVZ6xvdfLLCA1cy/Y6xGI0I= +github.com/hashicorp/hcl v1.0.1-vault-7/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM= +github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= +github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= -github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= +github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs= -github.com/mackerelio/go-osstat v0.2.4/go.mod h1:Zy+qzGdZs3A9cuIqmgbJvwbmLQH9dJvtio5ZjJTbdlQ= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= +github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o= +github.com/mackerelio/go-osstat v0.2.5/go.mod h1:atxwWF+POUZcdtR1wnsUcQxTytoHG4uhl2AKKzrOajY= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailgun/mailgun-go v2.0.0+incompatible h1:0FoRHWwMUctnd8KIR3vtZbqdfjpIMxOZgcSa51s8F8o= github.com/mailgun/mailgun-go v2.0.0+incompatible/go.mod h1:NWTyU+O4aczg/nsGhQnvHL6v2n5Gy6Sv5tNDVvC6FbU= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= +github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -287,8 +207,6 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= @@ -303,40 +221,39 @@ github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5h github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/outcaste-io/ristretto v0.2.1 h1:KCItuNIGJZcursqHr3ghO7fc5ddZLEHspL9UR0cQM64= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/outcaste-io/ristretto v0.2.1/go.mod h1:W8HywhmtlopSB1jeMg3JtdIhf+DYkLAr0VN/s4+MHac= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= -github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ= -github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/outcaste-io/ristretto v0.2.3 h1:AK4zt/fJ76kjlYObOeNwh4T3asEuaCmp26pOvUOL9w0= +github.com/outcaste-io/ristretto v0.2.3/go.mod h1:W8HywhmtlopSB1jeMg3JtdIhf+DYkLAr0VN/s4+MHac= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= +github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY= +github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 h1:Qp27Idfgi6ACvFQat5+VJvlYToylpM/hcyLBI3WaKPA= +github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052/go.mod h1:uvX/8buq8uVeiZiFht+0lqSLBHF+uGV8BrTv8W/SIwk= github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/secure-systems-lab/go-securesystemslib v0.3.1/go.mod h1:o8hhjkbNl2gOamKUA/eNW3xUrntHT9L4W89W1nfj43U= -github.com/secure-systems-lab/go-securesystemslib v0.6.0 h1:T65atpAVCJQK14UA57LMdZGpHi4QYSH/9FZyNGqMYIA= -github.com/secure-systems-lab/go-securesystemslib v0.6.0/go.mod h1:8Mtpo9JKks/qhPG4HGZ2LGMvrPbzuxwfz/f/zLfEWkk= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA= +github.com/secure-systems-lab/go-securesystemslib v0.8.0/go.mod h1:UH2VZVuJfCYR8WgMlCU1uFsOUU+KeyrTWcSS73NBOzU= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= -github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= -github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -349,44 +266,39 @@ github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= -github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw= -github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= +github.com/tinylib/msgp v1.2.4 h1:yLFeUGostXXSGW5vxfT5dXG/qzkn4schv2I7at5+hVU= +github.com/tinylib/msgp v1.2.4/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= -github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= +github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= @@ -396,347 +308,125 @@ go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1: go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4= go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= +golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.121.0 h1:8Oopoo8Vavxx6gt+sgs8s8/X60WBAtKQq6JqnkF+xow= -google.golang.org/api v0.121.0/go.mod h1:gcitW0lvnyWjSp9nKxAbdHKIZ6vF4aajGueeslZOyms= +google.golang.org/api v0.188.0 h1:51y8fJ/b1AaaBRJr4yWm96fPcuxSo0JcegXE3DaHQHw= +google.golang.org/api v0.188.0/go.mod h1:VR0d+2SIiWOYG3r/jdm7adPW9hI2aRv9ETOSCQ9Beag= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto v0.0.0-20240708141625-4ad9e859172b h1:dSTjko30weBaMj3eERKc0ZVXW4GudCswM3m+P++ukU0= +google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY= +google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d h1:JU0iKnSg02Gmb5ZdV8nYsKEKsP6o/FGVWTrw4i1DA9A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= +google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -745,43 +435,33 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/DataDog/dd-trace-go.v1 v1.52.0 h1:9tzXTBnx/KX/fcPw096+z342qXoe+5OC1DFJ8rzytM0= gopkg.in/DataDog/dd-trace-go.v1 v1.52.0/go.mod h1:FqhnU6+gHoRGI2U/IJEJzM9lQa1rjecPHfAfwtAsbnw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= inet.af/netaddr v0.0.0-20220811202034-502d2d690317 h1:U2fwK6P2EqmopP/hFLTOAjWTki0qgd4GMJn5X8wOleU= inet.af/netaddr v0.0.0-20220811202034-502d2d690317/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/osclient/main.go b/osclient/main.go new file mode 100644 index 0000000..40da65d --- /dev/null +++ b/osclient/main.go @@ -0,0 +1,59 @@ +package osclient + +import ( + "context" + "log" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" + "github.com/gophercloud/gophercloud/v2/openstack/config" + "github.com/gophercloud/gophercloud/v2/openstack/config/clouds" + + OBIIIConfig "github.com/ritsec/ops-bot-iii/config" +) + +var ( + // networkClient is the global openstack identity client + identityClient *gophercloud.ServiceClient + networkClient *gophercloud.ServiceClient + storageClient *gophercloud.ServiceClient + computeClient *gophercloud.ServiceClient +) + +func init() { + ctx := context.Background() + ao, eo, tlsConfig, err := clouds.Parse(clouds.WithCloudName("openstack"), clouds.WithLocations(OBIIIConfig.Openstack.CloudsPath)) + if err != nil { + log.Fatalf("Failed to parse the clouds.yaml: %v", err) + } + + providerClient, err := config.NewProviderClient(ctx, ao, config.WithTLSConfig(tlsConfig)) + if err != nil { + log.Fatalf("Failed to make providerClient with NewProviderClient: %v", err) + } + + _identityClient, err := openstack.NewIdentityV3(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _identityClient with NewIdentityV3: %v", err) + } + + _networkClient, err := openstack.NewNetworkV2(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _networkClient with NewNetworkV2: %v", err) + } + + _storageClient, err := openstack.NewBlockStorageV3(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _storageClient with NewBlockStorageV3: %v", err) + } + + _computeClient, err := openstack.NewComputeV2(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _computeClient with NewComputeV2: %v", err) + } + + identityClient = _identityClient + networkClient = _networkClient + storageClient = _storageClient + computeClient = _computeClient +} diff --git a/osclient/user.go b/osclient/user.go new file mode 100644 index 0000000..15a6db2 --- /dev/null +++ b/osclient/user.go @@ -0,0 +1,204 @@ +package osclient + +import ( + "context" + "crypto/md5" + "fmt" + "math/rand" + "strings" + + "github.com/gophercloud/gophercloud/v2" + blockstorage "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v2/quotasets" + compute "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/quotasets" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/projects" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/roles" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/users" + network "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/quotas" + OBIIIConfig "github.com/ritsec/ops-bot-iii/config" +) + +// Returns the username portion of the email +func extractUsername(email string) string { + parts := strings.Split(email, "@") + if len(parts) > 0 { + return strings.ToLower(parts[0]) + } + return "" +} + +// Checks to see if the user exists on openstack +func CheckUserExists(email string) (bool, error) { + username := extractUsername(email) + + ctx := context.Background() + + listOpts := users.ListOpts{ + DomainID: "default", + } + + allPages, err := users.List(identityClient, listOpts).AllPages(ctx) + if err != nil { + return false, err + } + + allUsers, err := users.ExtractUsers(allPages) + if err != nil { + return false, err + } + + for _, user := range allUsers { + if user.Name == username { + return true, nil + } + } + + return false, nil +} + +// Returns a password that should be used temporary to create the account or resetting the account +func tempPass() string { + randomNumber := rand.Int() + hash := md5.Sum([]byte(fmt.Sprint(randomNumber))) + return fmt.Sprintf("%x", hash)[:24] +} + +// Creats the account on openstack and returns username and password for the user to get +func Create(email string) (string, string, error) { + ctx := context.Background() + username := extractUsername(email) + + // Create Project + createOpts := projects.CreateOpts{ + DomainID: "default", + Enabled: gophercloud.Enabled, + Name: username, + } + + project, err := projects.Create(ctx, identityClient, createOpts).Extract() + if err != nil { + return "", "", err + } + + networkOpts := network.UpdateOpts{ + FloatingIP: gophercloud.IntToPointer(0), + Network: gophercloud.IntToPointer(10), + Port: gophercloud.IntToPointer(50), + Router: gophercloud.IntToPointer(1), + Subnet: gophercloud.IntToPointer(20), + SecurityGroup: gophercloud.IntToPointer(10), + SecurityGroupRule: gophercloud.IntToPointer(-1), + } + + projectID := project.ID + _, err = network.Update(ctx, networkClient, projectID, networkOpts).Extract() + if err != nil { + return "", "", err + } + + quotaOpts := compute.UpdateOpts{ + InjectedFileContentBytes: gophercloud.IntToPointer(10240), + InjectedFilePathBytes: gophercloud.IntToPointer(255), + InjectedFiles: gophercloud.IntToPointer(5), + KeyPairs: gophercloud.IntToPointer(10), + RAM: gophercloud.IntToPointer(51200), + Cores: gophercloud.IntToPointer(20), + Instances: gophercloud.IntToPointer(10), + ServerGroups: gophercloud.IntToPointer(10), + ServerGroupMembers: gophercloud.IntToPointer(10), + } + + _, err = compute.Update(ctx, computeClient, projectID, quotaOpts).Extract() + if err != nil { + return "", "", err + } + + storageOpts := blockstorage.UpdateOpts{ + Volumes: gophercloud.IntToPointer(10), + Snapshots: gophercloud.IntToPointer(10), + Gigabytes: gophercloud.IntToPointer(250), + } + + _, err = blockstorage.Update(ctx, storageClient, projectID, storageOpts).Extract() + if err != nil { + return "", "", err + } + + password := tempPass() + userOpts := users.CreateOpts{ + Name: username, + DefaultProjectID: projectID, + Description: "", + DomainID: "default", + Enabled: gophercloud.Enabled, + Password: password, + Extra: map[string]any{ + "email": email, + }, + } + + user, err := users.Create(ctx, identityClient, userOpts).Extract() + if err != nil { + return "", "", err + } + + userID := user.ID + err = roles.Assign(ctx, identityClient, OBIIIConfig.Openstack.MemberID, roles.AssignOpts{ + UserID: userID, + ProjectID: projectID, + }).ExtractErr() + if err != nil { + return "", "", err + } + + return username, password, nil +} + +// Resets the account's password and returns the new temporary password for the user to login and change +func Reset(email string) (string, string, error) { + ctx := context.Background() + + userID, err := GetUserID(email) + if err != nil { + return "", "", err + } + + newPassword := tempPass() + + changePasswordOpts := users.UpdateOpts{ + Password: newPassword, + } + + _, err = users.Update(ctx, identityClient, userID, changePasswordOpts).Extract() + if err != nil { + return "", "", err + } + + return extractUsername(email), newPassword, nil +} + +func GetUserID(email string) (string, error) { + ctx := context.Background() + username := extractUsername(email) + + listOpts := users.ListOpts{ + DomainID: "default", + } + + allPages, err := users.List(identityClient, listOpts).AllPages(ctx) + if err != nil { + return "", err + } + + allUsers, err := users.ExtractUsers(allPages) + if err != nil { + return "", err + } + + for _, user := range allUsers { + if user.Name == username { + return user.ID, nil + } + } + + return "", fmt.Errorf("User ID not found") +} diff --git a/structs/openstack.go b/structs/openstack.go new file mode 100644 index 0000000..07f4233 --- /dev/null +++ b/structs/openstack.go @@ -0,0 +1,13 @@ +package structs + +// OpenstackConfig is the config for Openstack +type OpenstackConfig struct { + // Enabled is whether or not openstack self-service is enabled + Enabled bool + + // MemberID is the ID of the default role Member + MemberID string + + // CloudsPath is the path to the Clouds.yaml that includes the password + CloudsPath string +} From 703196dac128ea9299870cd20565cdaff062fe9d Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Tue, 26 Nov 2024 09:58:24 -0500 Subject: [PATCH 31/49] Added comments and used the enabled option from config --- osclient/main.go | 72 +++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/osclient/main.go b/osclient/main.go index 40da65d..fdea87f 100644 --- a/osclient/main.go +++ b/osclient/main.go @@ -20,40 +20,44 @@ var ( computeClient *gophercloud.ServiceClient ) +// Init() will make the clients during the compile func init() { - ctx := context.Background() - ao, eo, tlsConfig, err := clouds.Parse(clouds.WithCloudName("openstack"), clouds.WithLocations(OBIIIConfig.Openstack.CloudsPath)) - if err != nil { - log.Fatalf("Failed to parse the clouds.yaml: %v", err) + // Checks to see if the config has the Openstack enabled option enabled + if OBIIIConfig.Openstack.Enabled { + ctx := context.Background() + ao, eo, tlsConfig, err := clouds.Parse(clouds.WithCloudName("openstack"), clouds.WithLocations(OBIIIConfig.Openstack.CloudsPath)) + if err != nil { + log.Fatalf("Failed to parse the clouds.yaml: %v", err) + } + + providerClient, err := config.NewProviderClient(ctx, ao, config.WithTLSConfig(tlsConfig)) + if err != nil { + log.Fatalf("Failed to make providerClient with NewProviderClient: %v", err) + } + + _identityClient, err := openstack.NewIdentityV3(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _identityClient with NewIdentityV3: %v", err) + } + + _networkClient, err := openstack.NewNetworkV2(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _networkClient with NewNetworkV2: %v", err) + } + + _storageClient, err := openstack.NewBlockStorageV3(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _storageClient with NewBlockStorageV3: %v", err) + } + + _computeClient, err := openstack.NewComputeV2(providerClient, eo) + if err != nil { + log.Fatalf("Failed to make _computeClient with NewComputeV2: %v", err) + } + + identityClient = _identityClient + networkClient = _networkClient + storageClient = _storageClient + computeClient = _computeClient } - - providerClient, err := config.NewProviderClient(ctx, ao, config.WithTLSConfig(tlsConfig)) - if err != nil { - log.Fatalf("Failed to make providerClient with NewProviderClient: %v", err) - } - - _identityClient, err := openstack.NewIdentityV3(providerClient, eo) - if err != nil { - log.Fatalf("Failed to make _identityClient with NewIdentityV3: %v", err) - } - - _networkClient, err := openstack.NewNetworkV2(providerClient, eo) - if err != nil { - log.Fatalf("Failed to make _networkClient with NewNetworkV2: %v", err) - } - - _storageClient, err := openstack.NewBlockStorageV3(providerClient, eo) - if err != nil { - log.Fatalf("Failed to make _storageClient with NewBlockStorageV3: %v", err) - } - - _computeClient, err := openstack.NewComputeV2(providerClient, eo) - if err != nil { - log.Fatalf("Failed to make _computeClient with NewComputeV2: %v", err) - } - - identityClient = _identityClient - networkClient = _networkClient - storageClient = _storageClient - computeClient = _computeClient } From 5e672591b289955323be2d634e639a993fc58f7a Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Tue, 26 Nov 2024 10:00:18 -0500 Subject: [PATCH 32/49] lowered the string that Errorf was unhappy with --- osclient/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osclient/user.go b/osclient/user.go index 15a6db2..828dad9 100644 --- a/osclient/user.go +++ b/osclient/user.go @@ -200,5 +200,5 @@ func GetUserID(email string) (string, error) { } } - return "", fmt.Errorf("User ID not found") + return "", fmt.Errorf("user id not found") } From 80a2ef3041a033f8e8cbd469e312e9b57fba5ef0 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 00:14:39 -0500 Subject: [PATCH 33/49] ent go generate ./... --- ent/client.go | 181 ++++++++++- ent/ent.go | 2 + ent/hook/hook.go | 12 + ent/migrate/schema.go | 22 ++ ent/mutation.go | 460 ++++++++++++++++++++++++++- ent/openstack.go | 143 +++++++++ ent/openstack/openstack.go | 89 ++++++ ent/openstack/where.go | 139 +++++++++ ent/openstack_create.go | 239 +++++++++++++++ ent/openstack_delete.go | 88 ++++++ ent/openstack_query.go | 614 +++++++++++++++++++++++++++++++++++++ ent/openstack_update.go | 319 +++++++++++++++++++ ent/predicate/predicate.go | 3 + ent/runtime.go | 7 + ent/tx.go | 3 + ent/user.go | 21 +- ent/user/user.go | 23 ++ ent/user/where.go | 23 ++ ent/user_create.go | 36 +++ ent/user_query.go | 73 ++++- ent/user_update.go | 109 +++++++ 21 files changed, 2597 insertions(+), 9 deletions(-) create mode 100644 ent/openstack.go create mode 100644 ent/openstack/openstack.go create mode 100644 ent/openstack/where.go create mode 100644 ent/openstack_create.go create mode 100644 ent/openstack_delete.go create mode 100644 ent/openstack_query.go create mode 100644 ent/openstack_update.go diff --git a/ent/client.go b/ent/client.go index 9886986..ed342a0 100644 --- a/ent/client.go +++ b/ent/client.go @@ -16,6 +16,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/shitpost" "github.com/ritsec/ops-bot-iii/ent/signin" "github.com/ritsec/ops-bot-iii/ent/user" @@ -30,6 +31,8 @@ type Client struct { Schema *migrate.Schema // Birthday is the client for interacting with the Birthday builders. Birthday *BirthdayClient + // Openstack is the client for interacting with the Openstack builders. + Openstack *OpenstackClient // Shitpost is the client for interacting with the Shitpost builders. Shitpost *ShitpostClient // Signin is the client for interacting with the Signin builders. @@ -52,6 +55,7 @@ func NewClient(opts ...Option) *Client { func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Birthday = NewBirthdayClient(c.config) + c.Openstack = NewOpenstackClient(c.config) c.Shitpost = NewShitpostClient(c.config) c.Signin = NewSigninClient(c.config) c.User = NewUserClient(c.config) @@ -150,6 +154,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { ctx: ctx, config: cfg, Birthday: NewBirthdayClient(cfg), + Openstack: NewOpenstackClient(cfg), Shitpost: NewShitpostClient(cfg), Signin: NewSigninClient(cfg), User: NewUserClient(cfg), @@ -175,6 +180,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) ctx: ctx, config: cfg, Birthday: NewBirthdayClient(cfg), + Openstack: NewOpenstackClient(cfg), Shitpost: NewShitpostClient(cfg), Signin: NewSigninClient(cfg), User: NewUserClient(cfg), @@ -209,7 +215,7 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Birthday, c.Shitpost, c.Signin, c.User, c.Vote, c.VoteResult, + c.Birthday, c.Openstack, c.Shitpost, c.Signin, c.User, c.Vote, c.VoteResult, } { n.Use(hooks...) } @@ -219,7 +225,7 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Birthday, c.Shitpost, c.Signin, c.User, c.Vote, c.VoteResult, + c.Birthday, c.Openstack, c.Shitpost, c.Signin, c.User, c.Vote, c.VoteResult, } { n.Intercept(interceptors...) } @@ -230,6 +236,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { case *BirthdayMutation: return c.Birthday.mutate(ctx, m) + case *OpenstackMutation: + return c.Openstack.mutate(ctx, m) case *ShitpostMutation: return c.Shitpost.mutate(ctx, m) case *SigninMutation: @@ -394,6 +402,155 @@ func (c *BirthdayClient) mutate(ctx context.Context, m *BirthdayMutation) (Value } } +// OpenstackClient is a client for the Openstack schema. +type OpenstackClient struct { + config +} + +// NewOpenstackClient returns a client for the Openstack from the given config. +func NewOpenstackClient(c config) *OpenstackClient { + return &OpenstackClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `openstack.Hooks(f(g(h())))`. +func (c *OpenstackClient) Use(hooks ...Hook) { + c.hooks.Openstack = append(c.hooks.Openstack, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `openstack.Intercept(f(g(h())))`. +func (c *OpenstackClient) Intercept(interceptors ...Interceptor) { + c.inters.Openstack = append(c.inters.Openstack, interceptors...) +} + +// Create returns a builder for creating a Openstack entity. +func (c *OpenstackClient) Create() *OpenstackCreate { + mutation := newOpenstackMutation(c.config, OpCreate) + return &OpenstackCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Openstack entities. +func (c *OpenstackClient) CreateBulk(builders ...*OpenstackCreate) *OpenstackCreateBulk { + return &OpenstackCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *OpenstackClient) MapCreateBulk(slice any, setFunc func(*OpenstackCreate, int)) *OpenstackCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &OpenstackCreateBulk{err: fmt.Errorf("calling to OpenstackClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*OpenstackCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &OpenstackCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Openstack. +func (c *OpenstackClient) Update() *OpenstackUpdate { + mutation := newOpenstackMutation(c.config, OpUpdate) + return &OpenstackUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *OpenstackClient) UpdateOne(o *Openstack) *OpenstackUpdateOne { + mutation := newOpenstackMutation(c.config, OpUpdateOne, withOpenstack(o)) + return &OpenstackUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *OpenstackClient) UpdateOneID(id int) *OpenstackUpdateOne { + mutation := newOpenstackMutation(c.config, OpUpdateOne, withOpenstackID(id)) + return &OpenstackUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Openstack. +func (c *OpenstackClient) Delete() *OpenstackDelete { + mutation := newOpenstackMutation(c.config, OpDelete) + return &OpenstackDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *OpenstackClient) DeleteOne(o *Openstack) *OpenstackDeleteOne { + return c.DeleteOneID(o.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *OpenstackClient) DeleteOneID(id int) *OpenstackDeleteOne { + builder := c.Delete().Where(openstack.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &OpenstackDeleteOne{builder} +} + +// Query returns a query builder for Openstack. +func (c *OpenstackClient) Query() *OpenstackQuery { + return &OpenstackQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeOpenstack}, + inters: c.Interceptors(), + } +} + +// Get returns a Openstack entity by its id. +func (c *OpenstackClient) Get(ctx context.Context, id int) (*Openstack, error) { + return c.Query().Where(openstack.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *OpenstackClient) GetX(ctx context.Context, id int) *Openstack { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryUser queries the user edge of a Openstack. +func (c *OpenstackClient) QueryUser(o *Openstack) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := o.ID + step := sqlgraph.NewStep( + sqlgraph.From(openstack.Table, openstack.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, openstack.UserTable, openstack.UserColumn), + ) + fromV = sqlgraph.Neighbors(o.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *OpenstackClient) Hooks() []Hook { + return c.hooks.Openstack +} + +// Interceptors returns the client interceptors. +func (c *OpenstackClient) Interceptors() []Interceptor { + return c.inters.Openstack +} + +func (c *OpenstackClient) mutate(ctx context.Context, m *OpenstackMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&OpenstackCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&OpenstackUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&OpenstackUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&OpenstackDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Openstack mutation op: %q", m.Op()) + } +} + // ShitpostClient is a client for the Shitpost schema. type ShitpostClient struct { config @@ -864,6 +1021,22 @@ func (c *UserClient) QueryBirthday(u *User) *BirthdayQuery { return query } +// QueryOpenstack queries the openstack edge of a User. +func (c *UserClient) QueryOpenstack(u *User) *OpenstackQuery { + query := (&OpenstackClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(openstack.Table, openstack.FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, user.OpenstackTable, user.OpenstackColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *UserClient) Hooks() []Hook { return c.hooks.User @@ -1174,9 +1347,9 @@ func (c *VoteResultClient) mutate(ctx context.Context, m *VoteResultMutation) (V // hooks and interceptors per client, for fast access. type ( hooks struct { - Birthday, Shitpost, Signin, User, Vote, VoteResult []ent.Hook + Birthday, Openstack, Shitpost, Signin, User, Vote, VoteResult []ent.Hook } inters struct { - Birthday, Shitpost, Signin, User, Vote, VoteResult []ent.Interceptor + Birthday, Openstack, Shitpost, Signin, User, Vote, VoteResult []ent.Interceptor } ) diff --git a/ent/ent.go b/ent/ent.go index 3914f93..13066e8 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/shitpost" "github.com/ritsec/ops-bot-iii/ent/signin" "github.com/ritsec/ops-bot-iii/ent/user" @@ -79,6 +80,7 @@ func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ birthday.Table: birthday.ValidColumn, + openstack.Table: openstack.ValidColumn, shitpost.Table: shitpost.ValidColumn, signin.Table: signin.ValidColumn, user.Table: user.ValidColumn, diff --git a/ent/hook/hook.go b/ent/hook/hook.go index dc024cd..1997c9b 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -21,6 +21,18 @@ func (f BirthdayFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, er return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BirthdayMutation", m) } +// The OpenstackFunc type is an adapter to allow the use of ordinary +// function as Openstack mutator. +type OpenstackFunc func(context.Context, *ent.OpenstackMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f OpenstackFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.OpenstackMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.OpenstackMutation", m) +} + // The ShitpostFunc type is an adapter to allow the use of ordinary // function as Shitpost mutator. type ShitpostFunc func(context.Context, *ent.ShitpostMutation) (ent.Value, error) diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index be9ffac..949443c 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -29,6 +29,26 @@ var ( }, }, } + // OpenstacksColumns holds the columns for the "openstacks" table. + OpenstacksColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "timestamp", Type: field.TypeTime}, + {Name: "user_openstack", Type: field.TypeString, Unique: true, Nullable: true}, + } + // OpenstacksTable holds the schema information for the "openstacks" table. + OpenstacksTable = &schema.Table{ + Name: "openstacks", + Columns: OpenstacksColumns, + PrimaryKey: []*schema.Column{OpenstacksColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "openstacks_users_openstack", + Columns: []*schema.Column{OpenstacksColumns[2]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } // ShitpostsColumns holds the columns for the "shitposts" table. ShitpostsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, @@ -122,6 +142,7 @@ var ( // Tables holds all the tables in the schema. Tables = []*schema.Table{ BirthdaysTable, + OpenstacksTable, ShitpostsTable, SigninsTable, UsersTable, @@ -132,6 +153,7 @@ var ( func init() { BirthdaysTable.ForeignKeys[0].RefTable = UsersTable + OpenstacksTable.ForeignKeys[0].RefTable = UsersTable ShitpostsTable.ForeignKeys[0].RefTable = UsersTable SigninsTable.ForeignKeys[0].RefTable = UsersTable VotesTable.ForeignKeys[0].RefTable = UsersTable diff --git a/ent/mutation.go b/ent/mutation.go index 109c97f..7d9d1b5 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/predicate" "github.com/ritsec/ops-bot-iii/ent/shitpost" "github.com/ritsec/ops-bot-iii/ent/signin" @@ -30,6 +31,7 @@ const ( // Node types. TypeBirthday = "Birthday" + TypeOpenstack = "Openstack" TypeShitpost = "Shitpost" TypeSignin = "Signin" TypeUser = "User" @@ -553,6 +555,399 @@ func (m *BirthdayMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Birthday edge %s", name) } +// OpenstackMutation represents an operation that mutates the Openstack nodes in the graph. +type OpenstackMutation struct { + config + op Op + typ string + id *int + timestamp *time.Time + clearedFields map[string]struct{} + user *string + cleareduser bool + done bool + oldValue func(context.Context) (*Openstack, error) + predicates []predicate.Openstack +} + +var _ ent.Mutation = (*OpenstackMutation)(nil) + +// openstackOption allows management of the mutation configuration using functional options. +type openstackOption func(*OpenstackMutation) + +// newOpenstackMutation creates new mutation for the Openstack entity. +func newOpenstackMutation(c config, op Op, opts ...openstackOption) *OpenstackMutation { + m := &OpenstackMutation{ + config: c, + op: op, + typ: TypeOpenstack, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withOpenstackID sets the ID field of the mutation. +func withOpenstackID(id int) openstackOption { + return func(m *OpenstackMutation) { + var ( + err error + once sync.Once + value *Openstack + ) + m.oldValue = func(ctx context.Context) (*Openstack, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Openstack.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withOpenstack sets the old Openstack of the mutation. +func withOpenstack(node *Openstack) openstackOption { + return func(m *OpenstackMutation) { + m.oldValue = func(context.Context) (*Openstack, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m OpenstackMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m OpenstackMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *OpenstackMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *OpenstackMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Openstack.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetTimestamp sets the "timestamp" field. +func (m *OpenstackMutation) SetTimestamp(t time.Time) { + m.timestamp = &t +} + +// Timestamp returns the value of the "timestamp" field in the mutation. +func (m *OpenstackMutation) Timestamp() (r time.Time, exists bool) { + v := m.timestamp + if v == nil { + return + } + return *v, true +} + +// OldTimestamp returns the old "timestamp" field's value of the Openstack entity. +// If the Openstack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *OpenstackMutation) OldTimestamp(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTimestamp is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTimestamp requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTimestamp: %w", err) + } + return oldValue.Timestamp, nil +} + +// ResetTimestamp resets all changes to the "timestamp" field. +func (m *OpenstackMutation) ResetTimestamp() { + m.timestamp = nil +} + +// SetUserID sets the "user" edge to the User entity by id. +func (m *OpenstackMutation) SetUserID(id string) { + m.user = &id +} + +// ClearUser clears the "user" edge to the User entity. +func (m *OpenstackMutation) ClearUser() { + m.cleareduser = true +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *OpenstackMutation) UserCleared() bool { + return m.cleareduser +} + +// UserID returns the "user" edge ID in the mutation. +func (m *OpenstackMutation) UserID() (id string, exists bool) { + if m.user != nil { + return *m.user, true + } + return +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *OpenstackMutation) UserIDs() (ids []string) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *OpenstackMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// Where appends a list predicates to the OpenstackMutation builder. +func (m *OpenstackMutation) Where(ps ...predicate.Openstack) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the OpenstackMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *OpenstackMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Openstack, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *OpenstackMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *OpenstackMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Openstack). +func (m *OpenstackMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *OpenstackMutation) Fields() []string { + fields := make([]string, 0, 1) + if m.timestamp != nil { + fields = append(fields, openstack.FieldTimestamp) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *OpenstackMutation) Field(name string) (ent.Value, bool) { + switch name { + case openstack.FieldTimestamp: + return m.Timestamp() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *OpenstackMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case openstack.FieldTimestamp: + return m.OldTimestamp(ctx) + } + return nil, fmt.Errorf("unknown Openstack field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *OpenstackMutation) SetField(name string, value ent.Value) error { + switch name { + case openstack.FieldTimestamp: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTimestamp(v) + return nil + } + return fmt.Errorf("unknown Openstack field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *OpenstackMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *OpenstackMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *OpenstackMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Openstack numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *OpenstackMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *OpenstackMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *OpenstackMutation) ClearField(name string) error { + return fmt.Errorf("unknown Openstack nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *OpenstackMutation) ResetField(name string) error { + switch name { + case openstack.FieldTimestamp: + m.ResetTimestamp() + return nil + } + return fmt.Errorf("unknown Openstack field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *OpenstackMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.user != nil { + edges = append(edges, openstack.EdgeUser) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *OpenstackMutation) AddedIDs(name string) []ent.Value { + switch name { + case openstack.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *OpenstackMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *OpenstackMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *OpenstackMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleareduser { + edges = append(edges, openstack.EdgeUser) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *OpenstackMutation) EdgeCleared(name string) bool { + switch name { + case openstack.EdgeUser: + return m.cleareduser + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *OpenstackMutation) ClearEdge(name string) error { + switch name { + case openstack.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown Openstack unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *OpenstackMutation) ResetEdge(name string) error { + switch name { + case openstack.EdgeUser: + m.ResetUser() + return nil + } + return fmt.Errorf("unknown Openstack edge %s", name) +} + // ShitpostMutation represents an operation that mutates the Shitpost nodes in the graph. type ShitpostMutation struct { config @@ -1511,6 +1906,8 @@ type UserMutation struct { clearedshitposts bool birthday *int clearedbirthday bool + openstack *int + clearedopenstack bool done bool oldValue func(context.Context) (*User, error) predicates []predicate.User @@ -1949,6 +2346,45 @@ func (m *UserMutation) ResetBirthday() { m.clearedbirthday = false } +// SetOpenstackID sets the "openstack" edge to the Openstack entity by id. +func (m *UserMutation) SetOpenstackID(id int) { + m.openstack = &id +} + +// ClearOpenstack clears the "openstack" edge to the Openstack entity. +func (m *UserMutation) ClearOpenstack() { + m.clearedopenstack = true +} + +// OpenstackCleared reports if the "openstack" edge to the Openstack entity was cleared. +func (m *UserMutation) OpenstackCleared() bool { + return m.clearedopenstack +} + +// OpenstackID returns the "openstack" edge ID in the mutation. +func (m *UserMutation) OpenstackID() (id int, exists bool) { + if m.openstack != nil { + return *m.openstack, true + } + return +} + +// OpenstackIDs returns the "openstack" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OpenstackID instead. It exists only for internal usage by the builders. +func (m *UserMutation) OpenstackIDs() (ids []int) { + if id := m.openstack; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOpenstack resets all changes to the "openstack" edge. +func (m *UserMutation) ResetOpenstack() { + m.openstack = nil + m.clearedopenstack = false +} + // Where appends a list predicates to the UserMutation builder. func (m *UserMutation) Where(ps ...predicate.User) { m.predicates = append(m.predicates, ps...) @@ -2131,7 +2567,7 @@ func (m *UserMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *UserMutation) AddedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 5) if m.signins != nil { edges = append(edges, user.EdgeSignins) } @@ -2144,6 +2580,9 @@ func (m *UserMutation) AddedEdges() []string { if m.birthday != nil { edges = append(edges, user.EdgeBirthday) } + if m.openstack != nil { + edges = append(edges, user.EdgeOpenstack) + } return edges } @@ -2173,13 +2612,17 @@ func (m *UserMutation) AddedIDs(name string) []ent.Value { if id := m.birthday; id != nil { return []ent.Value{*id} } + case user.EdgeOpenstack: + if id := m.openstack; id != nil { + return []ent.Value{*id} + } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *UserMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 5) if m.removedsignins != nil { edges = append(edges, user.EdgeSignins) } @@ -2220,7 +2663,7 @@ func (m *UserMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UserMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 5) if m.clearedsignins { edges = append(edges, user.EdgeSignins) } @@ -2233,6 +2676,9 @@ func (m *UserMutation) ClearedEdges() []string { if m.clearedbirthday { edges = append(edges, user.EdgeBirthday) } + if m.clearedopenstack { + edges = append(edges, user.EdgeOpenstack) + } return edges } @@ -2248,6 +2694,8 @@ func (m *UserMutation) EdgeCleared(name string) bool { return m.clearedshitposts case user.EdgeBirthday: return m.clearedbirthday + case user.EdgeOpenstack: + return m.clearedopenstack } return false } @@ -2259,6 +2707,9 @@ func (m *UserMutation) ClearEdge(name string) error { case user.EdgeBirthday: m.ClearBirthday() return nil + case user.EdgeOpenstack: + m.ClearOpenstack() + return nil } return fmt.Errorf("unknown User unique edge %s", name) } @@ -2279,6 +2730,9 @@ func (m *UserMutation) ResetEdge(name string) error { case user.EdgeBirthday: m.ResetBirthday() return nil + case user.EdgeOpenstack: + m.ResetOpenstack() + return nil } return fmt.Errorf("unknown User edge %s", name) } diff --git a/ent/openstack.go b/ent/openstack.go new file mode 100644 index 0000000..f1f3bcd --- /dev/null +++ b/ent/openstack.go @@ -0,0 +1,143 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/ritsec/ops-bot-iii/ent/openstack" + "github.com/ritsec/ops-bot-iii/ent/user" +) + +// Openstack is the model entity for the Openstack schema. +type Openstack struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Time of last reset + Timestamp time.Time `json:"timestamp,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the OpenstackQuery when eager-loading is set. + Edges OpenstackEdges `json:"edges"` + user_openstack *string + selectValues sql.SelectValues +} + +// OpenstackEdges holds the relations/edges for other nodes in the graph. +type OpenstackEdges struct { + // User holds the value of the user edge. + User *User `json:"user,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// UserOrErr returns the User value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e OpenstackEdges) UserOrErr() (*User, error) { + if e.User != nil { + return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} + } + return nil, &NotLoadedError{edge: "user"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Openstack) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case openstack.FieldID: + values[i] = new(sql.NullInt64) + case openstack.FieldTimestamp: + values[i] = new(sql.NullTime) + case openstack.ForeignKeys[0]: // user_openstack + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Openstack fields. +func (o *Openstack) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case openstack.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + o.ID = int(value.Int64) + case openstack.FieldTimestamp: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field timestamp", values[i]) + } else if value.Valid { + o.Timestamp = value.Time + } + case openstack.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_openstack", values[i]) + } else if value.Valid { + o.user_openstack = new(string) + *o.user_openstack = value.String + } + default: + o.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Openstack. +// This includes values selected through modifiers, order, etc. +func (o *Openstack) Value(name string) (ent.Value, error) { + return o.selectValues.Get(name) +} + +// QueryUser queries the "user" edge of the Openstack entity. +func (o *Openstack) QueryUser() *UserQuery { + return NewOpenstackClient(o.config).QueryUser(o) +} + +// Update returns a builder for updating this Openstack. +// Note that you need to call Openstack.Unwrap() before calling this method if this Openstack +// was returned from a transaction, and the transaction was committed or rolled back. +func (o *Openstack) Update() *OpenstackUpdateOne { + return NewOpenstackClient(o.config).UpdateOne(o) +} + +// Unwrap unwraps the Openstack entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (o *Openstack) Unwrap() *Openstack { + _tx, ok := o.config.driver.(*txDriver) + if !ok { + panic("ent: Openstack is not a transactional entity") + } + o.config.driver = _tx.drv + return o +} + +// String implements the fmt.Stringer. +func (o *Openstack) String() string { + var builder strings.Builder + builder.WriteString("Openstack(") + builder.WriteString(fmt.Sprintf("id=%v, ", o.ID)) + builder.WriteString("timestamp=") + builder.WriteString(o.Timestamp.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// Openstacks is a parsable slice of Openstack. +type Openstacks []*Openstack diff --git a/ent/openstack/openstack.go b/ent/openstack/openstack.go new file mode 100644 index 0000000..09f9340 --- /dev/null +++ b/ent/openstack/openstack.go @@ -0,0 +1,89 @@ +// Code generated by ent, DO NOT EDIT. + +package openstack + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the openstack type in the database. + Label = "openstack" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldTimestamp holds the string denoting the timestamp field in the database. + FieldTimestamp = "timestamp" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // Table holds the table name of the openstack in the database. + Table = "openstacks" + // UserTable is the table that holds the user relation/edge. + UserTable = "openstacks" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_openstack" +) + +// Columns holds all SQL columns for openstack fields. +var Columns = []string{ + FieldID, + FieldTimestamp, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "openstacks" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "user_openstack", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // DefaultTimestamp holds the default value on creation for the "timestamp" field. + DefaultTimestamp func() time.Time +) + +// OrderOption defines the ordering options for the Openstack queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByTimestamp orders the results by the timestamp field. +func ByTimestamp(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTimestamp, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, UserTable, UserColumn), + ) +} diff --git a/ent/openstack/where.go b/ent/openstack/where.go new file mode 100644 index 0000000..da71250 --- /dev/null +++ b/ent/openstack/where.go @@ -0,0 +1,139 @@ +// Code generated by ent, DO NOT EDIT. + +package openstack + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/ritsec/ops-bot-iii/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Openstack { + return predicate.Openstack(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Openstack { + return predicate.Openstack(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Openstack { + return predicate.Openstack(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Openstack { + return predicate.Openstack(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Openstack { + return predicate.Openstack(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Openstack { + return predicate.Openstack(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Openstack { + return predicate.Openstack(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Openstack { + return predicate.Openstack(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Openstack { + return predicate.Openstack(sql.FieldLTE(FieldID, id)) +} + +// Timestamp applies equality check predicate on the "timestamp" field. It's identical to TimestampEQ. +func Timestamp(v time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldEQ(FieldTimestamp, v)) +} + +// TimestampEQ applies the EQ predicate on the "timestamp" field. +func TimestampEQ(v time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldEQ(FieldTimestamp, v)) +} + +// TimestampNEQ applies the NEQ predicate on the "timestamp" field. +func TimestampNEQ(v time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldNEQ(FieldTimestamp, v)) +} + +// TimestampIn applies the In predicate on the "timestamp" field. +func TimestampIn(vs ...time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldIn(FieldTimestamp, vs...)) +} + +// TimestampNotIn applies the NotIn predicate on the "timestamp" field. +func TimestampNotIn(vs ...time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldNotIn(FieldTimestamp, vs...)) +} + +// TimestampGT applies the GT predicate on the "timestamp" field. +func TimestampGT(v time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldGT(FieldTimestamp, v)) +} + +// TimestampGTE applies the GTE predicate on the "timestamp" field. +func TimestampGTE(v time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldGTE(FieldTimestamp, v)) +} + +// TimestampLT applies the LT predicate on the "timestamp" field. +func TimestampLT(v time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldLT(FieldTimestamp, v)) +} + +// TimestampLTE applies the LTE predicate on the "timestamp" field. +func TimestampLTE(v time.Time) predicate.Openstack { + return predicate.Openstack(sql.FieldLTE(FieldTimestamp, v)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.Openstack { + return predicate.Openstack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.Openstack { + return predicate.Openstack(func(s *sql.Selector) { + step := newUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Openstack) predicate.Openstack { + return predicate.Openstack(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Openstack) predicate.Openstack { + return predicate.Openstack(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Openstack) predicate.Openstack { + return predicate.Openstack(sql.NotPredicates(p)) +} diff --git a/ent/openstack_create.go b/ent/openstack_create.go new file mode 100644 index 0000000..cfb9fa1 --- /dev/null +++ b/ent/openstack_create.go @@ -0,0 +1,239 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/ritsec/ops-bot-iii/ent/openstack" + "github.com/ritsec/ops-bot-iii/ent/user" +) + +// OpenstackCreate is the builder for creating a Openstack entity. +type OpenstackCreate struct { + config + mutation *OpenstackMutation + hooks []Hook +} + +// SetTimestamp sets the "timestamp" field. +func (oc *OpenstackCreate) SetTimestamp(t time.Time) *OpenstackCreate { + oc.mutation.SetTimestamp(t) + return oc +} + +// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. +func (oc *OpenstackCreate) SetNillableTimestamp(t *time.Time) *OpenstackCreate { + if t != nil { + oc.SetTimestamp(*t) + } + return oc +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (oc *OpenstackCreate) SetUserID(id string) *OpenstackCreate { + oc.mutation.SetUserID(id) + return oc +} + +// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. +func (oc *OpenstackCreate) SetNillableUserID(id *string) *OpenstackCreate { + if id != nil { + oc = oc.SetUserID(*id) + } + return oc +} + +// SetUser sets the "user" edge to the User entity. +func (oc *OpenstackCreate) SetUser(u *User) *OpenstackCreate { + return oc.SetUserID(u.ID) +} + +// Mutation returns the OpenstackMutation object of the builder. +func (oc *OpenstackCreate) Mutation() *OpenstackMutation { + return oc.mutation +} + +// Save creates the Openstack in the database. +func (oc *OpenstackCreate) Save(ctx context.Context) (*Openstack, error) { + oc.defaults() + return withHooks(ctx, oc.sqlSave, oc.mutation, oc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (oc *OpenstackCreate) SaveX(ctx context.Context) *Openstack { + v, err := oc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (oc *OpenstackCreate) Exec(ctx context.Context) error { + _, err := oc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (oc *OpenstackCreate) ExecX(ctx context.Context) { + if err := oc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (oc *OpenstackCreate) defaults() { + if _, ok := oc.mutation.Timestamp(); !ok { + v := openstack.DefaultTimestamp() + oc.mutation.SetTimestamp(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (oc *OpenstackCreate) check() error { + if _, ok := oc.mutation.Timestamp(); !ok { + return &ValidationError{Name: "timestamp", err: errors.New(`ent: missing required field "Openstack.timestamp"`)} + } + return nil +} + +func (oc *OpenstackCreate) sqlSave(ctx context.Context) (*Openstack, error) { + if err := oc.check(); err != nil { + return nil, err + } + _node, _spec := oc.createSpec() + if err := sqlgraph.CreateNode(ctx, oc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + oc.mutation.id = &_node.ID + oc.mutation.done = true + return _node, nil +} + +func (oc *OpenstackCreate) createSpec() (*Openstack, *sqlgraph.CreateSpec) { + var ( + _node = &Openstack{config: oc.config} + _spec = sqlgraph.NewCreateSpec(openstack.Table, sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt)) + ) + if value, ok := oc.mutation.Timestamp(); ok { + _spec.SetField(openstack.FieldTimestamp, field.TypeTime, value) + _node.Timestamp = value + } + if nodes := oc.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: openstack.UserTable, + Columns: []string{openstack.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.user_openstack = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OpenstackCreateBulk is the builder for creating many Openstack entities in bulk. +type OpenstackCreateBulk struct { + config + err error + builders []*OpenstackCreate +} + +// Save creates the Openstack entities in the database. +func (ocb *OpenstackCreateBulk) Save(ctx context.Context) ([]*Openstack, error) { + if ocb.err != nil { + return nil, ocb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ocb.builders)) + nodes := make([]*Openstack, len(ocb.builders)) + mutators := make([]Mutator, len(ocb.builders)) + for i := range ocb.builders { + func(i int, root context.Context) { + builder := ocb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*OpenstackMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ocb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ocb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, ocb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ocb *OpenstackCreateBulk) SaveX(ctx context.Context) []*Openstack { + v, err := ocb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ocb *OpenstackCreateBulk) Exec(ctx context.Context) error { + _, err := ocb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ocb *OpenstackCreateBulk) ExecX(ctx context.Context) { + if err := ocb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/openstack_delete.go b/ent/openstack_delete.go new file mode 100644 index 0000000..1bcfbce --- /dev/null +++ b/ent/openstack_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/ritsec/ops-bot-iii/ent/openstack" + "github.com/ritsec/ops-bot-iii/ent/predicate" +) + +// OpenstackDelete is the builder for deleting a Openstack entity. +type OpenstackDelete struct { + config + hooks []Hook + mutation *OpenstackMutation +} + +// Where appends a list predicates to the OpenstackDelete builder. +func (od *OpenstackDelete) Where(ps ...predicate.Openstack) *OpenstackDelete { + od.mutation.Where(ps...) + return od +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (od *OpenstackDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, od.sqlExec, od.mutation, od.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (od *OpenstackDelete) ExecX(ctx context.Context) int { + n, err := od.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (od *OpenstackDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(openstack.Table, sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt)) + if ps := od.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, od.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + od.mutation.done = true + return affected, err +} + +// OpenstackDeleteOne is the builder for deleting a single Openstack entity. +type OpenstackDeleteOne struct { + od *OpenstackDelete +} + +// Where appends a list predicates to the OpenstackDelete builder. +func (odo *OpenstackDeleteOne) Where(ps ...predicate.Openstack) *OpenstackDeleteOne { + odo.od.mutation.Where(ps...) + return odo +} + +// Exec executes the deletion query. +func (odo *OpenstackDeleteOne) Exec(ctx context.Context) error { + n, err := odo.od.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{openstack.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (odo *OpenstackDeleteOne) ExecX(ctx context.Context) { + if err := odo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/openstack_query.go b/ent/openstack_query.go new file mode 100644 index 0000000..db66838 --- /dev/null +++ b/ent/openstack_query.go @@ -0,0 +1,614 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/ritsec/ops-bot-iii/ent/openstack" + "github.com/ritsec/ops-bot-iii/ent/predicate" + "github.com/ritsec/ops-bot-iii/ent/user" +) + +// OpenstackQuery is the builder for querying Openstack entities. +type OpenstackQuery struct { + config + ctx *QueryContext + order []openstack.OrderOption + inters []Interceptor + predicates []predicate.Openstack + withUser *UserQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the OpenstackQuery builder. +func (oq *OpenstackQuery) Where(ps ...predicate.Openstack) *OpenstackQuery { + oq.predicates = append(oq.predicates, ps...) + return oq +} + +// Limit the number of records to be returned by this query. +func (oq *OpenstackQuery) Limit(limit int) *OpenstackQuery { + oq.ctx.Limit = &limit + return oq +} + +// Offset to start from. +func (oq *OpenstackQuery) Offset(offset int) *OpenstackQuery { + oq.ctx.Offset = &offset + return oq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (oq *OpenstackQuery) Unique(unique bool) *OpenstackQuery { + oq.ctx.Unique = &unique + return oq +} + +// Order specifies how the records should be ordered. +func (oq *OpenstackQuery) Order(o ...openstack.OrderOption) *OpenstackQuery { + oq.order = append(oq.order, o...) + return oq +} + +// QueryUser chains the current query on the "user" edge. +func (oq *OpenstackQuery) QueryUser() *UserQuery { + query := (&UserClient{config: oq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := oq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := oq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(openstack.Table, openstack.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, openstack.UserTable, openstack.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(oq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Openstack entity from the query. +// Returns a *NotFoundError when no Openstack was found. +func (oq *OpenstackQuery) First(ctx context.Context) (*Openstack, error) { + nodes, err := oq.Limit(1).All(setContextOp(ctx, oq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{openstack.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (oq *OpenstackQuery) FirstX(ctx context.Context) *Openstack { + node, err := oq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Openstack ID from the query. +// Returns a *NotFoundError when no Openstack ID was found. +func (oq *OpenstackQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = oq.Limit(1).IDs(setContextOp(ctx, oq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{openstack.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (oq *OpenstackQuery) FirstIDX(ctx context.Context) int { + id, err := oq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Openstack entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Openstack entity is found. +// Returns a *NotFoundError when no Openstack entities are found. +func (oq *OpenstackQuery) Only(ctx context.Context) (*Openstack, error) { + nodes, err := oq.Limit(2).All(setContextOp(ctx, oq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{openstack.Label} + default: + return nil, &NotSingularError{openstack.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (oq *OpenstackQuery) OnlyX(ctx context.Context) *Openstack { + node, err := oq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Openstack ID in the query. +// Returns a *NotSingularError when more than one Openstack ID is found. +// Returns a *NotFoundError when no entities are found. +func (oq *OpenstackQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = oq.Limit(2).IDs(setContextOp(ctx, oq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{openstack.Label} + default: + err = &NotSingularError{openstack.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (oq *OpenstackQuery) OnlyIDX(ctx context.Context) int { + id, err := oq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Openstacks. +func (oq *OpenstackQuery) All(ctx context.Context) ([]*Openstack, error) { + ctx = setContextOp(ctx, oq.ctx, ent.OpQueryAll) + if err := oq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Openstack, *OpenstackQuery]() + return withInterceptors[[]*Openstack](ctx, oq, qr, oq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (oq *OpenstackQuery) AllX(ctx context.Context) []*Openstack { + nodes, err := oq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Openstack IDs. +func (oq *OpenstackQuery) IDs(ctx context.Context) (ids []int, err error) { + if oq.ctx.Unique == nil && oq.path != nil { + oq.Unique(true) + } + ctx = setContextOp(ctx, oq.ctx, ent.OpQueryIDs) + if err = oq.Select(openstack.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (oq *OpenstackQuery) IDsX(ctx context.Context) []int { + ids, err := oq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (oq *OpenstackQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, oq.ctx, ent.OpQueryCount) + if err := oq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, oq, querierCount[*OpenstackQuery](), oq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (oq *OpenstackQuery) CountX(ctx context.Context) int { + count, err := oq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (oq *OpenstackQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, oq.ctx, ent.OpQueryExist) + switch _, err := oq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (oq *OpenstackQuery) ExistX(ctx context.Context) bool { + exist, err := oq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the OpenstackQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (oq *OpenstackQuery) Clone() *OpenstackQuery { + if oq == nil { + return nil + } + return &OpenstackQuery{ + config: oq.config, + ctx: oq.ctx.Clone(), + order: append([]openstack.OrderOption{}, oq.order...), + inters: append([]Interceptor{}, oq.inters...), + predicates: append([]predicate.Openstack{}, oq.predicates...), + withUser: oq.withUser.Clone(), + // clone intermediate query. + sql: oq.sql.Clone(), + path: oq.path, + } +} + +// WithUser tells the query-builder to eager-load the nodes that are connected to +// the "user" edge. The optional arguments are used to configure the query builder of the edge. +func (oq *OpenstackQuery) WithUser(opts ...func(*UserQuery)) *OpenstackQuery { + query := (&UserClient{config: oq.config}).Query() + for _, opt := range opts { + opt(query) + } + oq.withUser = query + return oq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Timestamp time.Time `json:"timestamp,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Openstack.Query(). +// GroupBy(openstack.FieldTimestamp). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (oq *OpenstackQuery) GroupBy(field string, fields ...string) *OpenstackGroupBy { + oq.ctx.Fields = append([]string{field}, fields...) + grbuild := &OpenstackGroupBy{build: oq} + grbuild.flds = &oq.ctx.Fields + grbuild.label = openstack.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Timestamp time.Time `json:"timestamp,omitempty"` +// } +// +// client.Openstack.Query(). +// Select(openstack.FieldTimestamp). +// Scan(ctx, &v) +func (oq *OpenstackQuery) Select(fields ...string) *OpenstackSelect { + oq.ctx.Fields = append(oq.ctx.Fields, fields...) + sbuild := &OpenstackSelect{OpenstackQuery: oq} + sbuild.label = openstack.Label + sbuild.flds, sbuild.scan = &oq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a OpenstackSelect configured with the given aggregations. +func (oq *OpenstackQuery) Aggregate(fns ...AggregateFunc) *OpenstackSelect { + return oq.Select().Aggregate(fns...) +} + +func (oq *OpenstackQuery) prepareQuery(ctx context.Context) error { + for _, inter := range oq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, oq); err != nil { + return err + } + } + } + for _, f := range oq.ctx.Fields { + if !openstack.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if oq.path != nil { + prev, err := oq.path(ctx) + if err != nil { + return err + } + oq.sql = prev + } + return nil +} + +func (oq *OpenstackQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Openstack, error) { + var ( + nodes = []*Openstack{} + withFKs = oq.withFKs + _spec = oq.querySpec() + loadedTypes = [1]bool{ + oq.withUser != nil, + } + ) + if oq.withUser != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, openstack.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Openstack).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Openstack{config: oq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, oq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := oq.withUser; query != nil { + if err := oq.loadUser(ctx, query, nodes, nil, + func(n *Openstack, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (oq *OpenstackQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Openstack, init func(*Openstack), assign func(*Openstack, *User)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*Openstack) + for i := range nodes { + if nodes[i].user_openstack == nil { + continue + } + fk := *nodes[i].user_openstack + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "user_openstack" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (oq *OpenstackQuery) sqlCount(ctx context.Context) (int, error) { + _spec := oq.querySpec() + _spec.Node.Columns = oq.ctx.Fields + if len(oq.ctx.Fields) > 0 { + _spec.Unique = oq.ctx.Unique != nil && *oq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, oq.driver, _spec) +} + +func (oq *OpenstackQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(openstack.Table, openstack.Columns, sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt)) + _spec.From = oq.sql + if unique := oq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if oq.path != nil { + _spec.Unique = true + } + if fields := oq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, openstack.FieldID) + for i := range fields { + if fields[i] != openstack.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := oq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := oq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := oq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := oq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (oq *OpenstackQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(oq.driver.Dialect()) + t1 := builder.Table(openstack.Table) + columns := oq.ctx.Fields + if len(columns) == 0 { + columns = openstack.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if oq.sql != nil { + selector = oq.sql + selector.Select(selector.Columns(columns...)...) + } + if oq.ctx.Unique != nil && *oq.ctx.Unique { + selector.Distinct() + } + for _, p := range oq.predicates { + p(selector) + } + for _, p := range oq.order { + p(selector) + } + if offset := oq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := oq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// OpenstackGroupBy is the group-by builder for Openstack entities. +type OpenstackGroupBy struct { + selector + build *OpenstackQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ogb *OpenstackGroupBy) Aggregate(fns ...AggregateFunc) *OpenstackGroupBy { + ogb.fns = append(ogb.fns, fns...) + return ogb +} + +// Scan applies the selector query and scans the result into the given value. +func (ogb *OpenstackGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ogb.build.ctx, ent.OpQueryGroupBy) + if err := ogb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*OpenstackQuery, *OpenstackGroupBy](ctx, ogb.build, ogb, ogb.build.inters, v) +} + +func (ogb *OpenstackGroupBy) sqlScan(ctx context.Context, root *OpenstackQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ogb.fns)) + for _, fn := range ogb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ogb.flds)+len(ogb.fns)) + for _, f := range *ogb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ogb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ogb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// OpenstackSelect is the builder for selecting fields of Openstack entities. +type OpenstackSelect struct { + *OpenstackQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (os *OpenstackSelect) Aggregate(fns ...AggregateFunc) *OpenstackSelect { + os.fns = append(os.fns, fns...) + return os +} + +// Scan applies the selector query and scans the result into the given value. +func (os *OpenstackSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, os.ctx, ent.OpQuerySelect) + if err := os.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*OpenstackQuery, *OpenstackSelect](ctx, os.OpenstackQuery, os, os.inters, v) +} + +func (os *OpenstackSelect) sqlScan(ctx context.Context, root *OpenstackQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(os.fns)) + for _, fn := range os.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*os.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := os.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/openstack_update.go b/ent/openstack_update.go new file mode 100644 index 0000000..31fc611 --- /dev/null +++ b/ent/openstack_update.go @@ -0,0 +1,319 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/ritsec/ops-bot-iii/ent/openstack" + "github.com/ritsec/ops-bot-iii/ent/predicate" + "github.com/ritsec/ops-bot-iii/ent/user" +) + +// OpenstackUpdate is the builder for updating Openstack entities. +type OpenstackUpdate struct { + config + hooks []Hook + mutation *OpenstackMutation +} + +// Where appends a list predicates to the OpenstackUpdate builder. +func (ou *OpenstackUpdate) Where(ps ...predicate.Openstack) *OpenstackUpdate { + ou.mutation.Where(ps...) + return ou +} + +// SetTimestamp sets the "timestamp" field. +func (ou *OpenstackUpdate) SetTimestamp(t time.Time) *OpenstackUpdate { + ou.mutation.SetTimestamp(t) + return ou +} + +// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. +func (ou *OpenstackUpdate) SetNillableTimestamp(t *time.Time) *OpenstackUpdate { + if t != nil { + ou.SetTimestamp(*t) + } + return ou +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (ou *OpenstackUpdate) SetUserID(id string) *OpenstackUpdate { + ou.mutation.SetUserID(id) + return ou +} + +// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. +func (ou *OpenstackUpdate) SetNillableUserID(id *string) *OpenstackUpdate { + if id != nil { + ou = ou.SetUserID(*id) + } + return ou +} + +// SetUser sets the "user" edge to the User entity. +func (ou *OpenstackUpdate) SetUser(u *User) *OpenstackUpdate { + return ou.SetUserID(u.ID) +} + +// Mutation returns the OpenstackMutation object of the builder. +func (ou *OpenstackUpdate) Mutation() *OpenstackMutation { + return ou.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (ou *OpenstackUpdate) ClearUser() *OpenstackUpdate { + ou.mutation.ClearUser() + return ou +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (ou *OpenstackUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, ou.sqlSave, ou.mutation, ou.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ou *OpenstackUpdate) SaveX(ctx context.Context) int { + affected, err := ou.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (ou *OpenstackUpdate) Exec(ctx context.Context) error { + _, err := ou.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ou *OpenstackUpdate) ExecX(ctx context.Context) { + if err := ou.Exec(ctx); err != nil { + panic(err) + } +} + +func (ou *OpenstackUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(openstack.Table, openstack.Columns, sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt)) + if ps := ou.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ou.mutation.Timestamp(); ok { + _spec.SetField(openstack.FieldTimestamp, field.TypeTime, value) + } + if ou.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: openstack.UserTable, + Columns: []string{openstack.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ou.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: openstack.UserTable, + Columns: []string{openstack.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, ou.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{openstack.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + ou.mutation.done = true + return n, nil +} + +// OpenstackUpdateOne is the builder for updating a single Openstack entity. +type OpenstackUpdateOne struct { + config + fields []string + hooks []Hook + mutation *OpenstackMutation +} + +// SetTimestamp sets the "timestamp" field. +func (ouo *OpenstackUpdateOne) SetTimestamp(t time.Time) *OpenstackUpdateOne { + ouo.mutation.SetTimestamp(t) + return ouo +} + +// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. +func (ouo *OpenstackUpdateOne) SetNillableTimestamp(t *time.Time) *OpenstackUpdateOne { + if t != nil { + ouo.SetTimestamp(*t) + } + return ouo +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (ouo *OpenstackUpdateOne) SetUserID(id string) *OpenstackUpdateOne { + ouo.mutation.SetUserID(id) + return ouo +} + +// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. +func (ouo *OpenstackUpdateOne) SetNillableUserID(id *string) *OpenstackUpdateOne { + if id != nil { + ouo = ouo.SetUserID(*id) + } + return ouo +} + +// SetUser sets the "user" edge to the User entity. +func (ouo *OpenstackUpdateOne) SetUser(u *User) *OpenstackUpdateOne { + return ouo.SetUserID(u.ID) +} + +// Mutation returns the OpenstackMutation object of the builder. +func (ouo *OpenstackUpdateOne) Mutation() *OpenstackMutation { + return ouo.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (ouo *OpenstackUpdateOne) ClearUser() *OpenstackUpdateOne { + ouo.mutation.ClearUser() + return ouo +} + +// Where appends a list predicates to the OpenstackUpdate builder. +func (ouo *OpenstackUpdateOne) Where(ps ...predicate.Openstack) *OpenstackUpdateOne { + ouo.mutation.Where(ps...) + return ouo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (ouo *OpenstackUpdateOne) Select(field string, fields ...string) *OpenstackUpdateOne { + ouo.fields = append([]string{field}, fields...) + return ouo +} + +// Save executes the query and returns the updated Openstack entity. +func (ouo *OpenstackUpdateOne) Save(ctx context.Context) (*Openstack, error) { + return withHooks(ctx, ouo.sqlSave, ouo.mutation, ouo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ouo *OpenstackUpdateOne) SaveX(ctx context.Context) *Openstack { + node, err := ouo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (ouo *OpenstackUpdateOne) Exec(ctx context.Context) error { + _, err := ouo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ouo *OpenstackUpdateOne) ExecX(ctx context.Context) { + if err := ouo.Exec(ctx); err != nil { + panic(err) + } +} + +func (ouo *OpenstackUpdateOne) sqlSave(ctx context.Context) (_node *Openstack, err error) { + _spec := sqlgraph.NewUpdateSpec(openstack.Table, openstack.Columns, sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt)) + id, ok := ouo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Openstack.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := ouo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, openstack.FieldID) + for _, f := range fields { + if !openstack.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != openstack.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := ouo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ouo.mutation.Timestamp(); ok { + _spec.SetField(openstack.FieldTimestamp, field.TypeTime, value) + } + if ouo.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: openstack.UserTable, + Columns: []string{openstack.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ouo.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: openstack.UserTable, + Columns: []string{openstack.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Openstack{config: ouo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, ouo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{openstack.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + ouo.mutation.done = true + return _node, nil +} diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go index 36a52ad..1544e2d 100644 --- a/ent/predicate/predicate.go +++ b/ent/predicate/predicate.go @@ -9,6 +9,9 @@ import ( // Birthday is the predicate function for birthday builders. type Birthday func(*sql.Selector) +// Openstack is the predicate function for openstack builders. +type Openstack func(*sql.Selector) + // Shitpost is the predicate function for shitpost builders. type Shitpost func(*sql.Selector) diff --git a/ent/runtime.go b/ent/runtime.go index ad9bcb4..78811d9 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -6,6 +6,7 @@ import ( "time" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/schema" "github.com/ritsec/ops-bot-iii/ent/shitpost" "github.com/ritsec/ops-bot-iii/ent/signin" @@ -56,6 +57,12 @@ func init() { return nil } }() + openstackFields := schema.Openstack{}.Fields() + _ = openstackFields + // openstackDescTimestamp is the schema descriptor for timestamp field. + openstackDescTimestamp := openstackFields[0].Descriptor() + // openstack.DefaultTimestamp holds the default value on creation for the timestamp field. + openstack.DefaultTimestamp = openstackDescTimestamp.Default.(func() time.Time) shitpostFields := schema.Shitpost{}.Fields() _ = shitpostFields // shitpostDescChannelID is the schema descriptor for channel_id field. diff --git a/ent/tx.go b/ent/tx.go index cb77ef6..4672145 100644 --- a/ent/tx.go +++ b/ent/tx.go @@ -14,6 +14,8 @@ type Tx struct { config // Birthday is the client for interacting with the Birthday builders. Birthday *BirthdayClient + // Openstack is the client for interacting with the Openstack builders. + Openstack *OpenstackClient // Shitpost is the client for interacting with the Shitpost builders. Shitpost *ShitpostClient // Signin is the client for interacting with the Signin builders. @@ -156,6 +158,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.Birthday = NewBirthdayClient(tx.config) + tx.Openstack = NewOpenstackClient(tx.config) tx.Shitpost = NewShitpostClient(tx.config) tx.Signin = NewSigninClient(tx.config) tx.User = NewUserClient(tx.config) diff --git a/ent/user.go b/ent/user.go index 1033bce..ed5d45e 100644 --- a/ent/user.go +++ b/ent/user.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/user" ) @@ -40,9 +41,11 @@ type UserEdges struct { Shitposts []*Shitpost `json:"shitposts,omitempty"` // Birthdays of the user Birthday *Birthday `json:"birthday,omitempty"` + // Openstacks Info of the user + Openstack *Openstack `json:"openstack,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool + loadedTypes [5]bool } // SigninsOrErr returns the Signins value or an error if the edge @@ -83,6 +86,17 @@ func (e UserEdges) BirthdayOrErr() (*Birthday, error) { return nil, &NotLoadedError{edge: "birthday"} } +// OpenstackOrErr returns the Openstack value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserEdges) OpenstackOrErr() (*Openstack, error) { + if e.Openstack != nil { + return e.Openstack, nil + } else if e.loadedTypes[4] { + return nil, &NotFoundError{label: openstack.Label} + } + return nil, &NotLoadedError{edge: "openstack"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*User) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -166,6 +180,11 @@ func (u *User) QueryBirthday() *BirthdayQuery { return NewUserClient(u.config).QueryBirthday(u) } +// QueryOpenstack queries the "openstack" edge of the User entity. +func (u *User) QueryOpenstack() *OpenstackQuery { + return NewUserClient(u.config).QueryOpenstack(u) +} + // Update returns a builder for updating this User. // Note that you need to call User.Unwrap() before calling this method if this User // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/ent/user/user.go b/ent/user/user.go index 1c2c160..52a2e6d 100644 --- a/ent/user/user.go +++ b/ent/user/user.go @@ -26,6 +26,8 @@ const ( EdgeShitposts = "shitposts" // EdgeBirthday holds the string denoting the birthday edge name in mutations. EdgeBirthday = "birthday" + // EdgeOpenstack holds the string denoting the openstack edge name in mutations. + EdgeOpenstack = "openstack" // Table holds the table name of the user in the database. Table = "users" // SigninsTable is the table that holds the signins relation/edge. @@ -56,6 +58,13 @@ const ( BirthdayInverseTable = "birthdays" // BirthdayColumn is the table column denoting the birthday relation/edge. BirthdayColumn = "user_birthday" + // OpenstackTable is the table that holds the openstack relation/edge. + OpenstackTable = "openstacks" + // OpenstackInverseTable is the table name for the Openstack entity. + // It exists in this package in order to avoid circular dependency with the "openstack" package. + OpenstackInverseTable = "openstacks" + // OpenstackColumn is the table column denoting the openstack relation/edge. + OpenstackColumn = "user_openstack" ) // Columns holds all SQL columns for user fields. @@ -160,6 +169,13 @@ func ByBirthdayField(field string, opts ...sql.OrderTermOption) OrderOption { sqlgraph.OrderByNeighborTerms(s, newBirthdayStep(), sql.OrderByField(field, opts...)) } } + +// ByOpenstackField orders the results by openstack field. +func ByOpenstackField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOpenstackStep(), sql.OrderByField(field, opts...)) + } +} func newSigninsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -188,3 +204,10 @@ func newBirthdayStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2O, false, BirthdayTable, BirthdayColumn), ) } +func newOpenstackStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OpenstackInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, OpenstackTable, OpenstackColumn), + ) +} diff --git a/ent/user/where.go b/ent/user/where.go index 972fbc4..7e24f4d 100644 --- a/ent/user/where.go +++ b/ent/user/where.go @@ -285,6 +285,29 @@ func HasBirthdayWith(preds ...predicate.Birthday) predicate.User { }) } +// HasOpenstack applies the HasEdge predicate on the "openstack" edge. +func HasOpenstack() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, OpenstackTable, OpenstackColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOpenstackWith applies the HasEdge predicate on the "openstack" edge with a given conditions (other predicates). +func HasOpenstackWith(preds ...predicate.Openstack) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newOpenstackStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { return predicate.User(sql.AndPredicates(predicates...)) diff --git a/ent/user_create.go b/ent/user_create.go index 42dbbf2..96dfef9 100644 --- a/ent/user_create.go +++ b/ent/user_create.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/shitpost" "github.com/ritsec/ops-bot-iii/ent/signin" "github.com/ritsec/ops-bot-iii/ent/user" @@ -135,6 +136,25 @@ func (uc *UserCreate) SetBirthday(b *Birthday) *UserCreate { return uc.SetBirthdayID(b.ID) } +// SetOpenstackID sets the "openstack" edge to the Openstack entity by ID. +func (uc *UserCreate) SetOpenstackID(id int) *UserCreate { + uc.mutation.SetOpenstackID(id) + return uc +} + +// SetNillableOpenstackID sets the "openstack" edge to the Openstack entity by ID if the given value is not nil. +func (uc *UserCreate) SetNillableOpenstackID(id *int) *UserCreate { + if id != nil { + uc = uc.SetOpenstackID(*id) + } + return uc +} + +// SetOpenstack sets the "openstack" edge to the Openstack entity. +func (uc *UserCreate) SetOpenstack(o *Openstack) *UserCreate { + return uc.SetOpenstackID(o.ID) +} + // Mutation returns the UserMutation object of the builder. func (uc *UserCreate) Mutation() *UserMutation { return uc.mutation @@ -316,6 +336,22 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := uc.mutation.OpenstackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: user.OpenstackTable, + Columns: []string{user.OpenstackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/ent/user_query.go b/ent/user_query.go index 06d6a7c..1be2eda 100644 --- a/ent/user_query.go +++ b/ent/user_query.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/predicate" "github.com/ritsec/ops-bot-iii/ent/shitpost" "github.com/ritsec/ops-bot-iii/ent/signin" @@ -31,6 +32,7 @@ type UserQuery struct { withVotes *VoteQuery withShitposts *ShitpostQuery withBirthday *BirthdayQuery + withOpenstack *OpenstackQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -155,6 +157,28 @@ func (uq *UserQuery) QueryBirthday() *BirthdayQuery { return query } +// QueryOpenstack chains the current query on the "openstack" edge. +func (uq *UserQuery) QueryOpenstack() *OpenstackQuery { + query := (&OpenstackClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(openstack.Table, openstack.FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, user.OpenstackTable, user.OpenstackColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first User entity from the query. // Returns a *NotFoundError when no User was found. func (uq *UserQuery) First(ctx context.Context) (*User, error) { @@ -351,6 +375,7 @@ func (uq *UserQuery) Clone() *UserQuery { withVotes: uq.withVotes.Clone(), withShitposts: uq.withShitposts.Clone(), withBirthday: uq.withBirthday.Clone(), + withOpenstack: uq.withOpenstack.Clone(), // clone intermediate query. sql: uq.sql.Clone(), path: uq.path, @@ -401,6 +426,17 @@ func (uq *UserQuery) WithBirthday(opts ...func(*BirthdayQuery)) *UserQuery { return uq } +// WithOpenstack tells the query-builder to eager-load the nodes that are connected to +// the "openstack" edge. The optional arguments are used to configure the query builder of the edge. +func (uq *UserQuery) WithOpenstack(opts ...func(*OpenstackQuery)) *UserQuery { + query := (&OpenstackClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withOpenstack = query + return uq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -479,11 +515,12 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e var ( nodes = []*User{} _spec = uq.querySpec() - loadedTypes = [4]bool{ + loadedTypes = [5]bool{ uq.withSignins != nil, uq.withVotes != nil, uq.withShitposts != nil, uq.withBirthday != nil, + uq.withOpenstack != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -531,6 +568,12 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e return nil, err } } + if query := uq.withOpenstack; query != nil { + if err := uq.loadOpenstack(ctx, query, nodes, nil, + func(n *User, e *Openstack) { n.Edges.Openstack = e }); err != nil { + return nil, err + } + } return nodes, nil } @@ -655,6 +698,34 @@ func (uq *UserQuery) loadBirthday(ctx context.Context, query *BirthdayQuery, nod } return nil } +func (uq *UserQuery) loadOpenstack(ctx context.Context, query *OpenstackQuery, nodes []*User, init func(*User), assign func(*User, *Openstack)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + } + query.withFKs = true + query.Where(predicate.Openstack(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.OpenstackColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.user_openstack + if fk == nil { + return fmt.Errorf(`foreign-key "user_openstack" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_openstack" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { _spec := uq.querySpec() diff --git a/ent/user_update.go b/ent/user_update.go index c04a7a7..dfa1767 100644 --- a/ent/user_update.go +++ b/ent/user_update.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/ritsec/ops-bot-iii/ent/birthday" + "github.com/ritsec/ops-bot-iii/ent/openstack" "github.com/ritsec/ops-bot-iii/ent/predicate" "github.com/ritsec/ops-bot-iii/ent/shitpost" "github.com/ritsec/ops-bot-iii/ent/signin" @@ -144,6 +145,25 @@ func (uu *UserUpdate) SetBirthday(b *Birthday) *UserUpdate { return uu.SetBirthdayID(b.ID) } +// SetOpenstackID sets the "openstack" edge to the Openstack entity by ID. +func (uu *UserUpdate) SetOpenstackID(id int) *UserUpdate { + uu.mutation.SetOpenstackID(id) + return uu +} + +// SetNillableOpenstackID sets the "openstack" edge to the Openstack entity by ID if the given value is not nil. +func (uu *UserUpdate) SetNillableOpenstackID(id *int) *UserUpdate { + if id != nil { + uu = uu.SetOpenstackID(*id) + } + return uu +} + +// SetOpenstack sets the "openstack" edge to the Openstack entity. +func (uu *UserUpdate) SetOpenstack(o *Openstack) *UserUpdate { + return uu.SetOpenstackID(o.ID) +} + // Mutation returns the UserMutation object of the builder. func (uu *UserUpdate) Mutation() *UserMutation { return uu.mutation @@ -218,6 +238,12 @@ func (uu *UserUpdate) ClearBirthday() *UserUpdate { return uu } +// ClearOpenstack clears the "openstack" edge to the Openstack entity. +func (uu *UserUpdate) ClearOpenstack() *UserUpdate { + uu.mutation.ClearOpenstack() + return uu +} + // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) @@ -443,6 +469,35 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if uu.mutation.OpenstackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: user.OpenstackTable, + Columns: []string{user.OpenstackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.OpenstackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: user.OpenstackTable, + Columns: []string{user.OpenstackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} @@ -576,6 +631,25 @@ func (uuo *UserUpdateOne) SetBirthday(b *Birthday) *UserUpdateOne { return uuo.SetBirthdayID(b.ID) } +// SetOpenstackID sets the "openstack" edge to the Openstack entity by ID. +func (uuo *UserUpdateOne) SetOpenstackID(id int) *UserUpdateOne { + uuo.mutation.SetOpenstackID(id) + return uuo +} + +// SetNillableOpenstackID sets the "openstack" edge to the Openstack entity by ID if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableOpenstackID(id *int) *UserUpdateOne { + if id != nil { + uuo = uuo.SetOpenstackID(*id) + } + return uuo +} + +// SetOpenstack sets the "openstack" edge to the Openstack entity. +func (uuo *UserUpdateOne) SetOpenstack(o *Openstack) *UserUpdateOne { + return uuo.SetOpenstackID(o.ID) +} + // Mutation returns the UserMutation object of the builder. func (uuo *UserUpdateOne) Mutation() *UserMutation { return uuo.mutation @@ -650,6 +724,12 @@ func (uuo *UserUpdateOne) ClearBirthday() *UserUpdateOne { return uuo } +// ClearOpenstack clears the "openstack" edge to the Openstack entity. +func (uuo *UserUpdateOne) ClearOpenstack() *UserUpdateOne { + uuo.mutation.ClearOpenstack() + return uuo +} + // Where appends a list predicates to the UserUpdate builder. func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { uuo.mutation.Where(ps...) @@ -905,6 +985,35 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if uuo.mutation.OpenstackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: user.OpenstackTable, + Columns: []string{user.OpenstackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.OpenstackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: user.OpenstackTable, + Columns: []string{user.OpenstackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(openstack.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &User{config: uuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues From 19cb1448fca87a16bd16b1debc7b8bc7be6b93d0 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 00:15:02 -0500 Subject: [PATCH 34/49] new db for openstack reset timestamps --- ent/schema/openstack.go | 34 ++++++++++++++++++++++++++++++++++ ent/schema/user.go | 3 +++ 2 files changed, 37 insertions(+) create mode 100644 ent/schema/openstack.go diff --git a/ent/schema/openstack.go b/ent/schema/openstack.go new file mode 100644 index 0000000..5345194 --- /dev/null +++ b/ent/schema/openstack.go @@ -0,0 +1,34 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type Openstack struct { + ent.Schema +} + +// Fields of the Openstack. +// Default is set to January 1st, 0001, 00:00:00 UTC +func (Openstack) Fields() []ent.Field { + return []ent.Field{ + field.Time("timestamp"). + Comment("Time of last reset"). + Default(func() time.Time { + return time.Time{} + }), + } +} + +// Edges of the Openstack. +func (Openstack) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("user", User.Type). + Ref("openstack"). + Unique(), + } +} diff --git a/ent/schema/user.go b/ent/schema/user.go index 0859a16..0003dcb 100644 --- a/ent/schema/user.go +++ b/ent/schema/user.go @@ -43,5 +43,8 @@ func (User) Edges() []ent.Edge { edge.To("birthday", Birthday.Type). Unique(). Comment("Birthdays of the user"), + edge.To("openstack", Openstack.Type). + Unique(). + Comment("Openstacks Info of the user"), } } From 7866f391d4e615ac2d5a40410285177c94e8d4d2 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 00:15:24 -0500 Subject: [PATCH 35/49] data queries for openstack db --- data/main.go | 3 +++ data/openstack.go | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 data/openstack.go diff --git a/data/main.go b/data/main.go index 88672a5..7f29b5d 100644 --- a/data/main.go +++ b/data/main.go @@ -33,6 +33,9 @@ var ( // Birthday is the struct reference birthday Birthday *birthday_s = &birthday_s{} + + // Openstack is the struct reference openstack + Openstack *openstack_s = &openstack_s{} ) func init() { diff --git a/data/openstack.go b/data/openstack.go new file mode 100644 index 0000000..423d940 --- /dev/null +++ b/data/openstack.go @@ -0,0 +1,67 @@ +package data + +import ( + "time" + + "github.com/ritsec/ops-bot-iii/ent" + "github.com/ritsec/ops-bot-iii/ent/openstack" + "github.com/ritsec/ops-bot-iii/ent/user" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" +) + +// Openstack is the interface for interacting with the openstack table +type openstack_s struct{} + +// Get gets the timestamp for the last reset for Openstack account for a user +func (*openstack_s) Get(user_id string, ctx ddtrace.SpanContext) (*ent.Openstack, error) { + span := tracer.StartSpan( + "data.openstack:Get", + tracer.ResourceName("Data.Openstack.Get"), + tracer.ChildOf(ctx), + ) + defer span.Finish() + + return Client.Openstack.Query(). + Where( + openstack.HasUserWith( + user.ID(user_id), + ), + ). + WithUser(). + Only(Ctx) +} + +func (*openstack_s) Update(user_id string, ctx ddtrace.SpanContext) (*ent.Openstack, error) { + span := tracer.StartSpan( + "data.openstack:Update", + tracer.ResourceName("Data.Openstack.Update"), + tracer.ChildOf(ctx), + ) + defer span.Finish() + + user, err := Client.Openstack.Query(). + Where( + openstack.HasUserWith( + user.ID(user_id), + ), + ). + Only(Ctx) + if err != nil { + return nil, err + } + + tx, err := time.LoadLocation("America/New_York") + if err != nil { + return nil, err + } + + updatedUser, err := Client.Openstack.UpdateOne(user). + SetTimestamp(time.Now().In(tx)). + Save(Ctx) + if err != nil { + return nil, err + } + + return updatedUser, err +} From 9bc1aae218e8e4f828e30eb964c597c5f25b64d4 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 00:18:06 -0500 Subject: [PATCH 36/49] Added a prevention for reset spamming --- commands/slash/openstack.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index b2707da..6937dc1 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -3,6 +3,7 @@ package slash import ( "fmt" "strings" + "time" "github.com/bwmarrin/discordgo" "github.com/ritsec/ops-bot-iii/commands/slash/permission" @@ -134,6 +135,23 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d return } + // Get the user's openstack info + openstack_ent, err := data.Openstack.Get(i.Member.User.ID, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + tx, err := time.LoadLocation("America/New_York") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + // Check if the user has done the reset recently + if time.Now().In(tx).Sub(openstack_ent.Timestamp) >= -2*time.Hour && time.Now().In(tx).Sub(openstack_ent.Timestamp) <= 2*time.Hour { + helpers.UpdateMessage(s, i, "You have tried to reset too much in the past 2 hours, please wait before trying again!") + return + } + // Checking if the user is DM'able err = helpers.SendDirectMessage(s, i.Member.User.ID, "Checking to see if your DMs are open... your openstack account username and password will be sent here!", span.Context()) if err != nil { @@ -168,6 +186,13 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d if err != nil { logging.Error(s, err.Error(), i.Member.User, span) } + + // Update the timestamp for the last reset for the user + _, err = data.Openstack.Update(i.Member.User.ID, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } } else { return } From 0334c262dc451d1733959cec6e2fbdd9428937ec Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 00:18:26 -0500 Subject: [PATCH 37/49] go generate ./... --- go.sum | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go.sum b/go.sum index cf55955..cdd0325 100644 --- a/go.sum +++ b/go.sum @@ -193,6 +193,8 @@ github.com/mailgun/mailgun-go v2.0.0+incompatible h1:0FoRHWwMUctnd8KIR3vtZbqdfjp github.com/mailgun/mailgun-go v2.0.0+incompatible/go.mod h1:NWTyU+O4aczg/nsGhQnvHL6v2n5Gy6Sv5tNDVvC6FbU= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= @@ -207,6 +209,8 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= @@ -254,6 +258,8 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= From 992f99eca82caa1da84049a2348fbcf21f2c7951 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 02:24:48 -0500 Subject: [PATCH 38/49] Added missing check for error --- commands/slash/openstack.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index 6937dc1..b4cade0 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -148,7 +148,10 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } // Check if the user has done the reset recently if time.Now().In(tx).Sub(openstack_ent.Timestamp) >= -2*time.Hour && time.Now().In(tx).Sub(openstack_ent.Timestamp) <= 2*time.Hour { - helpers.UpdateMessage(s, i, "You have tried to reset too much in the past 2 hours, please wait before trying again!") + err = helpers.UpdateMessage(s, i, "You have tried to reset too much in the past 2 hours, please wait before trying again!") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } return } From 0eada9f5d0a6d93a233abb9119ccb9d12de49f66 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 14:03:32 -0500 Subject: [PATCH 39/49] Clarified the instructions --- commands/slash/member.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/slash/member.go b/commands/slash/member.go index 341aa78..c8bbd71 100644 --- a/commands/slash/member.go +++ b/commands/slash/member.go @@ -487,7 +487,7 @@ func recievedEmail(s *discordgo.Session, i *discordgo.InteractionCreate, userEma err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseUpdateMessage, Data: &discordgo.InteractionResponseData{ - Content: "A verification code has been sent to \"" + userEmail + "\". This could take up to 10 minutes and could be in your spam. Please check your spam! **Do not close discord or this window will be closed**.", + Content: "A verification code has been sent to \"" + userEmail + "\". This could take up to 15 minutes and could be in your spam. Please check your spam! **Do not close discord or this window will be closed**.", Components: []discordgo.MessageComponent{ discordgo.ActionsRow{ Components: []discordgo.MessageComponent{ From eb8dc3efc9976b92e22100cb6529598e8382a960 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 14:04:18 -0500 Subject: [PATCH 40/49] Added and enabled the new command verify --- commands/enabled.go | 1 + commands/slash/verify.go | 133 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 commands/slash/verify.go diff --git a/commands/enabled.go b/commands/enabled.go index 86ef3e3..a6068b4 100644 --- a/commands/enabled.go +++ b/commands/enabled.go @@ -36,6 +36,7 @@ func populateSlashCommands(ctx ddtrace.SpanContext) { SlashCommands["attendance"] = slash.Attendance SlashCommands["attendanceof"] = slash.Attendanceof SlashCommands["openstack"] = slash.Openstack + SlashCommands["verify"] = slash.Verify } // populateHandlers populates the Handlers map with all of the handlers diff --git a/commands/slash/verify.go b/commands/slash/verify.go new file mode 100644 index 0000000..53bbc1f --- /dev/null +++ b/commands/slash/verify.go @@ -0,0 +1,133 @@ +package slash + +import ( + "fmt" + "strings" + + "github.com/bwmarrin/discordgo" + "github.com/ritsec/ops-bot-iii/data" + "github.com/ritsec/ops-bot-iii/helpers" + "github.com/ritsec/ops-bot-iii/logging" + "github.com/ritsec/ops-bot-iii/mail" + "github.com/sirupsen/logrus" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" +) + +func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) { + return &discordgo.ApplicationCommand{ + Name: "verify", + Description: "Verify your email to use services like openstack and count for attendance", + }, + func(s *discordgo.Session, i *discordgo.InteractionCreate) { + span := tracer.StartSpan( + "commands.slash.verify:Verify", + tracer.ResourceName("/Verify"), + ) + defer span.Finish() + + logging.Debug(s, "Verify command received", i.Member.User, span) + helpers.InitialMessage(s, i, "Checking to see if you are verified...") + + if data.User.IsVerified(i.Member.User.ID, span.Context()) { + logging.Debug(s, "User is already verified", i.Member.User, span) + helpers.UpdateMessage(s, i, "You are already verified.") + return + } + + // check if user has an RIT userEmail + ritEmail, i, err := hasRITEmail(s, i, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + if ritEmail { + // get userEmail + userEmail, i, err := getEmail(s, i, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + logging.Debug(s, fmt.Sprintf("User provided email: `%v`", userEmail), i.Member.User, span) + + // check if userEmail is valid + if !validRITEmail(userEmail, span.Context()) { + logging.Debug(s, fmt.Sprintf("User has invalid RIT email: `%v`", userEmail), i.Member.User, span) + helpers.UpdateMessage(s, i, "Invalid RIT email.") + return + } + + // check if email is already in use + if data.User.EmailExists(i.Member.User.ID, userEmail, span.Context()) { + logging.Debug(s, fmt.Sprintf("User has already used email: `%v`", userEmail), i.Member.User, span) + helpers.UpdateMessage(s, i, "Email already in use.") + return + } + + // send userEmail + helpers.UpdateMessage(s, i, "Sending a verification email...") + code, err := mail.SendVerificationEmail(userEmail, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + logging.Debug(s, fmt.Sprintf("User send Email with verification code: `%v`", code), i.Member.User, span) + + // check if userEmail was recieved + recieved, i, err := recievedEmail(s, i, userEmail, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + if recieved { + + logging.Debug(s, fmt.Sprintf("User recieved email: `%v`", userEmail), i.Member.User, span) + + // get verification code + verificationCode, i, err := getVerificationCode(s, i, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + // check code + if strings.TrimSpace(code) != strings.TrimSpace(verificationCode) { + logging.Debug(s, "User provided invalid verification code", i.Member.User, span) + err := invalidCode(s, i, verificationCode, 0, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + } + return + } + + // add email to user + _, err = data.User.SetEmail(i.Member.User.ID, userEmail, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + // mark user as verified + _, err = data.User.MarkVerified(i.Member.User.ID, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + msg := "You have been verified as a member of RITSEC. Welcome!" + _, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{ + Content: &msg, + }) + if err != nil { + logging.Error(s, err.Error(), i.User, span, logrus.Fields{"error": err}) + return + } + } else { + helpers.UpdateMessage(s, i, "Verification canceled.") + } + } + } +} From 5da7a84dd4233e7a342094da288f410521596970 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 29 Nov 2024 14:08:43 -0500 Subject: [PATCH 41/49] Added missing error checks --- commands/slash/verify.go | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/commands/slash/verify.go b/commands/slash/verify.go index 53bbc1f..26e4e0c 100644 --- a/commands/slash/verify.go +++ b/commands/slash/verify.go @@ -26,11 +26,19 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc defer span.Finish() logging.Debug(s, "Verify command received", i.Member.User, span) - helpers.InitialMessage(s, i, "Checking to see if you are verified...") + err := helpers.InitialMessage(s, i, "Checking to see if you are verified...") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } if data.User.IsVerified(i.Member.User.ID, span.Context()) { logging.Debug(s, "User is already verified", i.Member.User, span) - helpers.UpdateMessage(s, i, "You are already verified.") + err = helpers.UpdateMessage(s, i, "You are already verified.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } return } @@ -54,19 +62,31 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc // check if userEmail is valid if !validRITEmail(userEmail, span.Context()) { logging.Debug(s, fmt.Sprintf("User has invalid RIT email: `%v`", userEmail), i.Member.User, span) - helpers.UpdateMessage(s, i, "Invalid RIT email.") + err = helpers.UpdateMessage(s, i, "Invalid RIT email.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } return } // check if email is already in use if data.User.EmailExists(i.Member.User.ID, userEmail, span.Context()) { logging.Debug(s, fmt.Sprintf("User has already used email: `%v`", userEmail), i.Member.User, span) - helpers.UpdateMessage(s, i, "Email already in use.") + err = helpers.UpdateMessage(s, i, "Email already in use.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } return } // send userEmail - helpers.UpdateMessage(s, i, "Sending a verification email...") + err = helpers.UpdateMessage(s, i, "Sending a verification email...") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } code, err := mail.SendVerificationEmail(userEmail, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) @@ -126,7 +146,11 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc return } } else { - helpers.UpdateMessage(s, i, "Verification canceled.") + err := helpers.UpdateMessage(s, i, "Verification canceled.") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } } } } From 686d44df861767e1ce1465966475548261c0daaa Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 6 Dec 2024 10:45:22 -0500 Subject: [PATCH 42/49] added comments --- osclient/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osclient/main.go b/osclient/main.go index fdea87f..fcfe698 100644 --- a/osclient/main.go +++ b/osclient/main.go @@ -13,11 +13,14 @@ import ( ) var ( - // networkClient is the global openstack identity client + // identityClient is the global openstack identity client identityClient *gophercloud.ServiceClient - networkClient *gophercloud.ServiceClient - storageClient *gophercloud.ServiceClient - computeClient *gophercloud.ServiceClient + // networkClient is the global openstack network client + networkClient *gophercloud.ServiceClient + // storageClient is the global openstack storage client + storageClient *gophercloud.ServiceClient + // computeClient is the global openstack compute client + computeClient *gophercloud.ServiceClient ) // Init() will make the clients during the compile From 7a8786f453610818eb34a64f59eea4649bd2436a Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 6 Dec 2024 10:45:41 -0500 Subject: [PATCH 43/49] restructured to use structs for easy modifying defaults --- osclient/user.go | 125 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 106 insertions(+), 19 deletions(-) diff --git a/osclient/user.go b/osclient/user.go index 828dad9..d9df8ed 100644 --- a/osclient/user.go +++ b/osclient/user.go @@ -17,6 +17,90 @@ import ( OBIIIConfig "github.com/ritsec/ops-bot-iii/config" ) +// networkOpts is a struct for the quotas to be applied in network service +type networkOpts struct { + FloatingIP int + Network int + Port int + Router int + Subnet int + SecurityGroup int + SecurityGroupRule int +} + +func newNetworkOpts() networkOpts { + return networkOpts{ + // FloatingIP specifies the number of floating IPs the user can allocate. + FloatingIP: 0, + // Network specifies the number of networks the user can create. + Network: 10, + // Port specifies the number of ports the user can create. + Port: 50, + // Router specifies the number of routers the user can create. + Router: 1, + // Subnet specifies the number of subnets the user can create. + Subnet: 20, + // SecurityGroup specifies the number of security groups the user can create. + SecurityGroup: 10, + // SecurityGroupRule specifies the number of security group rules the user can create. + SecurityGroupRule: -1, + } +} + +// QuotaOpts defines the quota options for a compute resource in OpenStack. +type quotaOpts struct { + InjectedFileContentBytes int + InjectedFilePathBytes int + InjectedFiles int + KeyPairs int + RAM int + Cores int + Instances int + ServerGroups int + ServerGroupMembers int +} + +func newQuotaOpts() quotaOpts { + return quotaOpts{ + // InjectedFileContentBytes specifies the number of bytes allowed for injected file content. + InjectedFileContentBytes: 10240, + // InjectedFilePathBytes specifies the number of bytes allowed for the path of injected files. + InjectedFilePathBytes: 255, + // InjectedFiles specifies the number of injected files allowed. + InjectedFiles: 5, + // KeyPairs specifies the number of key pairs allowed. + KeyPairs: 10, + // RAM specifies the amount of RAM (in megabytes) allowed. + RAM: 51200, + // Cores specifies the number of CPU cores allowed. + Cores: 20, + // Instances specifies the number of instances allowed. + Instances: 10, + // ServerGroups specifies the number of server groups allowed. + ServerGroups: 10, + // ServerGroupMembers specifies the number of members allowed per server group. + ServerGroupMembers: 10, + } +} + +// StorageOpts defines the quota options for block storage resources in OpenStack. +type StorageOpts struct { + Volumes int + Snapshots int + Gigabytes int +} + +func newStorageOpts() StorageOpts { + return StorageOpts{ + // Volumes specifies the number of volumes allowed. + Volumes: 10, + // Snapshots specifies the number of snapshots allowed. + Snapshots: 10, + // Gigabytes specifies the amount of storage (in gigabytes) allowed. + Gigabytes: 250, + } +} + // Returns the username portion of the email func extractUsername(email string) string { parts := strings.Split(email, "@") @@ -79,14 +163,15 @@ func Create(email string) (string, string, error) { return "", "", err } + defaultNetworkOpts := newNetworkOpts() networkOpts := network.UpdateOpts{ - FloatingIP: gophercloud.IntToPointer(0), - Network: gophercloud.IntToPointer(10), - Port: gophercloud.IntToPointer(50), - Router: gophercloud.IntToPointer(1), - Subnet: gophercloud.IntToPointer(20), - SecurityGroup: gophercloud.IntToPointer(10), - SecurityGroupRule: gophercloud.IntToPointer(-1), + FloatingIP: gophercloud.IntToPointer(defaultNetworkOpts.FloatingIP), + Network: gophercloud.IntToPointer(defaultNetworkOpts.Network), + Port: gophercloud.IntToPointer(defaultNetworkOpts.Port), + Router: gophercloud.IntToPointer(defaultNetworkOpts.Router), + Subnet: gophercloud.IntToPointer(defaultNetworkOpts.Subnet), + SecurityGroup: gophercloud.IntToPointer(defaultNetworkOpts.SecurityGroup), + SecurityGroupRule: gophercloud.IntToPointer(defaultNetworkOpts.SecurityGroupRule), } projectID := project.ID @@ -95,16 +180,17 @@ func Create(email string) (string, string, error) { return "", "", err } + defaultQuotaOpts := newQuotaOpts() quotaOpts := compute.UpdateOpts{ - InjectedFileContentBytes: gophercloud.IntToPointer(10240), - InjectedFilePathBytes: gophercloud.IntToPointer(255), - InjectedFiles: gophercloud.IntToPointer(5), - KeyPairs: gophercloud.IntToPointer(10), - RAM: gophercloud.IntToPointer(51200), - Cores: gophercloud.IntToPointer(20), - Instances: gophercloud.IntToPointer(10), - ServerGroups: gophercloud.IntToPointer(10), - ServerGroupMembers: gophercloud.IntToPointer(10), + InjectedFileContentBytes: gophercloud.IntToPointer(defaultQuotaOpts.InjectedFileContentBytes), + InjectedFilePathBytes: gophercloud.IntToPointer(defaultQuotaOpts.InjectedFilePathBytes), + InjectedFiles: gophercloud.IntToPointer(defaultQuotaOpts.InjectedFiles), + KeyPairs: gophercloud.IntToPointer(defaultQuotaOpts.KeyPairs), + RAM: gophercloud.IntToPointer(defaultQuotaOpts.RAM), + Cores: gophercloud.IntToPointer(defaultQuotaOpts.Cores), + Instances: gophercloud.IntToPointer(defaultQuotaOpts.Instances), + ServerGroups: gophercloud.IntToPointer(defaultQuotaOpts.ServerGroups), + ServerGroupMembers: gophercloud.IntToPointer(defaultQuotaOpts.ServerGroupMembers), } _, err = compute.Update(ctx, computeClient, projectID, quotaOpts).Extract() @@ -112,10 +198,11 @@ func Create(email string) (string, string, error) { return "", "", err } + defaultStorageOpts := newStorageOpts() storageOpts := blockstorage.UpdateOpts{ - Volumes: gophercloud.IntToPointer(10), - Snapshots: gophercloud.IntToPointer(10), - Gigabytes: gophercloud.IntToPointer(250), + Volumes: gophercloud.IntToPointer(defaultStorageOpts.Volumes), + Snapshots: gophercloud.IntToPointer(defaultStorageOpts.Snapshots), + Gigabytes: gophercloud.IntToPointer(defaultStorageOpts.Gigabytes), } _, err = blockstorage.Update(ctx, storageClient, projectID, storageOpts).Extract() From 903f07a547f897f16c7dc8ca8e916742960ac14b Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Fri, 6 Dec 2024 11:03:54 -0500 Subject: [PATCH 44/49] Removed helper messages --- commands/slash/verify.go | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/commands/slash/verify.go b/commands/slash/verify.go index 26e4e0c..ff8526f 100644 --- a/commands/slash/verify.go +++ b/commands/slash/verify.go @@ -6,7 +6,6 @@ import ( "github.com/bwmarrin/discordgo" "github.com/ritsec/ops-bot-iii/data" - "github.com/ritsec/ops-bot-iii/helpers" "github.com/ritsec/ops-bot-iii/logging" "github.com/ritsec/ops-bot-iii/mail" "github.com/sirupsen/logrus" @@ -26,19 +25,9 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc defer span.Finish() logging.Debug(s, "Verify command received", i.Member.User, span) - err := helpers.InitialMessage(s, i, "Checking to see if you are verified...") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) - return - } if data.User.IsVerified(i.Member.User.ID, span.Context()) { logging.Debug(s, "User is already verified", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "You are already verified.") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) - return - } return } @@ -62,31 +51,16 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc // check if userEmail is valid if !validRITEmail(userEmail, span.Context()) { logging.Debug(s, fmt.Sprintf("User has invalid RIT email: `%v`", userEmail), i.Member.User, span) - err = helpers.UpdateMessage(s, i, "Invalid RIT email.") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) - return - } return } // check if email is already in use if data.User.EmailExists(i.Member.User.ID, userEmail, span.Context()) { logging.Debug(s, fmt.Sprintf("User has already used email: `%v`", userEmail), i.Member.User, span) - err = helpers.UpdateMessage(s, i, "Email already in use.") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) - return - } return } // send userEmail - err = helpers.UpdateMessage(s, i, "Sending a verification email...") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) - return - } code, err := mail.SendVerificationEmail(userEmail, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) @@ -146,11 +120,7 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc return } } else { - err := helpers.UpdateMessage(s, i, "Verification canceled.") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) - return - } + return } } } From f52d8dac82090bddddd9937b15bd7393dc056b41 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Tue, 10 Dec 2024 00:05:18 -0500 Subject: [PATCH 45/49] Updated the message content to reflect the stupid RIT's filtiering email system --- commands/slash/member.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/slash/member.go b/commands/slash/member.go index c8bbd71..65f5eb4 100644 --- a/commands/slash/member.go +++ b/commands/slash/member.go @@ -487,7 +487,7 @@ func recievedEmail(s *discordgo.Session, i *discordgo.InteractionCreate, userEma err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseUpdateMessage, Data: &discordgo.InteractionResponseData{ - Content: "A verification code has been sent to \"" + userEmail + "\". This could take up to 15 minutes and could be in your spam. Please check your spam! **Do not close discord or this window will be closed**.", + Content: "A verification code has been sent to \"" + userEmail + "\". This email will take at least **12 minutes** to arrive and show up in the **spam** due to RIT's email filitering system. Please be patient and watch your spam box! **Do not close discord or this window will be closed**.", Components: []discordgo.MessageComponent{ discordgo.ActionsRow{ Components: []discordgo.MessageComponent{ From a1b1a18a6e5d0c861604a3f47da4c35094c80834 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Tue, 10 Dec 2024 00:05:48 -0500 Subject: [PATCH 46/49] Better error checking to make sure the timestamp exists --- commands/slash/openstack.go | 39 ++++++++++++++++++++++++++----------- data/openstack.go | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index b4cade0..b081248 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -135,24 +135,41 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d return } - // Get the user's openstack info - openstack_ent, err := data.Openstack.Get(i.Member.User.ID, span.Context()) + // Check to see if the user's reset timestamp exists + ts_exists, err := data.Openstack.Exists(i.Member.User.ID, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) return } - tx, err := time.LoadLocation("America/New_York") - if err != nil { - logging.Error(s, err.Error(), i.Member.User, span) - return - } - // Check if the user has done the reset recently - if time.Now().In(tx).Sub(openstack_ent.Timestamp) >= -2*time.Hour && time.Now().In(tx).Sub(openstack_ent.Timestamp) <= 2*time.Hour { - err = helpers.UpdateMessage(s, i, "You have tried to reset too much in the past 2 hours, please wait before trying again!") + if !ts_exists { + // Create the row for user's timestamp and don't check it + _, err = data.Openstack.Create(i.Member.User.ID, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span) + return + } + } else { + // Check the user's timestamp if has done recently + + // Get the user's openstacks info + openstack_ent, err := data.Openstack.Get(i.Member.User.ID, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + tx, err := time.LoadLocation("America/New_York") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + return + } + // Check if the user has done the reset recently + if time.Now().In(tx).Sub(openstack_ent.Timestamp) >= -2*time.Hour && time.Now().In(tx).Sub(openstack_ent.Timestamp) <= 2*time.Hour { + err = helpers.UpdateMessage(s, i, "You have tried to reset too much in the past 2 hours, please wait before trying again!") + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span) + } + return } - return } // Checking if the user is DM'able diff --git a/data/openstack.go b/data/openstack.go index 423d940..b08a519 100644 --- a/data/openstack.go +++ b/data/openstack.go @@ -13,6 +13,44 @@ import ( // Openstack is the interface for interacting with the openstack table type openstack_s struct{} +// Exists checks if a timestamp exists for a user +func (*openstack_s) Exists(user_id string, ctx ddtrace.SpanContext) (bool, error) { + span := tracer.StartSpan( + "data.Openstack:Exists", + tracer.ResourceName("Data.Openstack.Exists"), + tracer.ChildOf(ctx), + ) + defer span.Finish() + + return Client.Openstack.Query(). + Where( + openstack.HasUserWith( + user.ID(user_id), + ), + ). + Exist(Ctx) +} + +func (*openstack_s) Create(user_id string, ctx ddtrace.SpanContext) (*ent.Openstack, error) { + span := tracer.StartSpan( + "data.Openstack:Create", + tracer.ResourceName("Data.Openstack.Create"), + tracer.ChildOf(ctx), + ) + defer span.Finish() + + entUser, err := User.Get(user_id, ctx) + if err != nil { + return nil, err + } + + return Client.Openstack.Create(). + SetUser( + entUser, + ). + Save(Ctx) +} + // Get gets the timestamp for the last reset for Openstack account for a user func (*openstack_s) Get(user_id string, ctx ddtrace.SpanContext) (*ent.Openstack, error) { span := tracer.StartSpan( From 5a9b2f5eda58a256515919ad30d648e215055f90 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Wed, 18 Dec 2024 16:59:26 -0500 Subject: [PATCH 47/49] added function to check if user has done /member first --- commands/slash/verify.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/commands/slash/verify.go b/commands/slash/verify.go index ff8526f..62aafbf 100644 --- a/commands/slash/verify.go +++ b/commands/slash/verify.go @@ -12,6 +12,11 @@ import ( "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) +// The purpose of this command is for users who were manually verified through the /member command. +// The issue is that they then would have no email in the database but they still need to set their email +// if they want to use the openstack command to create their accounts. +// +// This is done by checking if their verification attempts is above 1, arbitrary locking out this command until they did /member command first. func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) { return &discordgo.ApplicationCommand{ Name: "verify", @@ -31,6 +36,17 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc return } + attempts, err := data.User.GetVerificationAttempts(i.Member.User.ID, span.Context()) + if err != nil { + logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) + return + } + + if attempts == 0 { + logging.Debug(s, "User has not used /member yet", i.Member.User, span) + return + } + // check if user has an RIT userEmail ritEmail, i, err := hasRITEmail(s, i, span.Context()) if err != nil { From 86a25f4bd9ede1bbab4101bd19b4e3c22726d785 Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Wed, 18 Dec 2024 17:05:43 -0500 Subject: [PATCH 48/49] removed isverified --- commands/slash/verify.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/commands/slash/verify.go b/commands/slash/verify.go index 62aafbf..90306f4 100644 --- a/commands/slash/verify.go +++ b/commands/slash/verify.go @@ -31,11 +31,6 @@ func Verify() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc logging.Debug(s, "Verify command received", i.Member.User, span) - if data.User.IsVerified(i.Member.User.ID, span.Context()) { - logging.Debug(s, "User is already verified", i.Member.User, span) - return - } - attempts, err := data.User.GetVerificationAttempts(i.Member.User.ID, span.Context()) if err != nil { logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err}) From b50e51c6be10a792b5108d813f56f87311251b5e Mon Sep 17 00:00:00 2001 From: Lukas Peters Date: Wed, 18 Dec 2024 17:56:29 -0500 Subject: [PATCH 49/49] Editted the response to show the right command --- commands/slash/openstack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/slash/openstack.go b/commands/slash/openstack.go index b081248..6d58822 100644 --- a/commands/slash/openstack.go +++ b/commands/slash/openstack.go @@ -64,7 +64,7 @@ func Openstack() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *d } if email == "" { logging.Debug(s, "User has no email", i.Member.User, span) - err = helpers.UpdateMessage(s, i, "You have no verified email. Run /member and verify your email and run this command again.") + err = helpers.UpdateMessage(s, i, "You have no verified email. Run /verify to add your email and run this command again.") if err != nil { logging.Error(s, err.Error(), i.Member.User, span) }