Skip to content

Commit

Permalink
For incomprehensible reasons, google stringifies this data field (#184)
Browse files Browse the repository at this point in the history
Need to sanitize it a bit before then.
  • Loading branch information
michaeljguarino authored May 9, 2024
1 parent 0e5b3d4 commit d96d66d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/controller/constraint_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controller
import (
"context"
"fmt"
"strings"

"gopkg.in/yaml.v3"

Expand Down Expand Up @@ -120,7 +121,9 @@ func GenerateAPIConstraint(instance *unstructured.Unstructured, template *templa
if annotations := instance.GetAnnotations(); annotations != nil {
var bundleData BundleData
if d, ok := annotations[bundleDataAnnotation]; ok {
if err := yaml.Unmarshal([]byte(d), &bundleData); err != nil {
d = strings.TrimSpace(d)
d = strings.Trim(d, "\"")
if err := yaml.Unmarshal([]byte(d), &bundleData); err == nil {
pca.Description = lo.ToPtr(bundleData.Description)
pca.Recommendation = lo.ToPtr(bundleData.Remediation)
} else {
Expand Down

0 comments on commit d96d66d

Please sign in to comment.