| 1 | package sweepersscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.17 fmt/" |
| 5 | |
| 6 | functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ "github.com/scaleway/scaleway-sdk-go/api/function/v1beta1scip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/" |
| 7 | "github.com/scaleway/scaleway-sdk-go/loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/" |
| 8 | "github.com/scaleway/scaleway-sdk-go/scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/" |
| 9 | ) |
| 10 | |
| 11 | func SweepTriggersscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepTriggers().(scwClient *scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Clientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Client#, region scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Region#) error { |
| 12 | functionAPI := functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.NewAPIscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/NewAPI().(scwClient) |
| 13 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Warningfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Warningf().("sweeper: destroying the function triggers in (%s)", region) |
| 14 | listTriggers, err := functionAPI.ListTriggersscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#ListTriggers().( |
| 15 | &functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.ListTriggersRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListTriggersRequest#{ |
| 16 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListTriggersRequest#Region.: region, |
| 17 | }, scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.WithAllPagesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithAllPages().()) |
| 18 | if err != nil { |
| 19 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error listing trigger in (%s) in sweeper: %s", region, err) |
| 20 | } |
| 21 | |
| 22 | for _, trigger := range listTriggers.Triggersscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListTriggersResponse#Triggers. { |
| 23 | _, err := functionAPI.DeleteTriggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#DeleteTrigger().(&functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.DeleteTriggerRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteTriggerRequest#{ |
| 24 | TriggerIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteTriggerRequest#TriggerID.: trigger.IDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/Trigger#ID., |
| 25 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteTriggerRequest#Region.: region, |
| 26 | }) |
| 27 | if err != nil { |
| 28 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error deleting trigger in sweeper: %s", err) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return nil |
| 33 | } |
| 34 | |
| 35 | func SweepNamespacesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepNamespaces().(scwClient *scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Clientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Client#, region scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Region#) error { |
| 36 | functionAPI := functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.NewAPIscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/NewAPI().(scwClient) |
| 37 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Debugfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Debugf().("sweeper: destroying the function namespaces in (%s)", region) |
| 38 | listNamespaces, err := functionAPI.ListNamespacesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#ListNamespaces().( |
| 39 | &functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.ListNamespacesRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListNamespacesRequest#{ |
| 40 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListNamespacesRequest#Region.: region, |
| 41 | }, scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.WithAllPagesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithAllPages().()) |
| 42 | if err != nil { |
| 43 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error listing namespaces in (%s) in sweeper: %s", region, err) |
| 44 | } |
| 45 | |
| 46 | for _, ns := range listNamespaces.Namespacesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListNamespacesResponse#Namespaces. { |
| 47 | _, err := functionAPI.DeleteNamespacescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#DeleteNamespace().(&functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.DeleteNamespaceRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteNamespaceRequest#{ |
| 48 | NamespaceIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteNamespaceRequest#NamespaceID.: ns.IDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/Namespace#ID., |
| 49 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteNamespaceRequest#Region.: region, |
| 50 | }) |
| 51 | if err != nil { |
| 52 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Debugfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Debugf().("sweeper: error (%s)", err) |
| 53 | |
| 54 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error deleting namespace in sweeper: %s", err) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return nil |
| 59 | } |
| 60 | |
| 61 | func SweepFunctionsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepFunctions().(scwClient *scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Clientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Client#, region scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Region#) error { |
| 62 | functionAPI := functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.NewAPIscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/NewAPI().(scwClient) |
| 63 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Warningfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Warningf().("sweeper: destroying the function in (%s)", region) |
| 64 | listFunctions, err := functionAPI.ListFunctionsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#ListFunctions().( |
| 65 | &functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.ListFunctionsRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListFunctionsRequest#{ |
| 66 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListFunctionsRequest#Region.: region, |
| 67 | }, scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.WithAllPagesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithAllPages().()) |
| 68 | if err != nil { |
| 69 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error listing functions in (%s) in sweeper: %s", region, err) |
| 70 | } |
| 71 | |
| 72 | for _, f := range listFunctions.Functionsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListFunctionsResponse#Functions. { |
| 73 | _, err := functionAPI.DeleteFunctionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#DeleteFunction().(&functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.DeleteFunctionRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteFunctionRequest#{ |
| 74 | FunctionIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteFunctionRequest#FunctionID.: f.IDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/Function#ID., |
| 75 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteFunctionRequest#Region.: region, |
| 76 | }) |
| 77 | if err != nil { |
| 78 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error deleting functions in sweeper: %s", err) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | return nil |
| 83 | } |
| 84 | |
| 85 | func SweepCronsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepCrons().(scwClient *scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Clientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Client#, region scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Region#) error { |
| 86 | functionAPI := functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.NewAPIscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/NewAPI().(scwClient) |
| 87 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Warningfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Warningf().("sweeper: destroying the function cron in (%s)", region) |
| 88 | listCron, err := functionAPI.ListCronsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#ListCrons().( |
| 89 | &functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.ListCronsRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListCronsRequest#{ |
| 90 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListCronsRequest#Region.: region, |
| 91 | }, scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.WithAllPagesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithAllPages().()) |
| 92 | if err != nil { |
| 93 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error listing cron in (%s) in sweeper: %s", region, err) |
| 94 | } |
| 95 | |
| 96 | for _, cron := range listCron.Cronsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/ListCronsResponse#Crons. { |
| 97 | _, err := functionAPI.DeleteCronscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#DeleteCron().(&functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.DeleteCronRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteCronRequest#{ |
| 98 | CronIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteCronRequest#CronID.: cron.IDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/Cron#ID., |
| 99 | Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/DeleteCronRequest#Region.: region, |
| 100 | }) |
| 101 | if err != nil { |
| 102 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.17 fmt/Errorf().("error deleting cron in sweeper: %s", err) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | func SweepAllLocalitiesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepAllLocalities().(scwClient *scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Clientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Client#) error { |
| 110 | for _, region := range (&functionSDKscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/.APIscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#{}).Regionsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1`/API#Regions().() { |
| 111 | err := SweepTriggersscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepTriggers().(scwClient, region) |
| 112 | if err != nil { |
| 113 | return err |
| 114 | } |
| 115 | err = SweepNamespacesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepNamespaces().(scwClient, region) |
| 116 | if err != nil { |
| 117 | return err |
| 118 | } |
| 119 | err = SweepFunctionsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepFunctions().(scwClient, region) |
| 120 | if err != nil { |
| 121 | return err |
| 122 | } |
| 123 | err = SweepCronsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/function/v1beta1/sweepers`/SweepCrons().(scwClient, region) |
| 124 | if err != nil { |
| 125 | return err |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | return nil |
| 130 | } |