This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
74 lines (65 loc) · 1.77 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"context"
"github.com/prodyna/delete-from-enterprise/azure"
"github.com/prodyna/delete-from-enterprise/config"
"github.com/prodyna/delete-from-enterprise/github"
"github.com/prodyna/delete-from-enterprise/meta"
"github.com/prodyna/delete-from-enterprise/sync"
"log/slog"
"os"
)
func main() {
ctx := context.Background()
opts := &slog.HandlerOptions{
Level: slog.LevelDebug,
}
logger := slog.New(slog.NewTextHandler(os.Stdout, opts))
slog.SetDefault(logger)
slog.SetDefault(logger)
c, err := config.New()
if err != nil {
slog.Error("Unable to create config", "error", err)
os.Exit(1)
}
slog.Info("Starting [Delete from enterprise]", "version", meta.Version)
slog.Info("Configuration",
"githubEnterprise", c.GitHub.Enterprise,
"githubToken", "***",
"azureClientId", c.Azure.ClientId,
"azureClientSecret", "***",
"azureTenantId", c.Azure.TenantId,
"azureGroup", c.Azure.Group,
"dryRun", c.DryRun)
az, err := azure.New(ctx, azure.Config{
AzureClientId: c.Azure.ClientId,
AzureClientSecret: c.Azure.ClientSecret,
AzureTenantId: c.Azure.TenantId,
AzureGroup: c.Azure.Group,
})
if err != nil {
slog.Error("Unable to create Azure client", "error", err)
os.Exit(1)
}
slog.Info("Connected to azure",
"tenantId", c.Azure.TenantId,
"clientId", c.Azure.ClientId,
"group", c.Azure.Group)
gh, nil := github.New(ctx, github.Config{
Enterprise: c.GitHub.Enterprise,
Token: c.GitHub.Token,
DryRun: c.DryRun,
})
if err != nil {
slog.Error("Unable to create GitHub client", "error", err)
os.Exit(1)
}
slog.Info("Connected to GitHub",
"enterprise", c.GitHub.Enterprise,
"token", "***")
err = sync.Sync(ctx, *az, *gh)
if err != nil {
slog.Error("Unable to sync", "error", err)
os.Exit(1)
}
}