forked from palantir/godel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.go
164 lines (135 loc) · 7.28 KB
/
dist.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright 2016 Palantir Technologies, Inc.
//
// 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 params
import (
"github.com/palantir/pkg/matcher"
"github.com/palantir/godel/apps/distgo/pkg/osarch"
)
type Dist struct {
// OutputDir is the directory to which the distribution is written.
OutputDir string
// InputDir is the path (from the project root) to a directory whose contents will be copied into the output
// distribution directory at the beginning of the "dist" command. Can be used to include static resources and
// other files required in a distribution.
InputDir string
// InputProducts is a slice of the names of products in the project (other than the current one) whose binaries
// are required for the "dist" task. The "dist" task will ensure that the outputs of "build" exist for all of
// the products specified in this slice (and will build the products as part of the task if necessary) and make
// the outputs available to the "dist" script as environment variables. Note that the "dist" task only
// guarantees that the products will be built and their locations will be available in the environment variables
// provided to the script -- it is the responsibility of the user to write logic in the dist script to copy the
// generated binaries.
InputProducts []string
// Script is the content of a script that is written to file a file and run after the initial distribution
// process but before the artifact generation process. The contents of this value are written to a file with a
// header `#!/bin/bash` with the contents of the global `dist-script-include` prepended and executed. The script
// process inherits the environment variables of the Go process and also has the following environment variables
// defined:
//
// DIST_DIR: the absolute path to the root directory of the distribution created for the current product
// PROJECT_DIR: the root directory of project
// PRODUCT: product name
// VERSION: product version
// IS_SNAPSHOT: 1 if the version contains a git hash as part of the string, 0 otherwise
Script string
// Info specifies the type of the distribution to be built and configuration for it. If unspecified, defaults to
// a DistInfo of type SLSDistType.
Info DistInfo
// Publish is the configuration for the "publish" task.
Publish Publish
}
type DistInfoType string
const (
SLSDistType DistInfoType = "sls" // distribution that uses the Standard Layout Specification
BinDistType DistInfoType = "bin" // distribution that includes all of the binaries for a product
RPMDistType DistInfoType = "rpm" // RPM distribution
OSArchBinDistType DistInfoType = "os-arch-bin" // distribution that consists of the binaries for a specific OS/Architecture
ManualDistType DistInfoType = "manual" // distribution that consists of a distribution whose output is created by the distribution script
)
type DistInfo interface {
Type() DistInfoType
}
type ManualDistInfo struct {
// Extension is the extension used by the target output generated by the dist script: for example, "tgz",
// "zip", etc. Extension is used to locate the output generated by the dist script. The output should be a file
// of the form "{{product-name}}-{{version}}.{{Extension}}". If Extension is empty, it is assumed that the
// output has no extension and is of the form "{{product-name}}-{{version}}".
Extension string
}
func (i *ManualDistInfo) Type() DistInfoType {
return ManualDistType
}
type OSArchsBinDistInfo struct {
// OSArchs specifies the GOOS and GOARCH pairs for which TGZ distributions are created. If blank, defaults to
// the GOOS and GOARCH of the host system at runtime.
OSArchs []osarch.OSArch
}
func (i *OSArchsBinDistInfo) Type() DistInfoType {
return OSArchBinDistType
}
type BinDistInfo struct {
// OmitInitSh specifies whether or not the distribution should omit the auto-generated "init.sh" invocation
// script. If true, the "init.sh" script will not be generated and included in the output distribution.
OmitInitSh bool
// InitShTemplateFile is the relative path to the template that should be used to generate the "init.sh" script.
// If the value is absent, the default template will be used.
InitShTemplateFile string
}
func (i *BinDistInfo) Type() DistInfoType {
return BinDistType
}
type SLSDistInfo struct {
// InitShTemplateFile is the path to a template file that is used as the basis for the init.sh script of the
// distribution. The path is relative to the project root directory. The contents of the file is processed using
// Go templates and is provided with a distgo.ProductBuildSpec struct. If omitted, the default init.sh script
// is used.
InitShTemplateFile string
// ManifestTemplateFile is the path to a template file that is used as the basis for the manifest.yml file of
// the distribution. The path is relative to the project root directory. The contents of the file is processed
// using Go templates and is provided with a distgo.ProductBuildSpec struct.
ManifestTemplateFile string
// ServiceArgs is the string provided as the service arguments for the default init.sh file generated for the distribution.
ServiceArgs string
// ProductType is the SLS product type for the distribution.
ProductType string
// ManifestExtensions contain the SLS manifest extensions for the distribution.
ManifestExtensions map[string]interface{}
// Reloadable will enable the `init.sh reload` command which sends SIGHUP to the process.
Reloadable bool
// YMLValidationExclude specifies a matcher used to specify YML files or paths that should not be validated as
// part of creating the distribution. By default, the SLS distribution task verifies that all "*.yml" and
// "*.yaml" files in the distribution are syntactically valid. If a distribution is known to ship with YML files
// that are not valid YML, this parameter can be used to exclude those files from validation.
YMLValidationExclude matcher.Matcher
}
func (i *SLSDistInfo) Type() DistInfoType {
return SLSDistType
}
type RPMDistInfo struct {
// Release is the release identifier that forms part of the name/version/release/architecture quadruplet
// uniquely identifying the RPM package. Default is "1".
Release string
// ConfigFiles is a slice of absolute paths within the RPM that correspond to configuration files. RPM
// identifies these as mutable. Default is no files.
ConfigFiles []string
// BeforeInstallScript is the content of shell script to run before this RPM is installed. Optional.
BeforeInstallScript string
// AfterInstallScript is the content of shell script to run immediately after this RPM is installed. Optional.
AfterInstallScript string
// AfterRemoveScript is the content of shell script to clean up after this RPM is removed. Optional.
AfterRemoveScript string
}
func (i *RPMDistInfo) Type() DistInfoType {
return RPMDistType
}