Skip to content

Commit

Permalink
fix: unmarshal inline (arch detection) pod manifest template
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbreuninger committed Jul 23, 2024
1 parent c75cd4e commit b83a4c3
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions pkg/kubernetes/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,14 @@ func parseResources(resourceString string, log log.Logger) corev1.ResourceRequir
}

func getPodTemplate(manifest string) (*corev1.Pod, error) {
_, err := os.Stat(manifest)
if err != nil {
if os.IsNotExist(err) {
// try to parse inline template
pod := &corev1.Pod{}
err = yaml.Unmarshal([]byte(manifest), pod)
if err != nil {
return nil, errors.Wrap(err, "unmarshal pod template")
}

return pod, nil
}

return nil, err
// check if manifest is inline yaml
pod := &corev1.Pod{}
err := yaml.Unmarshal([]byte(manifest), pod)
if err == nil {
return pod, nil
}

// check if manifest is path
p, err := filepath.Abs(manifest)
if err != nil {
return nil, err
Expand All @@ -81,7 +73,6 @@ func getPodTemplate(manifest string) (*corev1.Pod, error) {
if err != nil {
return nil, err
}
pod := &corev1.Pod{}
err = yaml.Unmarshal(body, pod)
if err != nil {
return nil, errors.Wrap(err, "unmarshal pod template")
Expand Down

0 comments on commit b83a4c3

Please sign in to comment.