Path: blob/main/components/gitpod-cli/pkg/utils/parseGitpodConfig.go
2500 views
// Copyright (c) 2023 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 utils56import (7"errors"8"os"9"path/filepath"1011gitpod "github.com/gitpod-io/gitpod/gitpod-protocol"12yaml "gopkg.in/yaml.v2"13)1415func ParseGitpodConfig(repoRoot string) (*gitpod.GitpodConfig, error) {16if repoRoot == "" {17return nil, errors.New("repoRoot is empty")18}19data, err := os.ReadFile(filepath.Join(repoRoot, ".gitpod.yml"))20if err != nil {21// .gitpod.yml not exist is ok22if errors.Is(err, os.ErrNotExist) {23return nil, nil24}25return nil, errors.New("read .gitpod.yml file failed: " + err.Error())26}27var config *gitpod.GitpodConfig28if err = yaml.Unmarshal(data, &config); err != nil {29return nil, errors.New("unmarshal .gitpod.yml file failed" + err.Error())30}31return config, nil32}333435