This is an automated email from the ASF dual-hosted git repository. tsato pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 5d351d0f20a8e2c4b5e64a947c6950fc71f09cf5 Author: Tadayoshi Sato <sato.tadayo...@gmail.com> AuthorDate: Thu Jul 14 15:18:04 2022 +0900 chore(lint): fix containedctx --- pkg/builder/types.go | 1 + pkg/cmd/root.go | 1 + pkg/controller/integration/monitor.go | 5 ++--- pkg/controller/integration/monitor_cronjob.go | 5 ++--- pkg/controller/integration/monitor_deployment.go | 3 ++- pkg/controller/integration/monitor_knative.go | 4 +++- pkg/trait/trait_types.go | 1 + pkg/util/bindings/api.go | 1 + pkg/util/cancellable/cancellable.go | 1 + 9 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/builder/types.go b/pkg/builder/types.go index 5d3fef9b6..bbd684d6b 100644 --- a/pkg/builder/types.go +++ b/pkg/builder/types.go @@ -72,6 +72,7 @@ type resource struct { Content []byte } +// nolint: containedctx type builderContext struct { client.Client C context.Context diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index c32a187e1..b75afd321 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -40,6 +40,7 @@ superpowers. ` // RootCmdOptions --. +// nolint: containedctx type RootCmdOptions struct { RootContext context.Context `mapstructure:"-"` Context context.Context `mapstructure:"-"` diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go index c2f645948..5413390e4 100644 --- a/pkg/controller/integration/monitor.go +++ b/pkg/controller/integration/monitor.go @@ -168,7 +168,7 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra } type controller interface { - checkReadyCondition() (bool, error) + checkReadyCondition(ctx context.Context) (bool, error) getPodSpec() corev1.PodSpec updateReadyCondition(readyPods []corev1.Pod) bool } @@ -195,7 +195,6 @@ func (action *monitorAction) newController(ctx context.Context, env *trait.Envir obj: obj.(*batchv1.CronJob), integration: integration, client: action.client, - context: ctx, } default: return nil, fmt.Errorf("unsupported controller for integration %s", integration.Name) @@ -221,7 +220,7 @@ func (action *monitorAction) updateIntegrationPhaseAndReadyCondition(ctx context return err } - if done, err := controller.checkReadyCondition(); done || err != nil { + if done, err := controller.checkReadyCondition(ctx); done || err != nil { return err } if done := checkPodStatuses(integration, pendingPods, runningPods); done { diff --git a/pkg/controller/integration/monitor_cronjob.go b/pkg/controller/integration/monitor_cronjob.go index 77bf162b8..203938943 100644 --- a/pkg/controller/integration/monitor_cronjob.go +++ b/pkg/controller/integration/monitor_cronjob.go @@ -35,17 +35,16 @@ type cronJobController struct { obj *batchv1.CronJob integration *v1.Integration client client.Client - context context.Context lastCompletedJob *batchv1.Job } var _ controller = &cronJobController{} -func (c *cronJobController) checkReadyCondition() (bool, error) { +func (c *cronJobController) checkReadyCondition(ctx context.Context) (bool, error) { // Check latest job result if lastScheduleTime := c.obj.Status.LastScheduleTime; lastScheduleTime != nil && len(c.obj.Status.Active) == 0 { jobs := batchv1.JobList{} - if err := c.client.List(c.context, &jobs, + if err := c.client.List(ctx, &jobs, ctrl.InNamespace(c.integration.Namespace), ctrl.MatchingLabels{v1.IntegrationLabel: c.integration.Name}, ); err != nil { diff --git a/pkg/controller/integration/monitor_deployment.go b/pkg/controller/integration/monitor_deployment.go index 9cf748ff6..097fa73d5 100644 --- a/pkg/controller/integration/monitor_deployment.go +++ b/pkg/controller/integration/monitor_deployment.go @@ -18,6 +18,7 @@ limitations under the License. package integration import ( + "context" "fmt" appsv1 "k8s.io/api/apps/v1" @@ -34,7 +35,7 @@ type deploymentController struct { var _ controller = &deploymentController{} -func (c *deploymentController) checkReadyCondition() (bool, error) { +func (c *deploymentController) checkReadyCondition(ctx context.Context) (bool, error) { // Check the Deployment progression if progressing := kubernetes.GetDeploymentCondition(*c.obj, appsv1.DeploymentProgressing); progressing != nil && progressing.Status == corev1.ConditionFalse && progressing.Reason == "ProgressDeadlineExceeded" { c.integration.Status.Phase = v1.IntegrationPhaseError diff --git a/pkg/controller/integration/monitor_knative.go b/pkg/controller/integration/monitor_knative.go index cf8d09860..c8182266e 100644 --- a/pkg/controller/integration/monitor_knative.go +++ b/pkg/controller/integration/monitor_knative.go @@ -18,6 +18,8 @@ limitations under the License. package integration import ( + "context" + corev1 "k8s.io/api/core/v1" servingv1 "knative.dev/serving/pkg/apis/serving/v1" @@ -33,7 +35,7 @@ type knativeServiceController struct { var _ controller = &knativeServiceController{} -func (c *knativeServiceController) checkReadyCondition() (bool, error) { +func (c *knativeServiceController) checkReadyCondition(ctx context.Context) (bool, error) { // Check the KnativeService conditions if ready := kubernetes.GetKnativeServiceCondition(*c.obj, servingv1.ServiceConditionReady); ready.IsFalse() && ready.GetReason() == "RevisionFailed" { c.integration.Status.Phase = v1.IntegrationPhaseError diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go index 04ab4e3a3..6394cda1c 100644 --- a/pkg/trait/trait_types.go +++ b/pkg/trait/trait_types.go @@ -166,6 +166,7 @@ type ControllerStrategySelector interface { } // An Environment provides the context for the execution of the traits. +// nolint: containedctx type Environment struct { CamelCatalog *camel.RuntimeCatalog RuntimeVersion string diff --git a/pkg/util/bindings/api.go b/pkg/util/bindings/api.go index 151125e94..cbc88c5bf 100644 --- a/pkg/util/bindings/api.go +++ b/pkg/util/bindings/api.go @@ -55,6 +55,7 @@ type BindingProvider interface { Order() int } +// nolint: containedctx type BindingContext struct { Ctx context.Context Client client.Client diff --git a/pkg/util/cancellable/cancellable.go b/pkg/util/cancellable/cancellable.go index 47e0c987b..6ef87be29 100644 --- a/pkg/util/cancellable/cancellable.go +++ b/pkg/util/cancellable/cancellable.go @@ -41,6 +41,7 @@ func NewContextWithParent(parent context.Context) Context { } } +// nolint: containedctx type cancellableContext struct { context.Context cancel func()