Path: blob/main/components/ide-service-api/go/config/config.go
2500 views
// Copyright (c) 2022 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 config56import (7"bytes"8"encoding/json"9"os"1011"github.com/gitpod-io/gitpod/common-go/baseserver"12"golang.org/x/xerrors"13)1415type ServiceConfiguration struct {16Server *baseserver.Configuration `json:"server,omitempty"`17IDEConfigPath string `json:"ideConfigPath"`18DockerCfg string `json:"dockerCfg"`19}2021func Read(fn string) (*ServiceConfiguration, error) {22ctnt, err := os.ReadFile(fn)23if err != nil {24return nil, xerrors.Errorf("cannot read config file: %w", err)25}2627var cfg ServiceConfiguration28dec := json.NewDecoder(bytes.NewReader(ctnt))29dec.DisallowUnknownFields()30err = dec.Decode(&cfg)31if err != nil {32return nil, xerrors.Errorf("cannot parse config file: %w", err)33}3435return &cfg, nil36}373839