-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add option to turn on/off the new controller
A new and already deprecated boolean command line option —v07-controller turn v0.7 controller implementation on if true, and the new v0.8 implementation will be used if false. v0.8 will be released with this option (default false) and will be removed on v0.9 with all legacy controller code.
- Loading branch information
1 parent
4b1d58c
commit a8170ee
Showing
8 changed files
with
223 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
Copyright 2019 The HAProxy Ingress Controller Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License 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. | ||
*/ | ||
|
||
package controller | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
api "k8s.io/api/core/v1" | ||
|
||
"github.com/jcmoraisjr/haproxy-ingress/pkg/common/ingress" | ||
) | ||
|
||
type cache struct { | ||
listers *ingress.StoreLister | ||
} | ||
|
||
func (c *cache) GetService(serviceName string) (*api.Service, error) { | ||
return c.listers.Service.GetByName(serviceName) | ||
} | ||
|
||
func (c *cache) GetEndpoints(service *api.Service) (*api.Endpoints, error) { | ||
ep, err := c.listers.Endpoint.GetServiceEndpoints(service) | ||
return &ep, err | ||
} | ||
|
||
func (c *cache) GetPod(podName string) (*api.Pod, error) { | ||
sname := strings.Split(podName, "/") | ||
if len(sname) != 2 { | ||
return nil, fmt.Errorf("invalid pod name: '%s'", podName) | ||
} | ||
return c.listers.Pod.GetPod(sname[0], sname[1]) | ||
} | ||
|
||
func (c *cache) GetTLSSecretPath(secretName string) (string, error) { | ||
return "", fmt.Errorf("implement") | ||
} | ||
|
||
func (c *cache) GetCASecretPath(secretName string) (string, error) { | ||
return "", fmt.Errorf("implement") | ||
} | ||
|
||
func (c *cache) GetSecretContent(secretName, keyName string) ([]byte, error) { | ||
return []byte{}, fmt.Errorf("implement") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright 2019 The HAProxy Ingress Controller Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License 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. | ||
*/ | ||
|
||
package controller | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/golang/glog" | ||
) | ||
|
||
type logger struct { | ||
depth int | ||
} | ||
|
||
func (l *logger) build(msg string, args ...interface{}) string { | ||
if len(args) == 0 { | ||
return msg | ||
} | ||
return fmt.Sprintf(msg, args) | ||
} | ||
|
||
func (l *logger) InfoV(v int, msg string, args ...interface{}) { | ||
if glog.V(glog.Level(v)) { | ||
glog.InfoDepth(l.depth, l.build(msg, args)) | ||
} | ||
} | ||
|
||
func (l *logger) Info(msg string, args ...interface{}) { | ||
glog.InfoDepth(l.depth, l.build(msg, args)) | ||
} | ||
|
||
func (l *logger) Warn(msg string, args ...interface{}) { | ||
glog.WarningDepth(l.depth, l.build(msg, args)) | ||
} | ||
|
||
func (l *logger) Error(msg string, args ...interface{}) { | ||
glog.ErrorDepth(l.depth, l.build(msg, args)) | ||
} | ||
|
||
func (l *logger) Fatal(msg string, args ...interface{}) { | ||
glog.FatalDepth(l.depth, l.build(msg, args)) | ||
} |
File renamed without changes.
File renamed without changes.