Skip to content

Commit

Permalink
mergecat review: apply kubechecks review
Browse files Browse the repository at this point in the history
Signed-off-by: Mmadu Manasseh <[email protected]>
  • Loading branch information
MeNsaaH committed Nov 30, 2024
1 parent fafb4e5 commit cb0a64b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ func init() {
newStringOpts().
withDefault("kubechecks again"))

boolFlag(flags, "server-side-diff", "Enable server-side diff.")
boolFlag(flags, "server-side-diff", "Enable server-side diff.",
newBoolOpts().
withDefault(true))

panicIfError(viper.BindPFlags(flags))
setupLogOutput()
Expand Down
6 changes: 3 additions & 3 deletions pkg/argo_client/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ func (argo *ArgoClient) GetManifestsServerSide(ctx context.Context, name, tempRe

client, err := appClient.GetManifestsWithFiles(ctx, grpc_retry.Disable())
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to get manifest client")
}
localIncludes := []string{"*"}
log.Debug().Str("name", name).Str("repo_path", tempRepoDir).Msg("sending application manifest query with files")

err = manifeststream.SendApplicationManifestQueryWithFiles(ctx, client, name, app.Namespace, tempRepoDir, localIncludes)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to send manifest query")
}

res, err := client.CloseAndRecv()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to receive manifest response")
}

if res.Manifests == nil {
Expand Down
28 changes: 9 additions & 19 deletions pkg/events/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,18 @@ func (w *worker) processApp(ctx context.Context, app v1alpha1.Application) {
if !w.ctr.Config.ServerSideDiff {
logger.Debug().Str("repo_path", repoPath).Msg("Getting manifests")
jsonManifests, err = w.ctr.ArgoClient.GetManifestsLocal(ctx, appName, repoPath, appPath, app)
if err != nil {
logger.Error().Err(err).Msg("Unable to get manifests")
w.vcsNote.AddToAppMessage(ctx, appName, msg.Result{
State: pkg.StateError,
Summary: "Unable to get manifests",
Details: fmt.Sprintf("```\n%s\n```", cleanupGetManifestsError(err, repo.Directory)),
})
return
}
} else {
logger.Debug().Str("repo_path", repoPath).Msg("Getting server-side manifests")
jsonManifests, err = w.ctr.ArgoClient.GetManifestsServerSide(ctx, appName, repoPath, appPath, app)
if err != nil {
logger.Error().Err(err).Msg("Unable to get manifests")
w.vcsNote.AddToAppMessage(ctx, appName, msg.Result{
State: pkg.StateError,
Summary: "Unable to get manifests",
Details: fmt.Sprintf("```\n%s\n```", cleanupGetManifestsError(err, repo.Directory)),
})
return
}

}
if err != nil {
logger.Error().Err(err).Msg("Unable to get manifests")
w.vcsNote.AddToAppMessage(ctx, appName, msg.Result{
State: pkg.StateError,
Summary: "Unable to get manifests",
Details: fmt.Sprintf("```\n%s\n```", cleanupGetManifestsError(err, repo.Directory)),
})
return
}

// Argo diff logic wants unformatted manifests but everything else wants them as YAML, so we prepare both
Expand Down

0 comments on commit cb0a64b

Please sign in to comment.