Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions codefresh/cfclient/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type Spec struct {
Contexts []interface{} `json:"contexts,omitempty"`
Steps *Steps `json:"steps,omitempty"`
Stages *Stages `json:"stages,omitempty"`
Services *Services `json:"services,omitempty"`
Mode string `json:"mode,omitempty"`
FailFast *bool `json:"fail_fast,omitempty"`
RuntimeEnvironment RuntimeEnvironment `json:"runtimeEnvironment,omitempty"`
Expand All @@ -148,6 +149,10 @@ type Hooks struct {
Hooks string
}

type Services struct {
Services string
}

func (d Steps) MarshalJSON() ([]byte, error) {
bytes := []byte(d.Steps)
return bytes, nil
Expand All @@ -161,6 +166,10 @@ func (d Hooks) MarshalJSON() ([]byte, error) {
bytes := []byte(d.Hooks)
return bytes, nil
}
func (d Services) MarshalJSON() ([]byte, error) {
bytes := []byte(d.Services)
return bytes, nil
}
func (d *Steps) UnmarshalJSON(data []byte) error {
d.Steps = string(data)
return nil
Expand All @@ -173,6 +182,10 @@ func (d *Hooks) UnmarshalJSON(data []byte) error {
d.Hooks = string(data)
return nil
}
func (d *Services) UnmarshalJSON(data []byte) error {
d.Services = string(data)
return nil
}

type Pipeline struct {
Metadata Metadata `json:"metadata,omitempty"`
Expand Down
6 changes: 5 additions & 1 deletion codefresh/resource_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ func mapResourceToPipeline(d *schema.ResourceData) (*cfclient.Pipeline, error) {
// For this purpose we use yq that preserves the order of attributes when converting to json.
func extractSpecAttributesFromOriginalYamlString(originalYamlString string, pipeline *cfclient.Pipeline) error {

for _, attribute := range []string{"stages", "steps", "hooks"} {
for _, attribute := range []string{"stages", "steps", "hooks", "services"} {
attributeJson, err := datautil.Yq(fmt.Sprintf(".%s", attribute), originalYamlString, "json")
if err != nil {
return fmt.Errorf("error while extracting '%s' from original YAML string: %v", attribute, err)
Expand All @@ -1357,6 +1357,10 @@ func extractSpecAttributesFromOriginalYamlString(originalYamlString string, pipe
pipeline.Spec.Hooks = &cfclient.Hooks{
Hooks: attributeJson,
}
case "services":
pipeline.Spec.Services = &cfclient.Services{
Services: attributeJson,
}
}
}

Expand Down
Loading