-
Notifications
You must be signed in to change notification settings - Fork 246
/
main.go
112 lines (98 loc) · 3.09 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
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
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
// Code generated by ack-generate. DO NOT EDIT.
package main
import (
"os"
ackcfg "github.com/aws/aws-controllers-k8s/pkg/config"
ackrt "github.com/aws/aws-controllers-k8s/pkg/runtime"
flag "github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrlrt "sigs.k8s.io/controller-runtime"
ctrlrtmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
svctypes "github.com/aws/aws-controllers-k8s/services/sagemaker/apis/v1alpha1"
svcresource "github.com/aws/aws-controllers-k8s/services/sagemaker/pkg/resource"
_ "github.com/aws/aws-controllers-k8s/services/sagemaker/pkg/resource/model"
_ "github.com/aws/aws-controllers-k8s/services/sagemaker/pkg/resource/processing_job"
_ "github.com/aws/aws-controllers-k8s/services/sagemaker/pkg/resource/training_job"
)
var (
awsServiceAPIGroup = "sagemaker.services.k8s.aws"
awsServiceAlias = "sagemaker"
scheme = runtime.NewScheme()
setupLog = ctrlrt.Log.WithName("setup")
)
func init() {
_ = clientgoscheme.AddToScheme(scheme)
_ = svctypes.AddToScheme(scheme)
}
func main() {
var ackCfg ackcfg.Config
ackCfg.BindFlags()
flag.Parse()
ackCfg.SetupLogger()
if err := ackCfg.Validate(); err != nil {
setupLog.Error(
err, "Unable to create controller manager",
"aws.service", awsServiceAlias,
)
os.Exit(1)
}
mgr, err := ctrlrt.NewManager(ctrlrt.GetConfigOrDie(), ctrlrt.Options{
Scheme: scheme,
Port: ackCfg.BindPort,
MetricsBindAddress: ackCfg.MetricsAddr,
LeaderElection: ackCfg.EnableLeaderElection,
LeaderElectionID: awsServiceAPIGroup,
})
if err != nil {
setupLog.Error(
err, "unable to create controller manager",
"aws.service", awsServiceAlias,
)
os.Exit(1)
}
stopChan := ctrlrt.SetupSignalHandler()
setupLog.Info(
"initializing service controller",
"aws.service", awsServiceAlias,
)
sc := ackrt.NewServiceController(
awsServiceAlias, awsServiceAPIGroup,
).WithLogger(
ctrlrt.Log,
).WithResourceManagerFactories(
svcresource.GetManagerFactories(),
).WithPrometheusRegistry(
ctrlrtmetrics.Registry,
)
if err = sc.BindControllerManager(mgr, ackCfg); err != nil {
setupLog.Error(
err, "unable bind to controller manager to service controller",
"aws.service", awsServiceAlias,
)
os.Exit(1)
}
setupLog.Info(
"starting manager",
"aws.service", awsServiceAlias,
)
if err := mgr.Start(stopChan); err != nil {
setupLog.Error(
err, "unable to start controller manager",
"aws.service", awsServiceAlias,
)
os.Exit(1)
}
}