Skip to content

Commit

Permalink
fix: Wrap errors when unmarshal Cloud Run deploy manifests fail. (#9578)
Browse files Browse the repository at this point in the history
* Wrap errors when unmarhsal Cloud Run deploy manifests.

* Wrap errors when unmarshal Cloud Run deploy manifests.

Wrap errors returned from k8syaml.Unmarshal

* Wrapping yaml unmarshal errors for cloud run deploy jobs

---------

Co-authored-by: Jesse Ward <[email protected]>
  • Loading branch information
jesseward and Jesse Ward authored Nov 22, 2024
1 parent 533183e commit 62c0a70
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/skaffold/deploy/cloudrun/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (d *Deployer) deployToCloudRun(ctx context.Context, out io.Writer, manifest
// figure out which type we have:
resource := &unstructured.Unstructured{}
if err = k8syaml.Unmarshal(manifest, resource); err != nil {
return sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config"), &proto.ActionableErr{
return sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config: %w", err), &proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_DEPLOY_READ_MANIFEST_ERR,
})
Expand Down Expand Up @@ -232,7 +232,7 @@ func (d *Deployer) deployToCloudRun(ctx context.Context, out io.Writer, manifest
func (d *Deployer) deployService(crclient *run.APIService, manifest []byte, out io.Writer) (*RunResourceName, error) {
service := &run.Service{}
if err := k8syaml.Unmarshal(manifest, service); err != nil {
return nil, sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config"), &proto.ActionableErr{
return nil, sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config: %w", err), &proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_DEPLOY_READ_MANIFEST_ERR,
})
Expand Down Expand Up @@ -329,7 +329,7 @@ func (d *Deployer) forceSendValueOfMaxRetries(job *run.Job, manifest []byte) {
func (d *Deployer) deployJob(crclient *run.APIService, manifest []byte, out io.Writer) (*RunResourceName, error) {
job := &run.Job{}
if err := k8syaml.Unmarshal(manifest, job); err != nil {
return nil, sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Job config"), &proto.ActionableErr{
return nil, sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Job config: %w", err), &proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_DEPLOY_READ_MANIFEST_ERR,
})
Expand Down Expand Up @@ -435,7 +435,7 @@ func (d *Deployer) cleanupRun(ctx context.Context, out io.Writer, dryRun bool, m
func (d *Deployer) deleteRunService(crclient *run.APIService, out io.Writer, dryRun bool, manifest []byte) error {
service := &run.Service{}
if err := k8syaml.Unmarshal(manifest, service); err != nil {
return sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config"), &proto.ActionableErr{
return sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config: %w", err), &proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_DEPLOY_READ_MANIFEST_ERR,
})
Expand Down Expand Up @@ -475,7 +475,7 @@ func (d *Deployer) deleteRunService(crclient *run.APIService, out io.Writer, dry
func (d *Deployer) deleteRunJob(crclient *run.APIService, out io.Writer, dryRun bool, manifest []byte) error {
job := &run.Job{}
if err := k8syaml.Unmarshal(manifest, job); err != nil {
return sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Job config"), &proto.ActionableErr{
return sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Job config: %w", err), &proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_DEPLOY_READ_MANIFEST_ERR,
})
Expand Down Expand Up @@ -514,7 +514,7 @@ func (d *Deployer) deleteRunJob(crclient *run.APIService, out io.Writer, dryRun
func getTypeFromManifest(manifest []byte) (string, error) {
resource := &unstructured.Unstructured{}
if err := k8syaml.Unmarshal(manifest, resource); err != nil {
return "", sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config"), &proto.ActionableErr{
return "", sErrors.NewError(fmt.Errorf("unable to unmarshal Cloud Run Service config: %w", err), &proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_DEPLOY_READ_MANIFEST_ERR,
})
Expand Down

0 comments on commit 62c0a70

Please sign in to comment.