Skip to content

Commit

Permalink
Enable status subresource for integration
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti authored and nicolaferraro committed Jan 22, 2019
1 parent 51f2f4c commit f7714fe
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions deploy/crd-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ spec:
group: camel.apache.org
scope: Namespaced
version: v1alpha1
subresources:
status: {}
names:
kind: Integration
listKind: IntegrationList
Expand Down
2 changes: 2 additions & 0 deletions deploy/resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/controller/integration/build_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (action *buildContextAction) Handle(ctx context.Context, integration *v1alp
// with a context
target := integration.DeepCopy()
target.Status.Context = ""
return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}
}

Expand All @@ -83,7 +83,7 @@ func (action *buildContextAction) Handle(ctx context.Context, integration *v1alp

logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

if ictx.Status.Phase == v1alpha1.IntegrationContextPhaseReady {
Expand All @@ -104,14 +104,14 @@ func (action *buildContextAction) Handle(ctx context.Context, integration *v1alp

logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

if integration.Status.Context == "" {
// We need to set the context
target := integration.DeepCopy()
target.Status.Context = ictx.Name
return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

return nil
Expand Down Expand Up @@ -145,5 +145,5 @@ func (action *buildContextAction) Handle(ctx context.Context, integration *v1alp
target := integration.DeepCopy()
target.Status.Context = platformCtxName

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}
4 changes: 2 additions & 2 deletions pkg/controller/integration/build_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (action *buildImageAction) handleBuildStateChange(ctx context.Context, res

logrus.Infof("Integration %s transitioning to state %s, reason: %s", target.Name, target.Status.Phase, res.Error.Error())

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
case builder.StatusCompleted:
target.Status.Phase = v1alpha1.IntegrationPhaseDeploying
if res.PublicImage != "" {
Expand All @@ -164,7 +164,7 @@ func (action *buildImageAction) handleBuildStateChange(ctx context.Context, res

logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)

if err := action.client.Update(ctx, target); err != nil {
if err := action.client.Status().Update(ctx, target); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/integration/build_image_failure_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (action *errorRecoveryAction) Handle(ctx context.Context, integration *v1al

logrus.Infof("Max recovery attempt reached for integration %s, transition to phase %s", integration.Name, string(target.Status.Phase))

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

if integration.Status.Failure != nil {
Expand Down Expand Up @@ -97,7 +97,7 @@ func (action *errorRecoveryAction) Handle(ctx context.Context, integration *v1al
target.Status.Failure.Recovery.AttemptMax,
)

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/integration/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ func (action *deployAction) Handle(ctx context.Context, integration *v1alpha1.In
target.Status.Phase = v1alpha1.IntegrationPhaseRunning
logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}
8 changes: 4 additions & 4 deletions pkg/controller/integration/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (action *initializeAction) Handle(ctx context.Context, integration *v1alpha

logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

return nil
Expand All @@ -74,15 +74,15 @@ func (action *initializeAction) Handle(ctx context.Context, integration *v1alpha
}

//
// restore phase to initial phase ase traits are not aware of
// restore phase to initial phase as traits are not aware of
// WaitingForPlatform phase
//
if integration.Status.Phase == v1alpha1.IntegrationPhaseWaitingForPlatform {
target := integration.DeepCopy()
target.Status.Phase = v1alpha1.IntegrationPhaseInitial
target.Status.Digest = dgst

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

// better not changing the spec section of the target because it may be used for comparison by a
Expand All @@ -109,5 +109,5 @@ func (action *initializeAction) Handle(ctx context.Context, integration *v1alpha

logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}
2 changes: 1 addition & 1 deletion pkg/controller/integration/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1alpha1.I

logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)

return action.client.Update(ctx, target)
return action.client.Status().Update(ctx, target)
}

// TODO check also if deployment matches (e.g. replicas)
Expand Down

0 comments on commit f7714fe

Please sign in to comment.