Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address copilot comments, fix copyright
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
  • Loading branch information
mozesl-nokia committed Jun 2, 2026
commit 283480ce5569c2cdf45e429b7f1b27bfb4ec57f7
2 changes: 1 addition & 1 deletion controllers/functionconfigs/reconciler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2026 The kpt and Nephio Authors
// Copyright 2026 The kpt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
24 changes: 11 additions & 13 deletions controllers/functionconfigs/store.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2026 The kpt and Nephio Authors
// Copyright 2026 The kpt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,8 +22,8 @@ import (
"strings"
"sync"

"github.com/kptdev/krm-functions-catalog/functions/go/apply-replacements/replacements"
"github.com/kptdev/krm-functions-catalog/functions/go/set-namespace/transformer"
applyreplacements "github.com/kptdev/krm-functions-catalog/functions/go/apply-replacements/replacements"
setnamespace "github.com/kptdev/krm-functions-catalog/functions/go/set-namespace/transformer"
"github.com/kptdev/krm-functions-catalog/functions/go/starlark/starlark"
"github.com/kptdev/krm-functions-sdk/go/fn"
configapi "github.com/kptdev/porch/api/porchconfig/v1alpha1"
Expand Down Expand Up @@ -61,8 +61,8 @@ type FunctionConfigStore struct {

func NewStore(defaultImagePrefix, defaultBinaryDir string) *FunctionConfigStore {
procMap := map[string]fn.ResourceListProcessorFunc{
"apply-replacements": replacements.ApplyReplacements,
"set-namespace": set_namespace.Run,
"apply-replacements": applyreplacements.ApplyReplacements,
"set-namespace": setnamespace.Run,
"starlark": starlark.Process,
}

Expand Down Expand Up @@ -108,7 +108,7 @@ func (s *FunctionConfigStore) Store(obj *configapi.FunctionConfig) error {
}
if strippedSpec.BinaryExecutor != nil {
strippedSpec.BinaryExecutor.Tags = nil
if strippedSpec.BinaryExecutor.Path[0] != '/' {
if len(strippedSpec.BinaryExecutor.Path) > 0 && strippedSpec.BinaryExecutor.Path[0] != '/' {
var err error
strippedSpec.BinaryExecutor.Path, err = filepath.Abs(filepath.Join(s.defaultBinaryDir, spec.BinaryExecutor.Path))
if err != nil {
Expand Down Expand Up @@ -175,17 +175,15 @@ func (s *FunctionConfigStore) Delete(imageName string) {
}

func (s *FunctionConfigStore) DeleteByObjName(key client.ObjectKey) {
toDelete := ""
s.mu.Lock()
defer s.mu.Unlock()

for imageName, entry := range s.internalCache {
if entry.objName == key {
toDelete = imageName
break
delete(s.internalCache, imageName)
return
}
}

if toDelete != "" {
s.Delete(toDelete)
}
}
Comment thread
mozesl-nokia marked this conversation as resolved.

func (s *FunctionConfigStore) Get(fullImageName string) (configapi.FunctionConfigSpec, bool) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/functionconfigs/store_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2026 The kpt and Nephio Authors
// Copyright 2026 The kpt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion controllers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func prePopulateFunctionConfigStore(reader client.Reader, store *functionconfigs
obj := &fcList.Items[i]
err := store.Store(obj)
if err != nil {
klog.Warningf("Failed to store %q during pre-pupulate (non-fatal): %v", client.ObjectKeyFromObject(obj), err)
klog.Warningf("Failed to store %q during pre-populate (non-fatal): %v", client.ObjectKeyFromObject(obj), err)
}
}
klog.Infof("FunctionConfig store pre-populated with %d configs", len(fcList.Items))
Expand Down
2 changes: 1 addition & 1 deletion func/types/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type FunctionPodInfo struct {

// SendResponse sends a reply to the connection request containing the pod data.
// If err != nil it sends `err` as an error response.
// It sends and error response if the pod is not ready yet (this shouldn't happen).
// It sends an error response if the pod is not ready yet (this shouldn't happen).
func (pod *FunctionPodInfo) SendResponse(responseCh chan<- *ConnectionResponse, err error) {
switch {
case err != nil:
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/image/image.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2026 The kpt and Nephio Authors
// Copyright 2026 The kpt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/image/image_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2026 The kpt and Nephio Authors
// Copyright 2026 The kpt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions pkg/util/image/types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2026 The kpt and Nephio Authors
// Copyright 2026 The kpt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,8 @@ package image

import "strings"

// ParsedImage is a
// ParsedImage is a structured representation of a container image reference,
// broken into registry, sub-path, base name, tag, and digest components.
type ParsedImage struct {
// The registry part of the image name without trailing slash.
// Example: ghcr.io
Expand Down