mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-22 01:50:40 +00:00
Add yaml marshalling for variable and parameter
This commit is contained in:
parent
7441be0ed5
commit
f35bd60807
13
yaml/env.go
13
yaml/env.go
@ -42,3 +42,16 @@ func (v *Variable) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
v.Secret = d.Secret
|
v.Secret = d.Secret
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalYAML implements yaml marshalling.
|
||||||
|
func (v *Variable) MarshalYAML() (interface{}, error) {
|
||||||
|
if v.Secret != "" {
|
||||||
|
m := map[string]interface{}{}
|
||||||
|
m["from_secret"] = v.Secret
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
if v.Value != "" {
|
||||||
|
return v.Value, nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// Copyright 2019 Drone IO, Inc.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -34,7 +34,7 @@ type (
|
|||||||
func (p *Parameter) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (p *Parameter) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
d := new(parameter)
|
d := new(parameter)
|
||||||
err := unmarshal(d)
|
err := unmarshal(d)
|
||||||
if err == nil && d.Secret != ""{
|
if err == nil && d.Secret != "" {
|
||||||
p.Secret = d.Secret
|
p.Secret = d.Secret
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -43,3 +43,16 @@ func (p *Parameter) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
p.Value = i
|
p.Value = i
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalYAML implements yaml marshalling.
|
||||||
|
func (p *Parameter) MarshalYAML() (interface{}, error) {
|
||||||
|
if p.Secret != "" {
|
||||||
|
m := map[string]interface{}{}
|
||||||
|
m["from_secret"] = p.Secret
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
if p.Value != "" {
|
||||||
|
return p.Value, nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user