Skip to content

Commit

Permalink
fix validate sensor test
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhavPage committed Oct 6, 2018
1 parent e5a82ec commit c573229
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions controllers/sensor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ import (
"context"
"errors"
"time"

"fmt"
"log"

"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"

base "github.com/argoproj/argo-events"
"github.com/argoproj/argo-events/common"
"github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
sensorclientset "github.com/argoproj/argo-events/pkg/client/sensor/clientset/versioned"
"fmt"
"log"
)

const (
Expand Down
8 changes: 4 additions & 4 deletions controllers/sensor/signal-filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ func (se *sensorExecutionCtx) filterTime(timeFilter *v1alpha1.TimeFilter, eventT
se.log.Info().Str("date", currentTStr).Msg("current date")
if timeFilter.Start != "" && timeFilter.Stop != "" {
se.log.Info().Str("start time format", currentTStr+" "+timeFilter.Start).Msg("start time format")
startTime, err := time.Parse(common.StandardTimeFormat, currentTStr + " " + timeFilter.Start)
startTime, err := time.Parse(common.StandardTimeFormat, currentTStr+" "+timeFilter.Start)
if err != nil {
return false, err
}
se.log.Info().Str("start time", startTime.String()).Msg("start time")
startTime = startTime.UTC()
se.log.Info().Str("stop time format", currentTStr+" "+timeFilter.Stop).Msg("stop time format")
stopTime, err := time.Parse(common.StandardTimeFormat, currentTStr + " " + timeFilter.Stop)
stopTime, err := time.Parse(common.StandardTimeFormat, currentTStr+" "+timeFilter.Stop)
if err != nil {
return false, err
}
Expand All @@ -113,7 +113,7 @@ func (se *sensorExecutionCtx) filterTime(timeFilter *v1alpha1.TimeFilter, eventT
}
if timeFilter.Start != "" {
// stop is nil - does not have an end
startTime, err := time.Parse(common.StandardTimeFormat, currentTStr + " " + timeFilter.Start)
startTime, err := time.Parse(common.StandardTimeFormat, currentTStr+" "+timeFilter.Start)
if err != nil {
return false, err
}
Expand All @@ -122,7 +122,7 @@ func (se *sensorExecutionCtx) filterTime(timeFilter *v1alpha1.TimeFilter, eventT
return startTime.Before(eventTime.Time) || startTime.Equal(eventTime.Time), nil
}
if timeFilter.Stop != "" {
stopTime, err := time.Parse(common.StandardTimeFormat, currentTStr + " " + timeFilter.Stop)
stopTime, err := time.Parse(common.StandardTimeFormat, currentTStr+" "+timeFilter.Stop)
if err != nil {
return false, err
}
Expand Down
3 changes: 1 addition & 2 deletions controllers/sensor/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/argoproj/argo-events/common"
"github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ValidateSensor accepts a sensor and performs validation against it
Expand Down Expand Up @@ -105,7 +104,7 @@ func validateSignalTimeFilter(tFilter *v1alpha1.TimeFilter) error {
return err
}
stopTime = stopTime.UTC()
if stopTime.Before(currentT.Time) {
if stopTime.Before(currentT.UTC()) {
return fmt.Errorf("invalid signal time filter: stop '%s' is before the current time '%s'", tFilter.Stop, currentT)
}
}
Expand Down

0 comments on commit c573229

Please sign in to comment.