Path: blob/main/components/gitpod-cli/pkg/gitpodlib/config.go
2500 views
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package gitpodlib56type GitpodImage struct {7File string8Context string `yaml:"context,omitempty"`9}1011type gitpodPort struct {12Number int32 `yaml:"port"`13}1415type gitpodTask struct {16Command string `yaml:"command,omitempty"`17Init string `yaml:"init,omitempty"`18}1920type GitpodFile struct {21Image interface{} `yaml:"image,omitempty"`22Ports []gitpodPort `yaml:"ports,omitempty"`23Tasks []gitpodTask `yaml:"tasks,omitempty"`24CheckoutLocation string `yaml:"checkoutLocation,omitempty"`25WorkspaceLocation string `yaml:"workspaceLocation,omitempty"`26}2728// SetImageName configures a pre-built docker image by name29func (cfg *GitpodFile) SetImageName(name string) {30if name == "" {31return32}33cfg.Image = name34}3536// SetImage configures a Dockerfile as workspace image37func (cfg *GitpodFile) SetImage(img GitpodImage) {38cfg.Image = img39}4041// AddPort adds a port to the list of exposed ports42func (cfg *GitpodFile) AddPort(port int32) {43cfg.Ports = append(cfg.Ports, gitpodPort{44Number: port,45})46}4748// AddTask adds a workspace startup task49func (cfg *GitpodFile) AddTask(task ...string) {50if len(task) > 1 {51cfg.Tasks = append(cfg.Tasks, gitpodTask{52Command: task[0],53Init: task[1],54})55} else {56cfg.Tasks = append(cfg.Tasks, gitpodTask{57Command: task[0],58})59}60}616263