forked from operator-framework/operator-sdk
/
gopkgtoml.go
98 lines (80 loc) · 2.66 KB
/
gopkgtoml.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2019 The Operator-SDK Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package helm
import (
"fmt"
"github.com/operator-framework/operator-sdk/internal/pkg/scaffold"
"github.com/operator-framework/operator-sdk/internal/pkg/scaffold/input"
"github.com/operator-framework/operator-sdk/internal/pkg/scaffold/internal/deps"
)
// GopkgToml - the Gopkg.toml file for a hybrid operator
type GopkgToml struct {
input.Input
}
func (s *GopkgToml) GetInput() (input.Input, error) {
if s.Path == "" {
s.Path = scaffold.GopkgTomlFile
}
s.TemplateBody = gopkgTomlTmpl
return s.Input, nil
}
const gopkgTomlTmpl = `[[constraint]]
name = "github.com/operator-framework/operator-sdk"
# The version rule is used for a specific release and the master branch for in between releases.
# branch = "v0.8.x" #osdk_branch_annotation
version = "=v0.8.1" #osdk_version_annotation
[[override]]
name = "k8s.io/api"
version = "kubernetes-1.13.1"
[[override]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.13.1"
[[override]]
name = "k8s.io/apiextensions-apiserver"
version = "kubernetes-1.13.1"
[[override]]
name = "k8s.io/apiserver"
version = "kubernetes-1.13.1"
[[override]]
name = "k8s.io/client-go"
version = "kubernetes-1.13.1"
[[override]]
name = "k8s.io/cli-runtime"
version = "kubernetes-1.13.1"
# We need overrides for the following imports because dep can't resolve them
# correctly. The easiest way to get this right is to use the versions that
# k8s.io/helm uses. See https://github.com/helm/helm/blob/v2.13.1/glide.lock
[[override]]
name = "k8s.io/kubernetes"
revision = "c6d339953bd4fd8c021a6b5fb46d7952b30be9f9"
[[override]]
name = "github.com/russross/blackfriday"
revision = "300106c228d52c8941d4b3de6054a6062a86dda3"
[[override]]
name = "github.com/docker/distribution"
revision = "edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c"
[[override]]
name = "github.com/docker/docker"
revision = "a9fbbdc8dd8794b20af358382ab780559bca589d"
[prune]
go-tests = true
unused-packages = true
`
func PrintDepGopkgTOML(asFile bool) error {
if asFile {
_, err := fmt.Println(gopkgTomlTmpl)
return err
}
return deps.PrintDepGopkgTOML(gopkgTomlTmpl)
}