-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: copy parent project manifest to children
Signed-off-by: Donnie Adams <[email protected]>
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package projects | ||
|
||
import ( | ||
"github.com/obot-platform/nah/pkg/router" | ||
v1 "github.com/obot-platform/obot/pkg/storage/apis/obot.obot.ai/v1" | ||
"k8s.io/apimachinery/pkg/api/equality" | ||
) | ||
|
||
type Handler struct{} | ||
|
||
func NewHandler() *Handler { | ||
return &Handler{} | ||
} | ||
|
||
func (h *Handler) CopyProjectInfo(req router.Request, _ router.Response) error { | ||
projectThread := req.Object.(*v1.Thread) | ||
if !projectThread.Spec.Project || projectThread.Spec.ParentThreadName == "" { | ||
return nil | ||
} | ||
|
||
var parentThread v1.Thread | ||
if err := req.Get(&parentThread, projectThread.Namespace, projectThread.Spec.ParentThreadName); err != nil { | ||
return err | ||
} | ||
|
||
if !equality.Semantic.DeepEqual(projectThread.Spec.Manifest, parentThread.Spec.Manifest) { | ||
projectThread.Spec.Manifest = parentThread.Spec.Manifest | ||
return req.Client.Update(req.Ctx, projectThread) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters