github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/travis/service.go (about) 1 // Copyright 2022 Harness, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package travis 16 17 import harness "github.com/drone/spec/dist/go" 18 19 func (d *Converter) convertServices(ctx *context) []*harness.Step { 20 21 // TODO support for addons.postgres 22 // TODO support for addons.postgresql 23 24 // TODO document authentication differences for postgres (password set to "postgres") 25 // TODO document authentication differences for mysql (username set to "root", not "travis") 26 var dst []*harness.Step 27 for _, name := range ctx.config.Services { 28 if _, ok := defaultServiceImage[name]; ok { 29 dst = append(dst, d.convertService(name)) 30 } 31 } 32 if addons := ctx.config.Addons; addons != nil { 33 if v := addons.Rethinkdb; v != "" { 34 // TODO support addons.rethinkdb version 35 dst = append(dst, d.convertService("rethinkdb")) 36 } 37 if v := addons.Mariadb; v != "" { 38 // TODO support addons.mariadb version 39 dst = append(dst, d.convertService("mariadb")) 40 } 41 } 42 return dst 43 } 44 45 func (d *Converter) convertService(name string) *harness.Step { 46 return &harness.Step{ 47 Name: d.identifiers.Generate(name), 48 Type: "background", 49 Spec: &harness.StepBackground{ 50 Image: defaultServiceImage[name], 51 Ports: defaultServicePorts[name], 52 Envs: defaultServiceEnvs[name], 53 // TODO support for adding an image connector to a background step 54 // Connector: "", 55 }, 56 } 57 }