GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stackapps/main.go at main · criticalstack/stackapps

This repository was archived by the owner on Nov 20, 2021. It is now read-only.

Expand file tree

/

main.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
128 lines (113 loc) · 3.49 KB
/

main.go

Copy path

File metadata and controls

128 lines (113 loc) · 3.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package main
import (
"flag"
"fmt"
"os"
"github.com/prometheus/client_golang/api"
promv1 "github.com/prometheus/client_golang/api/prometheus/v1"
"go.uber.org/zap/zapcore"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
featuresv1alpha1 "github.com/criticalstack/stackapps/api/v1alpha1"
"github.com/criticalstack/stackapps/controllers"
// +kubebuilder:scaffold:imports
)
var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
)
const (
DefaultPrometheusEndpoint = "http://cs-prometheus-server.critical-stack.svc.cluster.local:9090"
)
func init() {
_ = clientgoscheme.AddToScheme(scheme)
_ = featuresv1alpha1.AddToScheme(scheme)
// +kubebuilder:scaffold:scheme
}
func main() {
var metricsAddr string
var enableLeaderElection bool
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.Parse()
promAddr := os.Getenv("PROMETHEUS_ENDPOINT")
var config api.Config
if promAddr != "" {
config.Address = promAddr
} else {
config.Address = DefaultPrometheusEndpoint
}
client, err := api.NewClient(config)
if err != nil {
setupLog.Error(err, "unable to start prometheus client")
os.Exit(1)
}
ctrl.SetLogger(zap.New(zap.StacktraceLevel(zapcore.FatalLevel), zap.UseDevMode(true)))
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: "7830725e.criticalstack.com",
})
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}
reconcilers := []interface {
SetupWithManager(ctrl.Manager) error
}{
&controllers.StackAppReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("StackApps"),
Scheme: mgr.GetScheme(),
},
&controllers.AppRevisionReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("AppRevisions"),
Scheme: mgr.GetScheme(),
},
&controllers.StackValueReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("StackValues"),
Scheme: mgr.GetScheme(),
},
&controllers.StackReleaseReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("StackReleases"),
Scheme: mgr.GetScheme(),
Metrics: promv1.NewAPI(client),
},
}
for _, r := range reconcilers {
if err := r.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "StackApps")
os.Exit(1)
}
}
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
whTypes := []interface {
SetupWebhookWithManager(ctrl.Manager) error
}{
&featuresv1alpha1.StackApp{},
&featuresv1alpha1.AppRevision{},
&featuresv1alpha1.VerificationKey{},
}
for _, t := range whTypes {
if err = t.SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", fmt.Sprintf("%T", t))
os.Exit(1)
}
}
}
setupLog.Info("Starting manager")
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
setupLog.Error(err, "Manager exited non-zero")
os.Exit(1)
}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.