Skip to content

Commit 4e008d4

Browse files
authored
chore: separate goods package (#1731)
* chore: separate goods package * f * f * f * f * f * f * Trigger Build
1 parent e84003d commit 4e008d4

34 files changed

+223
-255
lines changed

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
bundle
2-
pkg/goods/bins/*
3-
!pkg/goods/bins/.placeholder
4-
pkg/goods/internal/bins/*
5-
!pkg/goods/internal/bins/.placeholder
6-
pkg/goods/images
2+
cmd/installer/goods/bins/*
3+
!cmd/installer/goods/bins/.placeholder
4+
cmd/installer/goods/internal/bins/*
5+
!cmd/installer/goods/internal/bins/.placeholder
6+
cmd/installer/goods/images
77
.pre-commit-config.yaml
88
vendor
99
e2e/kots-release-install/license.yaml

Makefile

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ default: build-ttl.sh
6969
split-hyphen = $(word $2,$(subst -, ,$1))
7070
random-string = $(shell LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c6)
7171

72-
.PHONY: pkg/goods/bins/k0s
73-
pkg/goods/bins/k0s:
72+
.PHONY: cmd/installer/goods/bins/k0s
73+
cmd/installer/goods/bins/k0s:
7474
$(MAKE) output/bins/k0s-$(K0S_VERSION)-$(ARCH)
75-
mkdir -p pkg/goods/bins
75+
mkdir -p cmd/installer/goods/bins
7676
cp output/bins/k0s-$(K0S_VERSION)-$(ARCH) $@
7777

7878
output/bins/k0s-%:
@@ -85,10 +85,10 @@ output/bins/k0s-%:
8585
chmod +x $@
8686
touch $@
8787

88-
.PHONY: pkg/goods/bins/kubectl-support_bundle
89-
pkg/goods/bins/kubectl-support_bundle:
88+
.PHONY: cmd/installer/goods/bins/kubectl-support_bundle
89+
cmd/installer/goods/bins/kubectl-support_bundle:
9090
$(MAKE) output/bins/kubectl-support_bundle-$(TROUBLESHOOT_VERSION)-$(ARCH)
91-
mkdir -p pkg/goods/bins
91+
mkdir -p cmd/installer/goods/bins
9292
cp output/bins/kubectl-support_bundle-$(TROUBLESHOOT_VERSION)-$(ARCH) $@
9393

9494
output/bins/kubectl-support_bundle-%:
@@ -100,10 +100,10 @@ output/bins/kubectl-support_bundle-%:
100100
rm -rf output/tmp
101101
touch $@
102102

103-
.PHONY: pkg/goods/bins/kubectl-preflight
104-
pkg/goods/bins/kubectl-preflight:
103+
.PHONY: cmd/installer/goods/bins/kubectl-preflight
104+
cmd/installer/goods/bins/kubectl-preflight:
105105
$(MAKE) output/bins/kubectl-preflight-$(TROUBLESHOOT_VERSION)-$(ARCH)
106-
mkdir -p pkg/goods/bins
106+
mkdir -p cmd/installer/goods/bins
107107
cp output/bins/kubectl-preflight-$(TROUBLESHOOT_VERSION)-$(ARCH) $@
108108

109109
output/bins/kubectl-preflight-%:
@@ -115,9 +115,9 @@ output/bins/kubectl-preflight-%:
115115
rm -rf output/tmp
116116
touch $@
117117

118-
.PHONY: pkg/goods/bins/local-artifact-mirror
119-
pkg/goods/bins/local-artifact-mirror:
120-
mkdir -p pkg/goods/bins
118+
.PHONY: cmd/installer/goods/bins/local-artifact-mirror
119+
cmd/installer/goods/bins/local-artifact-mirror:
120+
mkdir -p cmd/installer/goods/bins
121121
$(MAKE) -C local-artifact-mirror build OS=$(OS) ARCH=$(ARCH)
122122
cp local-artifact-mirror/bin/local-artifact-mirror-$(OS)-$(ARCH) $@
123123
touch $@
@@ -134,24 +134,24 @@ output/bins/fio-%:
134134
docker rm -f fio
135135
touch $@
136136

137-
.PHONY: pkg/goods/bins/fio
138-
pkg/goods/bins/fio:
137+
.PHONY: cmd/installer/goods/bins/fio
138+
cmd/installer/goods/bins/fio:
139139
ifneq ($(DISABLE_FIO_BUILD),1)
140140
$(MAKE) output/bins/fio-$(FIO_VERSION)-$(ARCH)
141-
mkdir -p pkg/goods/bins
141+
mkdir -p cmd/installer/goods/bins
142142
cp output/bins/fio-$(FIO_VERSION)-$(ARCH) $@
143143
endif
144144

145-
.PHONY: pkg/goods/bins/manager
146-
pkg/goods/bins/manager:
147-
mkdir -p pkg/goods/bins
145+
.PHONY: cmd/installer/goods/bins/manager
146+
cmd/installer/goods/bins/manager:
147+
mkdir -p cmd/installer/goods/bins
148148
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags="-s -w $(LD_FLAGS) -extldflags=-static" -o output/bins/manager ./cmd/manager
149149
cp output/bins/manager $@
150150
touch $@
151151

152-
.PHONY: pkg/goods/internal/bins/kubectl-kots
153-
pkg/goods/internal/bins/kubectl-kots:
154-
mkdir -p pkg/goods/internal/bins
152+
.PHONY: cmd/installer/goods/internal/bins/kubectl-kots
153+
cmd/installer/goods/internal/bins/kubectl-kots:
154+
mkdir -p cmd/installer/goods/internal/bins
155155
if [ "$(KOTS_BINARY_URL_OVERRIDE)" != "" ]; then \
156156
$(MAKE) output/bins/kubectl-kots-override ; \
157157
cp output/bins/kubectl-kots-override $@ ; \
@@ -218,24 +218,24 @@ go.mod: Makefile
218218
go mod tidy
219219

220220
.PHONY: static
221-
static: pkg/goods/bins/k0s \
222-
pkg/goods/bins/kubectl-preflight \
223-
pkg/goods/bins/kubectl-support_bundle \
224-
pkg/goods/bins/local-artifact-mirror \
225-
pkg/goods/bins/fio \
226-
pkg/goods/bins/manager \
227-
pkg/goods/internal/bins/kubectl-kots
221+
static: cmd/installer/goods/bins/k0s \
222+
cmd/installer/goods/bins/kubectl-preflight \
223+
cmd/installer/goods/bins/kubectl-support_bundle \
224+
cmd/installer/goods/bins/local-artifact-mirror \
225+
cmd/installer/goods/bins/fio \
226+
cmd/installer/goods/bins/manager \
227+
cmd/installer/goods/internal/bins/kubectl-kots
228228

229229
.PHONY: static-dryrun
230230
static-dryrun:
231-
@mkdir -p pkg/goods/bins pkg/goods/internal/bins
232-
@touch pkg/goods/bins/k0s \
233-
pkg/goods/bins/kubectl-preflight \
234-
pkg/goods/bins/kubectl-support_bundle \
235-
pkg/goods/bins/local-artifact-mirror \
236-
pkg/goods/bins/fio \
237-
pkg/goods/bins/manager \
238-
pkg/goods/internal/bins/kubectl-kots
231+
@mkdir -p cmd/installer/goods/bins cmd/installer/goods/internal/bins
232+
@touch cmd/installer/goods/bins/k0s \
233+
cmd/installer/goods/bins/kubectl-preflight \
234+
cmd/installer/goods/bins/kubectl-support_bundle \
235+
cmd/installer/goods/bins/local-artifact-mirror \
236+
cmd/installer/goods/bins/fio \
237+
cmd/installer/goods/bins/manager \
238+
cmd/installer/goods/internal/bins/kubectl-kots
239239

240240
.PHONY: embedded-cluster-linux-amd64
241241
embedded-cluster-linux-amd64: export OS = linux
@@ -272,8 +272,8 @@ envtest:
272272

273273
.PHONY: unit-tests
274274
unit-tests: envtest
275-
mkdir -p pkg/goods/bins pkg/goods/internal/bins
276-
touch pkg/goods/bins/BUILD pkg/goods/internal/bins/BUILD # compilation will fail if no files are present
275+
mkdir -p cmd/installer/goods/bins cmd/installer/goods/internal/bins
276+
touch cmd/installer/goods/bins/BUILD cmd/installer/goods/internal/bins/BUILD # compilation will fail if no files are present
277277
KUBEBUILDER_ASSETS="$(shell ./operator/bin/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(shell pwd)/operator/bin -p path)" \
278278
go test -tags exclude_graphdriver_btrfs -v ./pkg/... ./cmd/...
279279
$(MAKE) -C operator test
@@ -305,8 +305,8 @@ build-ttl.sh:
305305
.PHONY: clean
306306
clean:
307307
rm -rf output
308-
rm -rf pkg/goods/bins/*
309-
rm -rf pkg/goods/internal/bins/*
308+
rm -rf cmd/installer/goods/bins/*
309+
rm -rf cmd/installer/goods/internal/bins/*
310310
rm -rf build
311311
rm -rf bin
312312

@@ -329,8 +329,8 @@ scan:
329329

330330
.PHONY: buildtools
331331
buildtools:
332-
mkdir -p pkg/goods/bins pkg/goods/internal/bins
333-
touch pkg/goods/bins/BUILD pkg/goods/internal/bins/BUILD # compilation will fail if no files are present
332+
mkdir -p cmd/installer/goods/bins cmd/installer/goods/internal/bins
333+
touch cmd/installer/goods/bins/BUILD cmd/installer/goods/internal/bins/BUILD # compilation will fail if no files are present
334334
go build -tags exclude_graphdriver_btrfs -o ./output/bin/buildtools ./cmd/buildtools
335335

336336
.PHONY: list-distros
@@ -373,7 +373,7 @@ delete-node%:
373373
@dev/scripts/down.sh $*
374374

375375
.PHONY: test-lam-e2e
376-
test-lam-e2e: pkg/goods/bins/local-artifact-mirror
376+
test-lam-e2e: cmd/installer/goods/bins/local-artifact-mirror
377377
sudo go test ./cmd/local-artifact-mirror/e2e/... -v
378378

379379
.PHONY: bin/installer

cmd/installer/cli/adminconsole_resetpassword.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/replicatedhq/embedded-cluster/pkg/kotscli"
8+
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
99
rcutil "github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig/util"
1010
"github.com/sirupsen/logrus"
1111
"github.com/spf13/cobra"

cmd/installer/cli/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
14+
"github.com/replicatedhq/embedded-cluster/cmd/installer/goods"
1415
eckinds "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
1516
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
1617
"github.com/replicatedhq/embedded-cluster/kinds/types"
@@ -21,7 +22,6 @@ import (
2122
"github.com/replicatedhq/embedded-cluster/pkg/config"
2223
"github.com/replicatedhq/embedded-cluster/pkg/configutils"
2324
"github.com/replicatedhq/embedded-cluster/pkg/dryrun"
24-
"github.com/replicatedhq/embedded-cluster/pkg/goods"
2525
"github.com/replicatedhq/embedded-cluster/pkg/helpers"
2626
"github.com/replicatedhq/embedded-cluster/pkg/helpers/systemd"
2727
"github.com/replicatedhq/embedded-cluster/pkg/k0s"

cmd/installer/cli/install2.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import (
99

1010
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1111
k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
12+
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
1213
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
1314
"github.com/replicatedhq/embedded-cluster/pkg/addons2"
1415
"github.com/replicatedhq/embedded-cluster/pkg/configutils"
1516
"github.com/replicatedhq/embedded-cluster/pkg/extensions"
1617
"github.com/replicatedhq/embedded-cluster/pkg/helpers"
1718
"github.com/replicatedhq/embedded-cluster/pkg/k0s"
18-
"github.com/replicatedhq/embedded-cluster/pkg/kotscli"
1919
"github.com/replicatedhq/embedded-cluster/pkg/kubeutils"
2020
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
2121
"github.com/replicatedhq/embedded-cluster/pkg/netutils"
@@ -24,6 +24,7 @@ import (
2424
"github.com/replicatedhq/embedded-cluster/pkg/release"
2525
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
2626
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
27+
"github.com/replicatedhq/embedded-cluster/pkg/support"
2728
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
2829
"github.com/sirupsen/logrus"
2930
"github.com/spf13/cobra"
@@ -250,6 +251,16 @@ func runInstall2(cmd *cobra.Command, args []string, name string, flags Install2C
250251
ConfigValuesFile: flags.configValues,
251252
ServiceCIDR: flags.cidrCfg.ServiceCIDR,
252253
DisasterRecoveryEnabled: disasterRecoveryEnabled,
254+
KotsInstaller: func(msg *spinner.MessageWriter) error {
255+
opts := kotscli.InstallOptions{
256+
AppSlug: flags.license.Spec.AppSlug,
257+
LicenseFile: flags.licenseFile,
258+
Namespace: runtimeconfig.KotsadmNamespace,
259+
AirgapBundle: flags.airgapBundle,
260+
ConfigValuesFile: flags.configValues,
261+
}
262+
return kotscli.Install(opts, msg)
263+
},
253264
}); err != nil {
254265
metrics.ReportApplyFinished(cmd.Context(), "", flags.license, err)
255266
return err
@@ -267,7 +278,7 @@ func runInstall2(cmd *cobra.Command, args []string, name string, flags Install2C
267278
return err
268279
}
269280

270-
if err = kotscli.CreateHostSupportBundle(); err != nil {
281+
if err = support.CreateHostSupportBundle(); err != nil {
271282
logrus.Warnf("unable to create host support bundle: %v", err)
272283
}
273284

cmd/installer/cli/install_runpreflights.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"strings"
99
"time"
1010

11+
"github.com/replicatedhq/embedded-cluster/cmd/installer/goods"
12+
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
1113
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
1214
"github.com/replicatedhq/embedded-cluster/pkg/addons"
1315
"github.com/replicatedhq/embedded-cluster/pkg/airgap"
1416
"github.com/replicatedhq/embedded-cluster/pkg/configutils"
1517
"github.com/replicatedhq/embedded-cluster/pkg/dryrun"
16-
"github.com/replicatedhq/embedded-cluster/pkg/goods"
1718
"github.com/replicatedhq/embedded-cluster/pkg/helpers"
1819
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
1920
"github.com/replicatedhq/embedded-cluster/pkg/preflights"
@@ -279,7 +280,17 @@ func getAddonsApplier(cmd *cobra.Command, opts addonsApplierOpts, adminConsolePw
279280
}
280281

281282
addonOpts = append(addonOpts, addons.WithLicense(license))
282-
addonOpts = append(addonOpts, addons.WithLicenseFile(opts.license))
283+
284+
addonOpts = append(addonOpts, addons.WithKotsInstaller(func(msg *spinner.MessageWriter) error {
285+
opts := kotscli.InstallOptions{
286+
AppSlug: license.Spec.AppSlug,
287+
LicenseFile: opts.license,
288+
Namespace: runtimeconfig.KotsadmNamespace,
289+
AirgapBundle: opts.airgapBundle,
290+
ConfigValuesFile: opts.configValues,
291+
}
292+
return kotscli.Install(opts, msg)
293+
}))
283294
}
284295

285296
if opts.airgapBundle != "" {

cmd/installer/cli/materialize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
"os"
77

8+
"github.com/replicatedhq/embedded-cluster/cmd/installer/goods"
89
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
9-
"github.com/replicatedhq/embedded-cluster/pkg/goods"
1010
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
1111
"github.com/spf13/cobra"
1212
)

cmd/installer/cli/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/aws/aws-sdk-go/aws/session"
1818
"github.com/aws/aws-sdk-go/service/s3"
1919
k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
20+
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
2021
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
2122
"github.com/replicatedhq/embedded-cluster/pkg/addons"
2223
"github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole"
@@ -28,7 +29,6 @@ import (
2829
"github.com/replicatedhq/embedded-cluster/pkg/disasterrecovery"
2930
"github.com/replicatedhq/embedded-cluster/pkg/helpers"
3031
"github.com/replicatedhq/embedded-cluster/pkg/k0s"
31-
"github.com/replicatedhq/embedded-cluster/pkg/kotscli"
3232
"github.com/replicatedhq/embedded-cluster/pkg/kubeutils"
3333
"github.com/replicatedhq/embedded-cluster/pkg/netutils"
3434
"github.com/replicatedhq/embedded-cluster/pkg/prompts"

cmd/installer/cli/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/replicatedhq/embedded-cluster/pkg/kotscli"
8+
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
99
"github.com/replicatedhq/embedded-cluster/pkg/release"
1010
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
1111
rcutil "github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig/util"
File renamed without changes.

0 commit comments

Comments
 (0)