-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- cleaned up the job property unmarshal to use map
- Loading branch information
Showing
23 changed files
with
337 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/xml" | ||
) | ||
|
||
func init() { | ||
propertyUnmarshalFunc["org.datadog.jenkins.plugins.datadog.DatadogJobProperty"] = unmarshalJobDatadogJobProperty | ||
} | ||
|
||
type JobDatadogJobProperty struct { | ||
XMLName xml.Name `xml:"org.datadog.jenkins.plugins.datadog.DatadogJobProperty"` | ||
Id string `xml:"id,attr,omitempty"` | ||
Plugin string `xml:"plugin,attr,omitempty"` | ||
|
||
EmitOnCheckout bool `xml:"emitOnCheckout"` | ||
} | ||
|
||
func NewJobDatadogJobProperty() *JobDatadogJobProperty { | ||
return &JobDatadogJobProperty{ | ||
EmitOnCheckout: false, | ||
} | ||
} | ||
|
||
func (property *JobDatadogJobProperty) GetId() string { | ||
return property.Id | ||
} | ||
|
||
func unmarshalJobDatadogJobProperty(d *xml.Decoder, start xml.StartElement) (JobProperty, error) { | ||
property := NewJobDatadogJobProperty() | ||
err := d.DecodeElement(property, &start) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return property, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package provider | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/jgramoll/terraform-provider-jenkins/client" | ||
"reflect" | ||
) | ||
|
||
type jobDatadogJobProperty struct { | ||
EmitOnCheckout bool `mapstruture:"emit_on_checkout"` | ||
} | ||
|
||
func newJobDatadogJobProperty() *jobDatadogJobProperty { | ||
return &jobDatadogJobProperty{} | ||
} | ||
|
||
func (p *jobDatadogJobProperty) toClientProperty(id string) client.JobProperty { | ||
clientProperty := client.NewJobDatadogJobProperty() | ||
clientProperty.Id = id | ||
clientProperty.EmitOnCheckout = p.EmitOnCheckout | ||
return clientProperty | ||
} | ||
|
||
func (p *jobDatadogJobProperty) fromClientJobProperty(clientPropertyInterface client.JobProperty) (jobProperty, error) { | ||
clientProperty, ok := clientPropertyInterface.(*client.JobDatadogJobProperty) | ||
if !ok { | ||
return nil, fmt.Errorf("Property is not of expected type, expected *client.JobDatadogJobProperty, actually %s", | ||
reflect.TypeOf(clientPropertyInterface).String()) | ||
} | ||
property := newJobDatadogJobProperty() | ||
property.EmitOnCheckout = clientProperty.EmitOnCheckout | ||
return property, nil | ||
} | ||
|
||
func (p *jobDatadogJobProperty) setResourceData(d *schema.ResourceData) error { | ||
return d.Set("emit_on_checkout", p.EmitOnCheckout) | ||
} |
Oops, something went wrong.