Skip to content

Commit

Permalink
fixups to transport/stunnel based on feedback
Browse files Browse the repository at this point in the history
Co-authored-by: John Strunk <[email protected]>
Signed-off-by: Alay Patel <[email protected]>
  • Loading branch information
alaypatel07 and JohnStrunk committed Dec 1, 2021
1 parent c5f95af commit 207aed0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 11 additions & 5 deletions transport/stunnel/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
client = yes
syslog = no
output = /dev/stdout
[rsync]
[transfer]
debug = 7
accept = {{ .listenPort }}
cert = /etc/stunnel/certs/tls.crt
Expand All @@ -50,7 +50,7 @@ const (

type client struct {
logger logr.Logger
ingressPort int32
connectPort int32
listenPort int32
containers []corev1.Container
volumes []corev1.Volume
Expand All @@ -68,7 +68,7 @@ func (sc *client) NamespacedName() types.NamespacedName {
}

func (sc *client) ConnectPort() int32 {
return sc.ingressPort
return sc.connectPort
}

func (sc *client) ListenPort() int32 {
Expand Down Expand Up @@ -102,17 +102,23 @@ func (sc *client) Hostname() string {
return "localhost"
}

// NewClient creates the stunnel client object, deploys the resource on the cluster
// and then generates the necessary containers and volumes for transport to consume.
//
// Before passing the client c make sure to call AddToScheme() if core types are not already registered
// In order to generate the right RBAC, add the following lines to the Reconcile function annotations.
// +kubebuilder:rbac:groups=core,resources=configmaps,secrets,verbs=get;list;watch;create;update;patch;delete
func NewClient(ctx context.Context, c ctrlclient.Client, logger logr.Logger,
namespacedName types.NamespacedName,
hostname string,
ingressPort int32,
connectPort int32,
options *transport.Options) (transport.Transport, error) {
clientLogger := logger.WithValues("stunnelClient", namespacedName)
tc := &client{
logger: clientLogger,
namespacedName: namespacedName,
options: options,
ingressPort: ingressPort,
connectPort: connectPort,
serverHostname: hostname,
listenPort: clientListenPort,
}
Expand Down
6 changes: 6 additions & 0 deletions transport/stunnel/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ type server struct {
namespacedName types.NamespacedName
}

// NewServer creates the stunnel server object, deploys the resource on the cluster
// and then generates the necessary containers and volumes for transport to consume.
//
// Before passing the client c make sure to call AddToScheme() if core types are not already registered
// In order to generate the right RBAC, add the following lines to the Reconcile function annotations.
// +kubebuilder:rbac:groups=core,resources=configmaps,secrets,verbs=get;list;watch;create;update;patch;delete
func NewServer(ctx context.Context, c ctrlclient.Client, logger logr.Logger,
namespacedName types.NamespacedName,
e endpoint.Endpoint,
Expand Down

0 comments on commit 207aed0

Please sign in to comment.