github.com/chenbh/concourse/v6@v6.4.2/atc/resource/resource_put.go (about)

     1  package resource
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"strings"
     7  
     8  	"github.com/chenbh/concourse/v6/atc/runtime"
     9  )
    10  
    11  func (resource *resource) Put(
    12  	ctx context.Context,
    13  	spec runtime.ProcessSpec,
    14  	runnable runtime.Runner,
    15  ) (runtime.VersionResult, error) {
    16  	vr := runtime.VersionResult{}
    17  
    18  	input, err := resource.Signature()
    19  	if err != nil {
    20  		return vr, err
    21  	}
    22  
    23  	err = runnable.RunScript(
    24  		ctx,
    25  		spec.Path,
    26  		spec.Args,
    27  		input,
    28  		&vr,
    29  		spec.StderrWriter,
    30  		true,
    31  	)
    32  	if err != nil {
    33  		return runtime.VersionResult{}, err
    34  	}
    35  	if vr.Version == nil {
    36  		return runtime.VersionResult{}, fmt.Errorf("resource script (%s %s) output a null version", spec.Path, strings.Join(spec.Args, " "))
    37  	}
    38  
    39  	return vr, nil
    40  }