Skip to content

Commit

Permalink
resolved the nits
Browse files Browse the repository at this point in the history
Signed-off-by: sethiyash <[email protected]>
  • Loading branch information
sethiyash committed Dec 12, 2023
1 parent 1631608 commit c871303
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
18 changes: 9 additions & 9 deletions cmd/controller/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ func Run(opts Options, runLog logr.Logger) error {
}
{ // add controller for apps
appFactory := app.CRDAppFactory{
CoreClient: coreClient,
AppClient: kcClient,
KcConfig: kcConfig,
CountMetrics: countMetrics,
TimeMetrics: reconcileTimeMetrics,
CmdRunner: sidecarCmdExec,
Kubeconf: kubeconf,
CompInfo: compInfo,
CacheFolder: cacheFolderApps,
CoreClient: coreClient,
AppClient: kcClient,
KcConfig: kcConfig,
CountMetrics: countMetrics,
ReconcileTimeMetrics: reconcileTimeMetrics,
CmdRunner: sidecarCmdExec,
Kubeconf: kubeconf,
CompInfo: compInfo,
CacheFolder: cacheFolderApps,
}
reconciler := app.NewReconciler(kcClient, runLog.WithName("app"),
appFactory, refTracker, updateStatusTracker, compInfo)
Expand Down
26 changes: 13 additions & 13 deletions pkg/app/app_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ import (

// CRDAppFactory allows to create CRDApps.
type CRDAppFactory struct {
CoreClient kubernetes.Interface
AppClient kcclient.Interface
KcConfig *config.Config
CountMetrics *metrics.ReconcileCountMetrics
TimeMetrics *metrics.ReconcileTimeMetrics
VendirConfigHook func(vendirconf.Config) vendirconf.Config
KbldAllowBuild bool
CmdRunner exec.CmdRunner
Kubeconf *kubeconfig.Kubeconfig
CompInfo ComponentInfo
DeployFactory deploy.Factory
CacheFolder *memdir.TmpDir
CoreClient kubernetes.Interface
AppClient kcclient.Interface
KcConfig *config.Config
CountMetrics *metrics.ReconcileCountMetrics
ReconcileTimeMetrics *metrics.ReconcileTimeMetrics
VendirConfigHook func(vendirconf.Config) vendirconf.Config
KbldAllowBuild bool
CmdRunner exec.CmdRunner
Kubeconf *kubeconfig.Kubeconfig
CompInfo ComponentInfo
DeployFactory deploy.Factory
CacheFolder *memdir.TmpDir
}

// NewCRDApp creates a CRDApp injecting necessary dependencies.
Expand All @@ -49,7 +49,7 @@ func (f *CRDAppFactory) NewCRDApp(app *kcv1alpha1.App, log logr.Logger) *CRDApp
templateFactory := template.NewFactory(f.CoreClient, fetchFactory, f.KbldAllowBuild, f.CmdRunner)
deployFactory := deploy.NewFactory(f.CoreClient, f.Kubeconf, f.KcConfig, f.CmdRunner, log)

return NewCRDApp(app, log, f.CountMetrics, f.TimeMetrics, f.AppClient, fetchFactory, templateFactory, deployFactory, f.CompInfo, Opts{
return NewCRDApp(app, log, f.CountMetrics, f.ReconcileTimeMetrics, f.AppClient, fetchFactory, templateFactory, deployFactory, f.CompInfo, Opts{
DefaultSyncPeriod: f.KcConfig.AppDefaultSyncPeriod(),
MinimumSyncPeriod: f.KcConfig.AppMinimumSyncPeriod(),
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/app_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ func (a *App) reconcileDeploy() error {
}

func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult {
reconcileStartTS := time.Now()
reconcileStartTime := time.Now()
a.isFirstReconcile = a.countMetrics.GetReconcileAttemptCounterValue("app", a.app.Name, a.app.Namespace) == 1
defer func() {
a.timeMetrics.RegisterOverallTime(appResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile,
time.Since(reconcileStartTS))
time.Since(reconcileStartTime))
}()

tmpDir := memdir.NewTmpDir("fetch-template-deploy")
Expand Down
4 changes: 2 additions & 2 deletions pkg/packageinstall/packageinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ func (pi *PackageInstallCR) reconcile(modelStatus *reconciler.Status) (reconcile
pi.log.Info("Reconciling")
pi.countMetrics.RegisterReconcileAttempt(packageInstallType, pi.model.Name, pi.model.Namespace)

reconcileStartTS := time.Now()
reconcileStartTime := time.Now()
pi.firstReconcile = pi.countMetrics.GetReconcileAttemptCounterValue("pkgi", pi.model.Name, pi.model.Namespace) == 1
defer func() {
pi.timeMetrics.RegisterOverallTime(packageInstallType, pi.model.Name, pi.model.Namespace,
pi.firstReconcile, time.Since(reconcileStartTS))
pi.firstReconcile, time.Since(reconcileStartTime))
}()

err := pi.blockDeletion()
Expand Down
4 changes: 2 additions & 2 deletions pkg/pkgrepository/app_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ func (a *App) reconcileDeploy() error {
}

func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult {
reconcileStartTS := time.Now()
reconcileStartTime := time.Now()
a.isFirstReconcile = a.countMetrics.GetReconcileAttemptCounterValue(packageRepoResourceType, a.app.Name, a.app.Namespace) == 1
defer func() {
a.timeMetrics.RegisterOverallTime(packageRepoResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile,
time.Since(reconcileStartTS))
time.Since(reconcileStartTime))
}()

tmpDir := memdir.NewTmpDir("fetch-template-deploy")
Expand Down
2 changes: 1 addition & 1 deletion pkg/pkgrepository/app_reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package pkgrepository

import (
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -15,6 +14,7 @@ import (
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/exec"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/fetch"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/kubeconfig"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/template"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/pkgrepository/crd_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ package pkgrepository
import (
"context"
"fmt"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics"

"github.com/go-logr/logr"
kcv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1"
pkgingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1"
kcclient "github.com/vmware-tanzu/carvel-kapp-controller/pkg/client/clientset/versioned"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/deploy"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/fetch"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/reftracker"
"github.com/vmware-tanzu/carvel-kapp-controller/pkg/template"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down

0 comments on commit c871303

Please sign in to comment.