Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ws-daemon/pkg/config/config.go
2501 views
1
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package config
6
7
import (
8
"bytes"
9
"encoding/json"
10
"os"
11
12
"golang.org/x/xerrors"
13
14
"github.com/gitpod-io/gitpod/common-go/baseserver"
15
"github.com/gitpod-io/gitpod/ws-daemon/pkg/daemon"
16
)
17
18
func Read(fn string) (*Config, error) {
19
ctnt, err := os.ReadFile(fn)
20
if err != nil {
21
return nil, xerrors.Errorf("cannot read config file: %w", err)
22
}
23
24
var cfg Config
25
dec := json.NewDecoder(bytes.NewReader(ctnt))
26
dec.DisallowUnknownFields()
27
err = dec.Decode(&cfg)
28
if err != nil {
29
return nil, xerrors.Errorf("cannot parse config file: %w", err)
30
}
31
32
return &cfg, nil
33
}
34
35
type Config struct {
36
Daemon daemon.Config `json:"daemon"`
37
Service baseserver.ServerConfiguration `json:"service"`
38
}
39
40