mirror of
https://github.com/drone-plugins/drone-manifest.git
synced 2026-06-04 18:24:08 +08:00
feat: allow to pass spec inline
This allows to pass the contents from `spec` directly from `drone.yml`, for use with autogenerated drone configurations.
This commit is contained in:
@@ -87,10 +87,16 @@ func (p *Plugin) Exec() error {
|
||||
args = append(args, "push")
|
||||
|
||||
if p.Config.Spec != "" {
|
||||
raw, err := ioutil.ReadFile(p.Config.Spec)
|
||||
var raw []byte
|
||||
// if spec is not a valid file, assume inlining
|
||||
if _, err := os.Stat(p.Config.Spec); os.IsNotExist(err) {
|
||||
raw = []byte(p.Config.Spec)
|
||||
} else { // otherwise read it
|
||||
raw, err = ioutil.ReadFile(p.Config.Spec)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read template")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read template")
|
||||
}
|
||||
}
|
||||
|
||||
spec, err := template.RenderTrim(string(raw), p)
|
||||
|
||||
Reference in New Issue
Block a user