Skip to content
Open
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
25 changes: 15 additions & 10 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
cmd.Flags().String("image", "", "An image built externally (ie, via CICD). Enabling it will skip the Integration build phase.")
cmd.Flags().StringArrayP("dependency", "d", nil, "A dependency that should be included, e.g., \"camel:mail\" for a Camel component, "+
"\"mvn:org.my:app:1.0\" for a Maven dependency")
cmd.Flags().BoolP("wait", "w", false, "Wait for the integration to be running")
cmd.Flags().BoolP("wait", "w", false, "Wait for the integration to be running or built (if --dont-run-after-build is enabled)")
cmd.Flags().StringP("kit", "k", "", "The kit used to run the integration")
cmd.Flags().StringArrayP("property", "p", nil, "Add a runtime property or a local properties file from a path "+
"(syntax: [my-key=my-value|file:/path/to/my-conf.properties])")
Expand Down Expand Up @@ -127,9 +127,9 @@
*RootCmdOptions `json:"-"`

// Deprecated: won't be supported in the future
Compression bool `mapstructure:"compression" yaml:",omitempty"`
Wait bool `mapstructure:"wait" yaml:",omitempty"`
Logs bool `mapstructure:"logs" yaml:",omitempty"`
Compression bool `mapstructure:"compression" yaml:",omitempty"`

Check failure on line 130 in pkg/cmd/run.go

View workflow job for this annotation

GitHub Actions / validate

File is not properly formatted (gofmt)
Wait bool `mapstructure:"wait" yaml:",omitempty"`
Logs bool `mapstructure:"logs" yaml:",omitempty"`
// Deprecated: won't be supported in the future
Sync bool `mapstructure:"sync" yaml:",omitempty"`
// Deprecated: won't be supported in the future
Expand Down Expand Up @@ -383,15 +383,20 @@
})
}
if o.Wait || o.Dev {
phase := v1.IntegrationPhaseRunning
if o.DontRunAfterBuild {
phase = v1.IntegrationPhaseBuildComplete
}

for {
integrationPhase, err := o.waitForIntegrationReady(cmd, c, integration)
if err != nil {
return err
integrationPhase, waitErr := o.waitForIntegrationPhase(cmd, c, integration, phase)
if waitErr != nil {
return waitErr
}

if integrationPhase == nil || *integrationPhase == v1.IntegrationPhaseError {
return fmt.Errorf("integration \"%s\" deployment failed", integration.Name)
} else if *integrationPhase == v1.IntegrationPhaseRunning {
} else if *integrationPhase == phase {
break
}

Expand Down Expand Up @@ -444,7 +449,7 @@
return nil
}

func (o *runCmdOptions) waitForIntegrationReady(cmd *cobra.Command, c client.Client, integration *v1.Integration) (*v1.IntegrationPhase, error) {
func (o *runCmdOptions) waitForIntegrationPhase(cmd *cobra.Command, c client.Client, integration *v1.Integration, wanted v1.IntegrationPhase) (*v1.IntegrationPhase, error) {
handler := func(i *v1.Integration) bool {
//
// TODO when we add health checks, we should Wait until they are passed
Expand All @@ -453,7 +458,7 @@
// TODO remove this log when we make sure that events are always created
fmt.Fprintf(cmd.OutOrStdout(), "Progress: integration %q in phase %s\n", integration.Name, string(i.Status.Phase))
}
if i.Status.Phase == v1.IntegrationPhaseRunning || i.Status.Phase == v1.IntegrationPhaseError {
if i.Status.Phase == wanted || i.Status.Phase == v1.IntegrationPhaseError {
return false
}

Expand Down
Loading