diff --git a/codefresh/cfclient/pipeline.go b/codefresh/cfclient/pipeline.go index f4f71a7..93f6e30 100644 --- a/codefresh/cfclient/pipeline.go +++ b/codefresh/cfclient/pipeline.go @@ -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"` @@ -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 @@ -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 @@ -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"` diff --git a/codefresh/resource_pipeline.go b/codefresh/resource_pipeline.go index 9c57fc5..44c450d 100644 --- a/codefresh/resource_pipeline.go +++ b/codefresh/resource_pipeline.go @@ -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) @@ -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, + } } }