Skip to content

Commit

Permalink
Merge pull request #2156 from nkubala/remove-plugin-event
Browse files Browse the repository at this point in the history
Remove some old plugin related code from event handler
  • Loading branch information
dgageot authored May 21, 2019
2 parents 0f2cb02 + 4b94078 commit fb7c2a4
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions pkg/skaffold/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@ limitations under the License.
package event

import (
"context"
"encoding/json"
"fmt"
"sync"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/event/proto"
runcontext "github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/context"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"
"google.golang.org/grpc"
)

const (
Expand All @@ -40,11 +37,8 @@ const (
)

var (
handler *eventHandler
once sync.Once
pluginMode bool

cli proto.SkaffoldServiceClient // for plugin RPC connections
handler *eventHandler
once sync.Once
)

type eventHandler struct {
Expand Down Expand Up @@ -158,16 +152,6 @@ func InitializeState(runCtx *runcontext.RunContext) (func() error, error) {
return serverShutdown, err
}

func SetupRPCClient(opts *config.SkaffoldOptions) error {
pluginMode = true
conn, err := grpc.Dial(fmt.Sprintf(":%d", opts.RPCPort), grpc.WithInsecure())
if err != nil {
return errors.Wrap(err, "opening gRPC connection to remote skaffold process")
}
cli = proto.NewSkaffoldServiceClient(conn)
return nil
}

// DeployInProgress notifies that a deployment has been started.
func DeployInProgress() {
handler.handleDeployEvent(&proto.DeployEvent{Status: InProgress})
Expand Down Expand Up @@ -200,7 +184,7 @@ func BuildComplete(imageName string) {

// PortForwarded notifies that a remote port has been forwarded locally.
func PortForwarded(localPort, remotePort int32, podName, containerName, namespace string, portName string) {
handler.doHandle(&proto.Event{
go handler.handle(&proto.Event{
EventType: &proto.Event_PortEvent{
PortEvent: &proto.PortEvent{
LocalPort: localPort,
Expand All @@ -215,29 +199,21 @@ func PortForwarded(localPort, remotePort int32, podName, containerName, namespac
}

func (ev *eventHandler) handleDeployEvent(e *proto.DeployEvent) {
ev.doHandle(&proto.Event{
go ev.handle(&proto.Event{
EventType: &proto.Event_DeployEvent{
DeployEvent: e,
},
})
}

func (ev *eventHandler) handleBuildEvent(e *proto.BuildEvent) {
ev.doHandle(&proto.Event{
go ev.handle(&proto.Event{
EventType: &proto.Event_BuildEvent{
BuildEvent: e,
},
})
}

func (ev *eventHandler) doHandle(event *proto.Event) {
if pluginMode {
go cli.Handle(context.Background(), event)
} else {
go ev.handle(event)
}
}

func LogSkaffoldMetadata(info *version.Info) {
handler.logEvent(proto.LogEntry{
Timestamp: ptypes.TimestampNow(),
Expand Down

0 comments on commit fb7c2a4

Please sign in to comment.