Skip to content

Commit 5a61c78

Browse files
author
NETIZEN-11
committed
Fix all merge conflicts and compilation errors
- Remove duplicate dependency declarations in go.mod (apply-setters v0.2.2 and krm-functions-sdk v1.0.0) - Fix duplicate field initializations in executor_test.go hydrationContext structs - Fix malformed if statement in runMutators function (removed unclosed if block) - Implement setRenderConditionWithStatus function properly - Remove redundant RenderStatus assignment in setRenderStatus function - Remove duplicate type declarations in types.go (Status, RenderStatus, PipelineStepResult, ResultItem) - Add Resource field to ResultItem struct (required by executor.go) All compilation errors resolved and tests compile successfully.
1 parent c8d4afd commit 5a61c78

5 files changed

Lines changed: 24 additions & 70 deletions

File tree

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ require (
1111
github.com/google/go-containerregistry v0.20.6
1212
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
1313
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.4
14-
github.com/kptdev/krm-functions-sdk/go/fn v1.0.0
15-
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.2
1614
github.com/kptdev/krm-functions-sdk/go/fn v1.0.2
1715
github.com/otiai10/copy v1.14.1
1816
github.com/philopon/go-toposort v0.0.0-20170620085441-9be86dbd762f

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uq
110110
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
111111
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.4 h1:qB0Az/M+qo31s5RD3YXV0bUkTKZ3I19Kdji42cFSPHY=
112112
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.4/go.mod h1:tYQYBka2UVPV4OnOY89h7SbtSoDfpsOGhdTy1yKse7M=
113-
github.com/kptdev/krm-functions-sdk/go/fn v1.0.0 h1:2xTAEw0/mWNnPNvBR7K3rvrnjmBMxVbtTyu2ZHJjQxo=
114-
github.com/kptdev/krm-functions-sdk/go/fn v1.0.0/go.mod h1:GxUbq9hEUYUtl2rGyQfzxz++xV+dSRrHpRxsx5l0PvA=
115-
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.2 h1:PZ4TcVzgad1OFuH4gHg4j2LKC2KXTuzfsQWil2knSlk=
116-
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.2/go.mod h1:S8Vrp3yPDp4ga2TOPfZzoO/Y7UGF7KPHS1S0taJ0XOc=
117113
github.com/kptdev/krm-functions-sdk/go/fn v1.0.2 h1:g9N6SW5axEXMagUbHliH14XpfvvvwkAVDLcN3ApVh2M=
118114
github.com/kptdev/krm-functions-sdk/go/fn v1.0.2/go.mod h1:NSfdmtQ9AwNg5wdS9gE/H9SQs7Vomzq7E7N9hyEju1U=
119115
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=

internal/util/render/executor.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,29 @@ func updateRenderStatus(hctx *hydrationContext, hydErr error) {
254254

255255
// setRenderConditionWithStatus reads the Kptfile at pkgPath, sets the Rendered condition and RenderStatus, and writes it back.
256256
func setRenderConditionWithStatus(fs filesys.FileSystem, pkgPath string, condition kptfilev1.Condition, renderStatus *kptfilev1.RenderStatus) {
257-
setRenderCondition(hctx.fileSystem, rootPath, kptfilev1.NewRenderedCondition(conditionStatus, reason, message))
258-
renderStatus := buildRenderStatus(hctx, hydErr)
259-
setRenderStatus(hctx.fileSystem, rootPath, kptfilev1.NewRenderedCondition(conditionStatus, reason, message), renderStatus)
257+
fsOrDisk := filesys.FileSystemOrOnDisk{FileSystem: fs}
258+
kf, err := kptfileutil.ReadKptfile(fsOrDisk, pkgPath)
259+
if err != nil {
260+
klog.V(3).Infof("failed to read Kptfile for render status update at %s: %v", pkgPath, err)
261+
return
262+
}
263+
if kf.Status == nil {
264+
kf.Status = &kptfilev1.Status{}
265+
}
266+
// Replace any existing Rendered condition
267+
kf.Status.Conditions = slices.DeleteFunc(kf.Status.Conditions, func(c kptfilev1.Condition) bool {
268+
return c.Type == kptfilev1.ConditionTypeRendered
269+
})
270+
kf.Status.Conditions = append(kf.Status.Conditions, condition)
271+
272+
// Update render status if provided
273+
if renderStatus != nil {
274+
kf.Status.RenderStatus = renderStatus
275+
}
276+
277+
if err := kptfileutil.WriteKptfileToFS(fs, pkgPath, kf); err != nil {
278+
klog.V(3).Infof("failed to write render status to Kptfile at %s: %v", pkgPath, err)
279+
}
260280
}
261281

262282
// buildRenderStatus constructs a RenderStatus from the tracked pipeline step results.
@@ -321,7 +341,6 @@ func setRenderStatus(fs filesys.FileSystem, pkgPath string, condition kptfilev1.
321341
kf.Status.RenderStatus = renderStatus
322342
}
323343

324-
kf.Status.RenderStatus = renderStatus
325344
if err := kptfileutil.WriteKptfileToFS(fs, pkgPath, kf); err != nil {
326345
klog.V(3).Infof("failed to write render status to Kptfile at %s: %v", pkgPath, err)
327346
}
@@ -940,7 +959,6 @@ func (pn *pkgNode) runMutators(ctx context.Context, hctx *hydrationContext, inpu
940959
function := pl.Mutators[i]
941960
stepResult := createPipelineStepResult(function, 0, "", "")
942961

943-
if function.ConfigPath != "" {
944962
resultCountBeforeExec := len(hctx.fnResults.Items)
945963

946964
if pl.Mutators[i].ConfigPath != "" {

internal/util/render/executor_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,6 @@ metadata:
604604
pkgs: map[types.UniquePath]*pkgNode{},
605605
fileSystem: mockFS,
606606
renderStatus: &kptfilev1.RenderStatus{},
607-
root: &pkgNode{pkg: rootPkg},
608-
pkgs: map[types.UniquePath]*pkgNode{},
609-
fileSystem: mockFS,
610607
}
611608
hctx.pkgs[rootPkg.UniquePath] = &pkgNode{pkg: rootPkg}
612609

@@ -645,9 +642,6 @@ metadata:
645642
pkgs: map[types.UniquePath]*pkgNode{},
646643
fileSystem: mockFS,
647644
renderStatus: &kptfilev1.RenderStatus{},
648-
root: &pkgNode{pkg: rootPkg},
649-
pkgs: map[types.UniquePath]*pkgNode{},
650-
fileSystem: mockFS,
651645
}
652646
hctx.pkgs[rootPkg.UniquePath] = &pkgNode{pkg: rootPkg}
653647

pkg/api/kptfile/v1/types.go

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,6 @@ type Status struct {
414414

415415
// RenderStatus contains detailed information about pipeline execution results
416416
RenderStatus *RenderStatus `yaml:"renderStatus,omitempty" json:"renderStatus,omitempty"`
417-
Conditions []Condition `yaml:"conditions,omitempty" json:"conditions,omitempty"`
418-
RenderStatus *RenderStatus `yaml:"renderStatus,omitempty" json:"renderStatus,omitempty"`
419417
}
420418

421419
// RenderStatus represents the result of performing render operation
@@ -441,6 +439,7 @@ type PipelineStepResult struct {
441439

442440
// ResultItem mirrors framework.Result with only the fields needed for Kptfile status.
443441
type ResultItem struct {
442+
Resource string `yaml:"resource,omitempty" json:"resource,omitempty"`
444443
Message string `yaml:"message,omitempty" json:"message,omitempty"`
445444
Severity string `yaml:"severity,omitempty" json:"severity,omitempty"`
446445
ResourceRef *ResourceRef `yaml:"resourceRef,omitempty" json:"resourceRef,omitempty"`
@@ -525,54 +524,3 @@ func ToCondition(value string) ConditionStatus {
525524
return ConditionUnknown
526525
}
527526
}
528-
529-
// RenderStatus contains detailed information about pipeline execution results
530-
type RenderStatus struct {
531-
// MutationSteps contains results from mutation pipeline functions
532-
MutationSteps []PipelineStepResult `yaml:"mutationSteps,omitempty" json:"mutationSteps,omitempty"`
533-
534-
// ValidationSteps contains results from validation pipeline functions
535-
ValidationSteps []PipelineStepResult `yaml:"validationSteps,omitempty" json:"validationSteps,omitempty"`
536-
537-
// ErrorSummary provides a consolidated summary of all errors
538-
ErrorSummary string `yaml:"errorSummary,omitempty" json:"errorSummary,omitempty"`
539-
}
540-
541-
// PipelineStepResult contains the result of executing a single pipeline step
542-
type PipelineStepResult struct {
543-
// Name is the name of the function step
544-
Name string `yaml:"name,omitempty" json:"name,omitempty"`
545-
546-
// Image is the container image that was executed
547-
Image string `yaml:"image,omitempty" json:"image,omitempty"`
548-
549-
// ExecPath is the executable path that was run
550-
ExecPath string `yaml:"execPath,omitempty" json:"execPath,omitempty"`
551-
552-
// ExecutionError captures execution failures like network errors, missing images, etc.
553-
ExecutionError string `yaml:"executionError,omitempty" json:"executionError,omitempty"`
554-
555-
// Stderr contains the standard error output from the function execution
556-
Stderr string `yaml:"stderr,omitempty" json:"stderr,omitempty"`
557-
558-
// ExitCode is the exit code returned by the function
559-
ExitCode int `yaml:"exitCode" json:"exitCode"`
560-
561-
// Results contains successful results from the function
562-
Results []ResultItem `yaml:"results,omitempty" json:"results,omitempty"`
563-
564-
// ErrorResults contains error results from the function
565-
ErrorResults []ResultItem `yaml:"errorResults,omitempty" json:"errorResults,omitempty"`
566-
}
567-
568-
// ResultItem represents a single result item from a function execution
569-
type ResultItem struct {
570-
// Resource is the KRM resource that was processed (serialized as YAML string)
571-
Resource string `yaml:"resource,omitempty" json:"resource,omitempty"`
572-
573-
// Message contains details about the result
574-
Message string `yaml:"message,omitempty" json:"message,omitempty"`
575-
576-
// Severity indicates the severity level of the result (error, warning, info)
577-
Severity string `yaml:"severity,omitempty" json:"severity,omitempty"`
578-
}

0 commit comments

Comments
 (0)