Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some old plugin related code from event handler #2156

Merged
merged 1 commit into from
May 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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