Skip to content

Commit

Permalink
fix: fill message in bundle status
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Jin <kavinjsir@gmail.com>
(cherry picked from commit c527e65)
Signed-off-by: Todd Short <todd.short@me.com>
  • Loading branch information
Kavinjsir authored and tmshort committed Feb 23, 2023
1 parent abcadb1 commit 5b6a1f8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
9 changes: 9 additions & 0 deletions internal/source/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package source

import (
"fmt"
)

func generateMessage(bundleName string) string {
return fmt.Sprintf("Successfully unpacked the %s Bundle", bundleName)
}
4 changes: 3 additions & 1 deletion internal/source/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ func (r *Git) Unpack(ctx context.Context, bundle *rukpakv1alpha1.Bundle) (*Resul
Git: resolvedGit,
}

return &Result{Bundle: bundleFS, ResolvedSource: resolvedSource, State: StateUnpacked}, nil
message := generateMessage("git")

return &Result{Bundle: bundleFS, ResolvedSource: resolvedSource, State: StateUnpacked, Message: message}, nil
}

func (r *Git) configAuth(ctx context.Context, bundle *rukpakv1alpha1.Bundle) (transport.AuthMethod, error) {
Expand Down
5 changes: 4 additions & 1 deletion internal/source/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ func (b *HTTP) Unpack(ctx context.Context, bundle *rukpakv1alpha1.Bundle) (*Resu
if err != nil {
return nil, fmt.Errorf("error creating FS: %s", err)
}
return &Result{Bundle: fs, ResolvedSource: bundle.Spec.Source.DeepCopy(), State: StateUnpacked}, nil

message := generateMessage("http")

return &Result{Bundle: fs, ResolvedSource: bundle.Spec.Source.DeepCopy(), State: StateUnpacked, Message: message}, nil
}

// getCredentials reads credentials from the secret specified in the bundle
Expand Down
4 changes: 3 additions & 1 deletion internal/source/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ func (i *Image) succeededPodResult(ctx context.Context, pod *corev1.Pod) (*Resul
Image: &rukpakv1alpha1.ImageSource{Ref: digest},
}

return &Result{Bundle: bundleFS, ResolvedSource: resolvedSource, State: StateUnpacked}, nil
message := generateMessage("image")

return &Result{Bundle: bundleFS, ResolvedSource: resolvedSource, State: StateUnpacked, Message: message}, nil
}

func (i *Image) getBundleContents(ctx context.Context, pod *corev1.Pod) (fs.FS, error) {
Expand Down
4 changes: 3 additions & 1 deletion internal/source/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,7 @@ func (o *Local) Unpack(ctx context.Context, bundle *rukpakv1alpha1.Bundle) (*Res
Local: bundle.Spec.Source.Local.DeepCopy(),
}

return &Result{Bundle: bundleFS, ResolvedSource: resolvedSource, State: StateUnpacked}, nil
message := generateMessage("local")

return &Result{Bundle: bundleFS, ResolvedSource: resolvedSource, State: StateUnpacked, Message: message}, nil
}
5 changes: 4 additions & 1 deletion internal/source/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@ func (b *Upload) Unpack(ctx context.Context, bundle *rukpakv1alpha1.Bundle) (*Re
if err != nil {
return nil, fmt.Errorf("untar bundle contents from response: %v", err)
}
return &Result{Bundle: bundleFS, ResolvedSource: bundle.Spec.Source.DeepCopy(), State: StateUnpacked}, nil

message := generateMessage("upload")

return &Result{Bundle: bundleFS, ResolvedSource: bundle.Spec.Source.DeepCopy(), State: StateUnpacked, Message: message}, nil
}

0 comments on commit 5b6a1f8

Please sign in to comment.