-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
2762 lines (2329 loc) · 119 KB
/
Makefile
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
###############################################################################
# Main IDC Makefile
###############################################################################
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
COMMA := ,
# Get directory that this Makefile is located in.
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Determine the IDC environment (IDC_ENV).
# If IDC_ENV is already set, then use that.
# Otherwise, if a directory that matches the hostname exists in build/environment, then use that.
# Otherwise, use "kind-singlecluster".
ifeq ($(IDC_ENV),)
HOSTNAME := $(shell hostname)
ifneq "$(wildcard build/environments/$(HOSTNAME))" ""
export IDC_ENV=$(HOSTNAME)
else
export IDC_ENV=kind-grc
endif
endif
# IDC_ENV_DIR can be used for any environment-specific files.
export IDC_ENV_DIR ?= build/environments/${IDC_ENV}
# Load environment-specific Makefiles.
INCLUDE_FILES = \
$(IDC_ENV_DIR)/Makefile.environment \
local/environments/$(IDC_ENV)/Makefile.environment
-include $(INCLUDE_FILES)
TMPDIR := $(shell mktemp -d)
export GOPATH ?= $(ROOT_DIR)/local/go
# Ensure that binaries installed with "go install" are in the PATH.
ORIGINAL_PATH := $(PATH)
ifeq (,$(findstring :$(GOPATH)/bin, $(PATH)))
export PATH := $(GOPATH)/bin:$(PATH)
endif
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
GOOGLE_API_DIR ?= public_api/proto/google/api
## Tool Versions
ARGOCD_VERSION ?= v2.9.3
# Releases are listed at https://github.com/metal3-io/baremetal-operator/releases
METAL3_BAREMETAL_OPERATOR_VERSION ?= 0.3.1
BAZELISK_VERSION ?= v1.22.0
GRPCURL_VERSION ?= 1.8.7
TIMESCALE_CHART_VERSION ?= 0.27.5
POSTGRES_CHART_VERSION ?= 12.2.6
OPENAPI_GENERATOR_TAG ?= :v6.2.1
CONTROLLER_TOOLS_VERSION ?= v0.16.4
CODEGEN_VERSION ?= 0.25.2
KUSTOMIZE_VERSION ?= v4.5.5
KUBECTL_VERSION ?= v1.24.9
# Releases are listed at https://github.com/helm/helm/releases
HELM_VERSION ?= v3.16.3
HELMFILE_VERSION ?= 0.169.2
VAULT_VERSION ?= 1.13.1
# Releases are listed at https://github.com/protocolbuffers/protobuf/releases
PROTOC_VERSION ?= 21.9
# Releases are listed at https://pkg.go.dev/google.golang.org/protobuf/cmd/protoc-gen-go
PROTOC_GEN_VERSION ?= 1.28
# Releases are listed at https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc
PROTOC_GEN_GO_GRPC_VERSION ?= 1.2
# Releases are listed at https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
GRPC_GATEWAY_VERSION ?= 2.12.0
# Releases are listed at https://github.com/golang/mock/releases/
MOCKGEN_VERSION ?= v1.6.0
OPAL_VERSION ?= 0.5.0
OPAL_HELM_VERSION ?= 0.0.11
OPAL_CLIENT_DOCKER_TAG ?= b98db071b2bf60f98eebf75de4ff474c68baf887532fb52a2d3a55bc23c5811e
PROTO_VALIDATE_VERSION ?= v0.10.1
TERRAFORM_VERSION ?= 1.8.5
JQ_VERSION ?= 1.7.1
YQ_VERSION ?= v4.35.2
GOLANGCI_LINT_VERSION ?= 1.63.4
## Tool Binaries
ARGOCD = $(LOCALBIN)/argocd-$(ARGOCD_VERSION)
AWS = $(LOCALBIN)/aws
BAZELISK = $(LOCALBIN)/bazelisk-$(BAZELISK_VERSION)
BAZEL = $(BAZELISK)
PROTOC = $(HOME)/.local/bin/protoc
GRPCURL = $(LOCALBIN)/grpcurl-$(GRPCURL_VERSION)
CONTROLLER_GEN = $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
CODEGEN_DIR = $(LOCALBIN)/code-generator-$(CODEGEN_VERSION)
CODEGEN_GENERATE_GROUPS = $(CODEGEN_DIR)/generate-groups.sh
KUSTOMIZE = $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
HELM = $(LOCALBIN)/helm-$(HELM_VERSION)
HELMFILE = $(LOCALBIN)/helmfile-$(HELMFILE_VERSION)
VAULT = $(LOCALBIN)/vault-$(VAULT_VERSION)
KUBECTL = $(LOCALBIN)/kubectl
TERRAFORM = $(LOCALBIN)/terraform-$(TERRAFORM_VERSION)
JQ = $(LOCALBIN)/jq-$(JQ_VERSION)
YQ = $(LOCALBIN)/yq-$(YQ_VERSION)
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
# When deploying kind, a local Docker registry will be started that listens on this port.
KIND_REGISTRY_PORT ?= 5001
LOCAL_REGISTRY_NAME ?= idc-registry-$(KIND_REGISTRY_PORT).$(shell id -un).intel.com
# Push container images to this repo.
export DOCKER_REGISTRY ?= localhost:$(KIND_REGISTRY_PORT)
# When run in Jenkins, we must use the GIT_BRANCH and GIT_URL provided in the environment to determine these values.
# Otherwise, we can use the standard git commands.
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
GIT_URL ?= $(shell git remote get-url origin)
# IDC version numbers
GIT_REV_COUNT := $(shell git rev-list --count HEAD)
GIT_SHORT_HASH := $(shell git rev-parse --short=8 HEAD)
export GIT_COMMIT := $(shell git rev-parse HEAD)
IDC_SEMANTIC_VERSION ?= 0.0.1
IDC_FULL_VERSION ?= $(IDC_SEMANTIC_VERSION)-$(GIT_COMMIT)
# Container images will have this prefix and tag.
DOCKER_IMAGE_PREFIX ?=
# Note that images used by Bazel-built Helm charts will be referenced using the SHA-256, not the tag.
export DOCKER_TAG ?= $(IDC_SEMANTIC_VERSION)-$(GIT_COMMIT)
# Helm settings.
# HELM_CHART_VERSION is the prefix. It will have a hash appended to it.
# - The idc-versions Helm chart version will include the Git commit hash and look like: 0.0.1-d693c958428c1bc500f3f2a95f657d28eb11bd1a
# - All other Helm chart versions will include a SHA-256 hash of the Helm chart and look like: 0.0.1-4ea989504fdda81d57ab36ebbf19bf938113d1d96753ff69c4b4fa6ae76c9e93
export HELM_CHART_VERSION ?= $(IDC_SEMANTIC_VERSION)
# Complete Helm chart versions will be downloaded as individual files to this directory with "make download-helm-chart-versions".
export HELM_CHART_VERSIONS_DIR ?= $(ROOT_DIR)/local/idc-versions/$(IDC_FULL_VERSION)/idc-versions/chart_versions
HELM_REGISTRY ?= localhost:$(KIND_REGISTRY_PORT)
HELM_PROJECT ?= intelcloud
HELMFILE_OPTS += --helm-binary $(HELM)
# Define resource attributes for traces when running tests.
OTEL_DEPLOYMENT_ENVIRONMENT ?= $(shell hostname)
export OTEL_RESOURCE_ATTRIBUTES ?= deployment.environment=$(OTEL_DEPLOYMENT_ENVIRONMENT)
# Disable proxy for addresses that end in .local.
ifeq (,$(findstring $(COMMA).local, $(no_proxy)))
export no_proxy := $(no_proxy),.local
endif
export NO_PROXY := $(no_proxy)
# Deployment configuration and secrets.
export REGION ?= us-dev-1
export AVAILABILITY_ZONE ?= us-dev-1a
export SECRETS_DIR ?= local/secrets
export SECRETS_DIR := $(abspath $(SECRETS_DIR))
export DB_ADMIN_USERNAME = postgres
export DB_USER_USERNAME = dbuser
export GRAFANA_ADMIN_USERNAME = admin
export HARVESTER_KUBECONFIG_DIR = $(SECRETS_DIR)/harvester-kubeconfig
export HARVESTER_KUBECONFIG = $(HARVESTER_KUBECONFIG_DIR)/harvester1
export SSH_PROXY_OPERATOR_ID_RSA = $(SECRETS_DIR)/ssh-proxy-operator/id_rsa
export VAULT_BACKUP_DIR = $(SECRETS_DIR)/vault-backup
export SSH_PROXY_SERVER_HOST_PUBLIC_KEY = $(SECRETS_DIR)/ssh-proxy-operator/host_public_key
export BM_INSTANCE_OPERATOR_ID_RSA = $(SECRETS_DIR)/bm-instance-operator/id_rsa
export BM_VALIDATION_OPERATOR_ID_RSA = $(SECRETS_DIR)/bm-validation-operator/id_rsa
export BM_INSTANCE_OPERATOR_HOST_PUBLIC_KEY = $(SECRETS_DIR)/bm-instance-operator/host_public_key
export VAULT_ADDR ?= http://dev.vault.cloud.intel.com.kind.local:80
export VAULT_TOKEN_FILE ?= $(SECRETS_DIR)/VAULT_TOKEN
export HOST_IP := $(shell ip -o route get to 10.248.2.1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
export KIND_API_SERVER_ADDRESS ?= $(HOST_IP)
export ARIA_CLIENT_ID_PREFIX ?= $(USER)
HELMFILE_ARGOCD_VALUES_DIR ?= $(SECRETS_DIR)/helm-values
HELMFILE_DUMP_YAML ?= $(SECRETS_DIR)/helmfile-dump.yaml
IKS_KUBERNETES_OPERATOR_CONFIG = $(SECRETS_DIR)/kubernetes-operator
IKS_KUBERNETES_RECONCILER_CONFIG = $(SECRETS_DIR)/kubernetes-reconciler
IKS_ILB_OPERATOR_CONFIG = $(SECRETS_DIR)/ilb-operator
BILLING_DRIVER_ARIA_SQS_ACCESS_KEY_ID = $(SECRETS_DIR)/billing_driver_aria_sqs_access_key_id
BILLING_DRIVER_ARIA_SQS_SECRET_ACCESS_KEY = $(SECRETS_DIR)/billing_driver_aria_sqs_secret_access_key
BILLING_DRIVER_ARIA_SQS_ACCOUNT_ID = $(SECRETS_DIR)/billing_driver_aria_sqs_account_id
SSH_PROXY_USER ?= guest-${USER}
# Helm releases matching this regex will be deleted when running "make upgrade-all-in-kind-v2".
# Example: us-dev-1-compute-api-server|us-dev-1-compute-db
DEPLOY_ALL_IN_KIND_APPLICATIONS_TO_DELETE ?=
DEPLOY_ALL_IN_KIND_IDC_SERVICES_DEPLOYMENT_METHOD ?= argocd
# Universe Deployer configuration
UNIVERSE_DEPLOYER_BUILDS_PER_HOST ?= 1
UNIVERSE_DEPLOYER_JOBS_PER_PIPELINE ?= 1
UNIVERSE_DEPLOYER_POOL_DIR ?= /tmp
TEST_UNIVERSE_CONFIG_FILE ?= universe_deployer/environments/testing1.json
UNIVERSE_CONFIG ?= universe_deployer/environments/${IDC_ENV}.json
RUN_MANIFESTS_GENERATOR_GIT_COMMIT ?= $(GIT_COMMIT)
# OS http server port
HTTP_SERVER_PORT ?= 50001
GUEST_HOST_MEMORY_MB ?= 16384
GUEST_HOST_DEPLOYMENTS ?= 3
# Matrix for Docker registry values:
# DOCKER_REGISTRY DOCKERIO_REGISTRY DOCKERIO_REPOSITORY_PREFIX
# Inside Intel, kind localhost:5001 internal-placeholder.com cache/
# Inside Intel, Jenkins internal-placeholder.com internal-placeholder.com cache/
# Staging w/o Harbor, kind localhost:5001 docker.io
# Staging w/ Harbor amr-idc-registry-pre.infra-host.com amr-idc-registry-pre.infra-host.com cache/
ifeq ($(DOCKERIO_REGISTRY),)
DOCKERIO_REGISTRY ?= docker.io
DOCKERIO_REPOSITORY_PREFIX ?=
endif
# internal-placeholder.com/cache/ OR docker.io/
export DOCKERIO_IMAGE_PREFIX ?= $(DOCKERIO_REGISTRY)/$(DOCKERIO_REPOSITORY_PREFIX)
# Same as above without trailing "/".
# internal-placeholder.com/cache OR docker.io
ifeq ($(DOCKERIO_REPOSITORY_PREFIX),)
DOCKERIO_REGISTRY_WITH_PREFIX ?= $(DOCKERIO_REGISTRY)
else
DOCKERIO_REGISTRY_WITH_PREFIX ?= $(DOCKERIO_REGISTRY)/$(DOCKERIO_REPOSITORY_PREFIX:/=)
endif
OPENAPI_DOCKER_PREFIX ?=
# Calculated variables.
UNAME_ARCH := $(shell uname -p)
ifeq ($(UNAME_ARCH), aarch64)
IDC_ARCH=arm64
BAZELISK_ARCH := arm64
HELM_ARCH := arm64
HELMFILE_ARCH := arm64
VAULT_ARCH := arm64
OPAL_SERVER_HELM_OPTS := --set imageRegistry=localhost:$(KIND_REGISTRY_PORT) \
--set postgresImageRegistry=arm64v8
OPAL_CLIENT_DOCKER_REPOSITORY := permitio/opal-client-standalone
OPAL_DOCKER_REGISTRY := localhost:$(KIND_REGISTRY_PORT)
OPAL_CLIENT_DOCKER_TAG := $(OPAL_VERSION)
# Tag "latest" as of 2023-03-16
POSTGRES_IMAGE_TAG ?= @sha256:50a96a21f2992518c2cb4601467cf27c7ac852542d8913c1872fe45cd6449947
else
IDC_ARCH=x86_64
BAZELISK_ARCH := amd64
HELM_ARCH := amd64
HELMFILE_ARCH := amd64
VAULT_ARCH := amd64
OPAL_SERVER_HELM_OPTS :=
OPAL_CLIENT_DOCKER_REPOSITORY := permitio/opal-client-standalone@sha256
OPAL_DOCKER_REGISTRY := $(DOCKERIO_REGISTRY_WITH_PREFIX)
# Tag "latest" as of 2023-03-10
POSTGRES_IMAGE_TAG ?= @sha256:fbcec7ba704eb8c846b2a265953fa8faaa562fb172e6670018e35da77ef06057
endif
LOCAL_BAZEL_REMOTE_CACHE_NAME ?= bazel-remote-cache
BAZEL_STARTUP_OPTS ?=
BAZEL_EXTRA_OPTS ?=
BAZEL_OPTS = $(BAZEL_EXTRA_OPTS)
HELMFILE_ENVIRONMENT ?= $(IDC_ENV)
HELMFILE_ENVIRONMENT_FILES = \
deployment/helmfile/environments/example.yaml.gotmpl \
deployment/helmfile/environments/example-region-*.yaml.gotmpl
DEPLOY_ALL_IN_KIND_OPTS = \
//go/pkg/universe_deployer/cmd/deploy_all_in_kind:deploy_all_in_kind -- \
--bazel-binary $(BAZEL) \
--commit $(shell git rev-parse HEAD) \
--docker-image-prefix "$(DOCKER_IMAGE_PREFIX)" \
--helm-project "$(HELM_PROJECT)" \
--idc-env $(IDC_ENV) \
--idc-services-deployment-method $(DEPLOY_ALL_IN_KIND_IDC_SERVICES_DEPLOYMENT_METHOD) \
--local-registry-name $(LOCAL_REGISTRY_NAME) \
--local-registry-port $(KIND_REGISTRY_PORT) \
--secrets-dir $(SECRETS_DIR) \
--semantic-version $(IDC_SEMANTIC_VERSION) \
--temp-dir local/deploy-all-in-kind \
--universe-config ${UNIVERSE_CONFIG}
###############################################################################
# DEFINE TARGET GROUPS FOR DEPLOY-ALL-IN-KIND (V1).
###############################################################################
# Containers built by Bazel.
BAZEL_CONTAINERS = \
$(BAZEL_CONTAINERS_WITH_HELM) \
$(BAZEL_CONTAINERS_WITHOUT_HELM)
# Containers built by Bazel with a Helm chart of the same name.
# Containers are built using Bazel.
# Helm charts are pushed using Bazel.
# Helm charts are deployed using Helmfile.
BAZEL_CONTAINERS_WITH_HELM = \
$(BAZEL_CONTAINERS_FOUNDATION) \
$(BAZEL_CONTAINERS_FINANCE) \
$(BAZEL_CONTAINERS_COMPUTE) \
$(BAZEL_CONTAINERS_STORAGE) \
$(BAZEL_CONTAINERS_NETWORKING) \
$(BAZEL_CONTAINERS_TRAINING) \
$(BAZEL_CONTAINERS_MISC) \
$(BAZEL_CONTAINERS_IKS) \
$(BAZEL_CONTAINERS_INSIGHTS) \
$(BAZEL_CONTAINERS_IKS_OPERATORS) \
$(BAZEL_CONTAINERS_KFAAS) \
$(BAZEL_CONTAINERS_CLOUDMONITOR) \
$(BAZEL_CONTAINERS_CLOUDMONITOR_LOGS) \
$(BAZEL_CONTAINERS_DATALOADER) \
$(BAZEL_CONTAINERS_DPAI) \
$(BAZEL_CONTAINERS_MAAS) \
$(BAZEL_CONTAINERS_QUOTA_MANAGEMENT_SERVICE)
BAZEL_CONTAINERS_FOUNDATION = \
cloudaccount \
authz \
user-credentials \
grpc-rest-gateway \
grpc-reflect \
oidc
BAZEL_CONTAINERS_FINANCE = \
cloudaccount-enroll \
productcatalog \
productcatalog-operator \
usage \
metering \
cloudcredits \
billing-standard \
billing-aria \
billing-intel \
billing \
billing-schedulers \
notification-gateway \
trade-scanner \
cloudcredits-worker
BAZEL_CONTAINERS_COMPUTE = \
baremetal-enrollment-api \
baremetal-enrollment-operator \
bm-instance-operator \
bm-validation-operator \
compute-api-server \
compute-metering-monitor \
firewall-operator \
fleet-node-reporter \
git-to-grpc-synchronizer \
instance-replicator \
loadbalancer-replicator \
loadbalancer-operator \
intel-device-plugin \
ssh-proxy-operator \
vm-instance-scheduler \
vm-instance-operator
BAZEL_CONTAINERS_NETWORKING = \
sdn-controller \
sdn-controller-rest \
sdn-integrity-checker \
sdn-vn-controller \
switch-config-saver
BAZEL_CONTAINERS_TRAINING = \
training-api-server \
armada
BAZEL_CONTAINERS_MISC = \
console
BAZEL_CONTAINERS_IKS = \
iks
BAZEL_CONTAINERS_INSIGHTS = \
security-insights \
kubescore \
security-scanner
BAZEL_CONTAINERS_IKS_OPERATORS = \
ilb-operator \
kubernetes-operator \
kubernetes-reconciler
BAZEL_CONTAINERS_KFAAS = \
kfaas
BAZEL_CONTAINERS_CLOUDMONITOR = \
cloudmonitor
BAZEL_CONTAINERS_CLOUDMONITOR_LOGS = \
cloudmonitor-logs-api-server
BAZEL_CONTAINERS_DPAI = \
dpai
BAZEL_CONTAINERS_MAAS = \
infaas-dispatcher \
infaas-inference \
maas-gateway
BAZEL_CONTAINERS_STORAGE = \
object-store-operator \
bucket-metering-monitor \
storage-api-server \
storage-operator \
vast-storage-operator \
vast-metering-monitor \
storage-replicator \
bucket-replicator \
storage-scheduler \
storage-kms \
storage-metering-monitor \
storage-user \
storage-custom-metrics-service \
storage-admin-api-server \
storage-resource-cleaner
BAZEL_CONTAINERS_QUOTA_MANAGEMENT_SERVICE = \
quota-management-service
BAZEL_CONTAINERS_DATALOADER = \
dataloader
# Containers built by Bazel without a Helm chart of the same name.
# Containers are built using Bazel.
# Helm charts are not pushed using Bazel.
# Helm charts are not deployed using Helmfile.
BAZEL_CONTAINERS_WITHOUT_HELM = \
opa
# Helm charts that can be pushed (with Bazel).
HELM_CHARTS = \
$(NON_BAZEL_CUSTOM_CHARTS) \
$(BAZEL_CONTAINERS_FOUNDATION) \
$(BAZEL_CONTAINERS_FINANCE) \
$(BAZEL_CONTAINERS_COMPUTE) \
$(BAZEL_CONTAINERS_STORAGE) \
$(BAZEL_CONTAINERS_NETWORKING) \
$(BAZEL_CONTAINERS_TRAINING) \
$(BAZEL_CONTAINERS_MISC) \
$(BAZEL_CONTAINERS_IKS) \
$(BAZEL_CONTAINERS_INSIGHTS) \
$(BAZEL_CONTAINERS_IKS_OPERATORS) \
$(BAZEL_CONTAINERS_KFAAS) \
$(BAZEL_CONTAINERS_CLOUDMONITOR) \
$(BAZEL_CONTAINERS_CLOUDMONITOR_LOGS) \
$(BAZEL_CONTAINERS_DATALOADER) \
$(BAZEL_CONTAINERS_DPAI) \
$(BAZEL_CONTAINERS_MAAS) \
$(BAZEL_CONTAINERS_QUOTA_MANAGEMENT_SERVICE)
# Helm charts deployed using Helmfile.
HELMFILE_CHARTS = \
$(HELM_CHARTS) \
$(THIRD_PARTY_CHARTS)
# IDC custom Helm charts.
# Containers are not built using Bazel.
# Helm charts are pushed using Bazel.
# Helm charts are deployed using Helmfile.
NON_BAZEL_CUSTOM_CHARTS = \
argo-cd-resources \
compute-crds \
debug-tools \
productcatalog-crds \
metal3-crds \
baremetal-enrollment-task \
baremetal-operator-ns \
baremetal-operator \
dhcp-proxy \
metallb-custom-resources \
bm-dnsmasq \
idcs-init-k8s-resources \
idcs-istio-custom-resources \
grpc-proxy \
nginx-s3-gateway\
netbox \
netbox-azuread-sso\
tftp-server \
database-creator \
ilb-crds \
loadbalancer-crds \
firewall-crds \
network-crds \
kubernetes-crds \
sdn-controller-crds \
sdn-restricted-sa \
idc-versions \
local-path-provisioner \
rate-limit \
rate-limit-redis \
vm-machine-image-resources
# 3rd-party Helm charts.
# Containers are not built using Bazel.
# Helm charts are not pushed using Bazel.
# Helm charts are deployed using Helmfile.
THIRD_PARTY_CHARTS = \
argo-cd \
coredns \
gitea \
opal \
postgresql \
timescaledb \
cert-manager \
external-secrets \
metallb \
grafana \
minio \
localstack \
cloudnative-pg \
operator \
tenant
# Dependencies for container-build.
# This builds the Helm chart, which depends on the container image.
CONTAINER_BUILD_DEPS = \
$(BAZEL_CONTAINERS_WITH_HELM:%=helm-build-%) \
$(BAZEL_CONTAINERS_WITHOUT_HELM:%=container-build-%)
# Dependencies for container-push.
CONTAINER_PUSH_DEPS = \
$(BAZEL_CONTAINERS:%=retry-container-push-%) \
# Dependencies for helm-push.
HELM_PUSH_DEPS = \
$(HELM_CHARTS:%=retry-helm-push-%)
# Dependencies for deploy-all-in-kind.
DEPLOY_ALL_IN_KIND_DEPS = \
show-make-config \
secrets \
deploy-registry \
deploy-kind \
deploy-k8s-infrastructure-helm-releases \
deploy-vault \
deploy-k8s-tls-secrets \
deploy-idc \
create-localstack-resources
# Dependencies for deploy-all-in-kind-v2.
DEPLOY_ALL_IN_KIND_V2_DEPS = \
show-make-config \
update-etc-hosts \
deploy-registry
# Metal3 namespaces for vault roles
export BAREMETAL_OPERATOR_NAMESPACES ?= metal3-1 metal3-2
# Dependencies for deploy-metal-in-kind.
DEPLOY_METAL_IN_KIND_DEPS ?= \
show-make-config \
secrets \
add-api-server-to-no-proxy \
secrets \
teardown-bmvs \
deploy-kind \
deploy-registry \
deploy-k8s-infrastructure-helm-releases \
deploy-vault \
deploy-baremetal-operator-ns \
deploy-cert-manager \
deploy-external-secrets \
deploy-metal3-crds \
deploy-metallb \
deploy-metallb-custom-resources \
deploy-baremetal-operator \
deploy-bm-dnsmasq \
deploy-dhcp-proxy \
setup-bmvs \
deploy-baremetal-enrollment-api \
deploy-baremetal-enrollment-task \
deploy-netbox-kind \
deploy-idc
DEPLOY_METAL_IN_RKE2_DEPS := \
secrets \
deploy-rke2 \
deploy-k8s-infrastructure-helm-releases \
deploy-vault \
deploy-baremetal-operator-ns \
deploy-cert-manager \
deploy-external-secrets \
deploy-metallb \
deploy-metallb-custom-resources \
deploy-metal3-crds \
deploy-baremetal-operator \
deploy-baremetal-enrollment-api \
deploy-baremetal-enrollment-task \
deploy-netbox-kind \
deploy-idc
# Dependencies for deploy-idc.
DEPLOY_IDC_DEPS = \
container-and-chart-push \
helm-chart-versions \
deploy-crds \
deploy-all-helm-releases
# Dependencies for deploy-foundation.
DEPLOY_FOUNDATION_DEPS = \
deploy-cloudaccount-db \
deploy-opal \
$(BAZEL_CONTAINERS_FOUNDATION:%=deploy-%) \
deploy-grpc-proxy
# Dependencies for deploy-finance.
DEPLOY_FINANCE_DEPS = \
deploy-metering-db \
deploy-cloudcredits-db \
deploy-billing-db \
deploy-usage-db \
deploy-notification-db \
deploy-productcatalog-db \
deploy-productcatalog-crds \
$(BAZEL_CONTAINERS_FINANCE:%=deploy-%)
# Dependencies for deploy-compute.
DEPLOY_COMPUTE_DEPS = \
deploy-compute-db \
deploy-compute-crds \
$(BAZEL_CONTAINERS_COMPUTE:%=deploy-%)
# Dependencies for deploy-storage.
DEPLOY_STORAGE_DEPS = \
deploy-storage-db \
$(BAZEL_CONTAINERS_STORAGE:%=deploy-%)
DEPLOY_TRAINING_DEPS = \
deploy-training-db \
$(BAZEL_CONTAINERS_TRAINING:%=deploy-%)
DEPLOY_IKS_DEPS = \
$(BAZEL_CONTAINERS_IKS:%=deploy-%)
DEPLOY_INSIGHTS_DEPS = \
deploy-insights-db \
$(BAZEL_CONTAINERS_INSIGHTS:%=deploy-%)
DEPLOY_KFAAS_DEPS = \
deploy-kfaas-db \
$(BAZEL_CONTAINERS_KFAAS:%=deploy-%)
DEPLOY_CLOUDMONITOR_DEPS = \
deploy-cloudmonitor-db \
$(BAZEL_CONTAINERS_CLOUDMONITOR:%=deploy-%)
DEPLOY_CLOUDMONITOR_LOGS_DEPS = \
deploy-cloudmonitor-logs-db \
$(BAZEL_CONTAINERS_CLOUDMONITOR_LOGS:%=deploy-%)
DEPLOY_DPAI_DEPS = \
deploy-dpai-db \
$(BAZEL_CONTAINERS_DPAI:%=deploy-%)
DEPLOY_IKS_OPERATORS_DEPS = \
deploy-ilb-crds \
deploy-kubernetes-crds \
$(BAZEL_CONTAINERS_IKS_OPERATORS:%=deploy-%)
DEPLOY_DATALOADER_DEPS = \
deploy-dataloader \
$(BAZEL_CONTAINERS_DATALOADER:%=deploy-%)
DEPLOY_MISC_DEPS = \
sdn-controller-crds \
sdn-controller \
sdn-controller-rest \
sdn-restricted-sa \
sdn-integrity-checker \
switch-config-saver \
deploy-console
DEPLOY_QUOTA_MANAGEMENT_DEPS = \
deploy-quota-management-service-db \
$(BAZEL_CONTAINERS_QUOTA_MANAGEMENT_SERVICE:%=deploy-%)
# Postgres databases.
DBS = \
authz \
billing \
cloudcredits \
cloudaccount \
metering \
$(REGION)-compute \
$(REGION)-dpai \
$(REGION)-insights \
$(REGION)-storage \
$(REGION)-training \
$(REGION)-iks \
$(REGION)-kfaas \
$(REGION)-cloudmonitor \
$(REGION)-cloudmonitor-logs \
$(REGION)-quota-management-service
SECRETS = \
$(IKS_KUBERNETES_OPERATOR_CONFIG) \
$(IKS_KUBERNETES_RECONCILER_CONFIG) \
$(IKS_ILB_OPERATOR_CONFIG)
###############################################################################
# CALCULATE BAZEL TEST TARGETS
###############################################################################
GO_TEST_TARGETS = $(shell $(BAZEL) query '\
tests(//go/...) \
except attr("tags", "manual", //go/...)')
BAZEL_TEST_TARGETS = \
$(GO_TEST_TARGETS) \
//deployment/universe_deployer:universe_config_tests
GO_NON_GINKGO_TEST_TARGETS = $(shell $(BAZEL) query '\
tests(//go/...) \
except rdeps(//go/..., @com_github_onsi_ginkgo_v2//:ginkgo) \
except attr("tags", "manual", //go/...)')
GINKGO_TEST_TARGETS = $(shell $(BAZEL) query '\
tests(//go/...) \
intersect rdeps(//go/..., @com_github_onsi_ginkgo_v2//:ginkgo) \
except attr("tags", "manual", //go/...)')
BAZEL_LARGE_JENKINS_TEST_TARGETS = $(shell $(BAZEL) query '\
tests(//go/...) \
intersect attr("size", "large", //go/...) \
intersect attr("tags", "jenkins", //go/...)')
BAZEL_ENORMOUS_JENKINS_TEST_TARGETS = $(shell $(BAZEL) query '\
tests(//go/test/compute/e2e/vm/...) \
intersect attr("size", "enormous", //go/test/compute/e2e/vm/...) \
intersect attr("tags", "jenkins", //go/test/compute/e2e/vm/...)')
BAZEL_ENORMOUS_JENKINS_BM_TEST_TARGETS = $(shell $(BAZEL) query '\
tests(//go/test/compute/e2e/bm/...) \
intersect attr("size", "enormous", //go/test/compute/e2e/bm/...) \
intersect attr("tags", "jenkins", //go/test/compute/e2e/bm/...)')
###############################################################################
# RULES
###############################################################################
.PHONY: all
all: help
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
.PHONY: generate
generate: bazel generate-go generate-proto generate-go-openapi generate-k8s fmt tidy gazelle generate-copyright-headers ## Generate all generated files that should be committed.
delete-generated-files-go: ## Deleted output of Go code generators.
rm -rf go/pkg/pb/*.{pb,gw,validate}.go
.PHONY: generate-go
generate-go: bazel protoc install-go-packages mockgen delete-generated-files-go ## Generate Go code.
cd go && $(BAZEL) run @go_sdk//:bin/go -- generate ./...
.PHONY: generate-proto
generate-proto: bazel ## Generate Protobuf files for IDE support.
$(BAZEL) run $(BAZEL_OPTS) //go/pkg/storage/storagecontroller:update_gen
.PHONY: generate-copyright-headers
generate-copyright-headers: ## only ./go folder for now
python3 ./hack/generate_copyright.py --dir ./go
# See https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/go.md
.PHONY: generate-go-openapi
generate-go-openapi: ## Generate Go OpenAPI clients.
rm -rf go/pkg/compute_api_server/openapi
docker run --rm -v $(shell pwd):/local \
-u $(shell id -u $(USER)):$(shell id -g $(USER)) \
$(OPENAPI_DOCKER_PREFIX)openapitools/openapi-generator-cli$(OPENAPI_GENERATOR_TAG) \
generate \
--input-spec /local/public_api/proto/compute.swagger.json \
--generator-name go \
--output /local/go/pkg/compute_api_server/openapi
rm go/pkg/compute_api_server/openapi/go.{mod,sum}
rm -rf go/pkg/compute_api_server/openapi/test
.PHONY: delete-generated-files-k8s
delete-generated-files-k8s: ## Deleted output of Kubernetes code generators to ensure there are no circular dependencies.
rm -f go/pkg/k8s/apis/private.cloud/v1alpha1/zz_generated.deepcopy.go
rm -rf go/pkg/k8s/generated
rm -rf go/pkg/k8s/config/crd/bases/*.yaml
rm -rf go/pkg/productcatalog_operator/config/rbac/role.yaml
rm -rf go/pkg/productcatalog_operator/config/crd/bases/*.yaml
rm -rf go/pkg/instance_operator/bm/config/rbac/role.yaml
rm -f deployment/charts/compute-crds/templates/*.yaml
rm -f deployment/charts/firewall-crds/templates/*.yaml
rm -f deployment/charts/productcatalog-crds/templates/*.yaml
rm -f go/pkg/sdn-controller/api/v1alpha1/zz_generated.deepcopy.go
rm -f deployment/charts/sdn-controller-crds/templates/*.yaml
rm -f deployment/charts/ilb-crds/templates/*.yaml
rm -f deployment/charts/loadbalancer-crds/templates/*.yaml
rm -f deployment/charts/kubernetes-crds/templates/*.yaml
# Run all Kubernetes code generators. These must run in a precise order.
# This uses the following code generators:
# - https://book.kubebuilder.io/reference/controller-gen.html
# - https://github.com/rancher/wrangler
# - https://github.com/kubernetes/code-generator
.PHONY: generate-k8s
generate-k8s: export PATH = $(shell $(BAZEL) info output_base)/external/go_sdk/bin:$(ORIGINAL_PATH)
generate-k8s: controller-gen codegen-tool delete-generated-files-k8s ## Run Kubernetes code generators.
@echo Generating go/pkg/k8s/apis/private.cloud/v1alpha1/zz_generated.deepcopy.go
cd go/pkg/k8s && $(CONTROLLER_GEN) object:headerFile="$(ROOT_DIR)/hack/boilerplate.go.txt" paths="./apis/..."
@echo Generating go/pkg/k8s/generated/clientset and go/pkg/k8s/generated/controllers
go run go/pkg/k8s/codegen/main.go
@echo Generating go/pkg/k8s/generated/cloudintelclient
cd go && $(CODEGEN_GENERATE_GROUPS) \
client,lister,informer \
github.com/intel-innersource/frameworks.cloud.devcloud.services.idc/go/pkg/k8s/generated/cloudintelclient \
github.com/intel-innersource/frameworks.cloud.devcloud.services.idc/go/pkg/k8s/apis \
private.cloud:v1alpha1 \
--output-base $(TMPDIR) \
--go-header-file $(ROOT_DIR)/hack/boilerplate.go.txt
mv $(TMPDIR)/github.com/intel-innersource/frameworks.cloud.devcloud.services.idc/go/pkg/k8s/generated/cloudintelclient \
go/pkg/k8s/generated
@echo Generating go/pkg/k8s/generated/metal3client
cd go && $(CODEGEN_GENERATE_GROUPS) \
all \
github.com/intel-innersource/frameworks.cloud.devcloud.services.idc/go/pkg/k8s/generated/metal3client \
github.com/intel-innersource/frameworks.cloud.devcloud.services.idc/go/pkg/k8s/apis \
metal3.io:v1alpha1 \
--output-base $(TMPDIR) \
--go-header-file $(ROOT_DIR)/hack/boilerplate.go.txt
mv $(TMPDIR)/github.com/intel-innersource/frameworks.cloud.devcloud.services.idc/go/pkg/k8s/generated/metal3client \
go/pkg/k8s/generated
@echo Generating go/pkg/k8s/config/crd/bases/*.yaml
cd go/pkg/k8s && $(CONTROLLER_GEN) crd paths="./apis/private.cloud/..." output:crd:artifacts:config=config/crd/bases
@echo Generating go/pkg/productcatalog_operator/config/crd/bases/*.yaml
cd go/pkg/productcatalog_operator && $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
@echo Generating go/pkg/instance_operator/bm/config/rbac/role.yaml
cd go/pkg/instance_operator && $(CONTROLLER_GEN) rbac:roleName=manager-role paths="./..." output:dir=bm/config/rbac
@echo Generating go/pkg/productcatalog_operator/config/rbac/role.yaml
cd go/pkg/productcatalog_operator && $(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..."
@echo Generating go/pkg/ilb_operator/config/crd/bases/*.yaml
cd go/pkg/ilb_operator && $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
@echo Generating go/pkg/ilb_operator/config/rbac/role.yaml
cd go/pkg/ilb_operator && $(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..."
@echo Generating go/pkg/firewall_operator/config/crd/bases/*.yaml
cd go/pkg/firewall_operator && $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
@echo Generating go/pkg/loadbalancer_operator/config/crd/bases/*.yaml
cd go/pkg/loadbalancer_operator && $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
@echo Generating go/pkg/loadbalancer_operator/config/rbac/role.yaml
cd go/pkg/loadbalancer_operator && $(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..."
@echo Generating go/pkg/kubernetes_operator/config/crd/bases/*.yaml
cd go/pkg/kubernetes_operator && $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
@echo Generating go/pkg/kubernetes_operator/config/rbac/role.yaml
cd go/pkg/kubernetes_operator && $(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..."
@echo Generating go/pkg/network/operator/config/crd/bases/*.yaml
cd go/pkg/network/operator && $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
@echo Generating go/pkg/network/operator/config/rbac/role.yaml
cd go/pkg/network/operator && $(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..."
@echo Generating go/pkg/network/operator/apis/v1alpha1/zz_generated.deepcopy.go
cd go/pkg/network/operator && $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
@echo Generating deployment/charts/compute-crds/templates/*.yaml
cp go/pkg/k8s/config/crd/bases/*.yaml deployment/charts/compute-crds/templates
@echo Generating deployment/charts/productcatalog-crds/templates/*.yaml
cp go/pkg/productcatalog_operator/config/crd/bases/*.yaml deployment/charts/productcatalog-crds/templates
@echo Generating deployment/charts/sdn-controller-crds/templates/*.yaml
cd go/pkg/sdn-controller && $(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./..." output:crd:artifacts:config=../../../deployment/charts/sdn-controller-crds/templates
@echo Generating go/pkg/sdn-controller/api/v1alpha1/zz_generated.deepcopy.go
cd go/pkg/sdn-controller && $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
@echo Generating deployment/charts/ilb-crds/templates/*.yaml
cp go/pkg/ilb_operator/config/crd/bases/*.yaml deployment/charts/ilb-crds/crds
@echo Generating deployment/charts/loadbalancer-crds/templates/*.yaml
cp go/pkg/loadbalancer_operator/config/crd/bases/*.yaml deployment/charts/loadbalancer-crds/templates/
@echo Generating deployment/charts/network-crds/templates/*.yaml
cp go/pkg/network/operator/config/crd/bases/*.yaml deployment/charts/network-crds/templates/
@echo Generating deployment/charts/firewall-crds/templates/*.yaml
cp go/pkg/firewall_operator/config/crd/bases/*.yaml deployment/charts/firewall-crds/templates
@echo Generating deployment/charts/kubernetes-crds/templates/*.yaml
cp go/pkg/kubernetes_operator/config/crd/bases/*.yaml deployment/charts/kubernetes-crds/crds
.PHONY: download-metal3-apis
download-metal3-apis: ## Download Metal3 APIs.
wget -q https://github.com/metal3-io/baremetal-operator/archive/refs/tags/v$(METAL3_BAREMETAL_OPERATOR_VERSION).tar.gz -O - | \
tar -xzv -C $(TMPDIR)
cp -rv $(TMPDIR)/baremetal-operator-$(METAL3_BAREMETAL_OPERATOR_VERSION)/apis/metal3.io/* go/pkg/k8s/apis/metal3.io/
$(MAKE) generate-copyright-headers
.PHONY: generate-docs
generate-docs: ## Run Protobuf documentation generator.
rm -rf $(ROOT_DIR)/docs/generated
mkdir -p $(ROOT_DIR)/docs/generated
docker run --rm \
-u $(shell id -u $(USER)):$(shell id -g $(USER)) \
-v $(ROOT_DIR)/public_api/proto:/protos:ro \
-v $(ROOT_DIR)/docs/generated:/out \
${DOCKERIO_IMAGE_PREFIX}pseudomuto/protoc-gen-doc@sha256:779263a6dc01fbe375298c4e556d784640539e7b2bd433a50588285da88b74d5 \
--doc_opt=html,index.html
.PHONY: docs
docs: bazel ## Build Sphinx documentation
$(BAZEL) build $(BAZEL_OPTS) //docs
docs-http-server: docs ## Run an HTTP server to serve Sphinx documentation
cd bazel-bin/docs/source/private_docs_html && \
python3 -m http.server 8180 --bind 127.0.0.1
.PHONY: go-sdk
go-sdk: bazel ## Build Go SDK.
cd go && $(BAZEL) build @go_sdk//:bin/go
.PHONY: go-sdk-export
go-sdk-export: ## Show command to export PATH to include the Go SDK. Run with "eval `make go-sdk-export`".
@$(MAKE) go-sdk 1>&2
@echo "export PATH=$(shell $(BAZEL) info output_base)/external/go_sdk/bin:$(ORIGINAL_PATH)"
.PHONY: go-get
go-get: bazel ## Update a Go module to the latest version. For example: GO_GET_OPTS=github.com/docker/docker make go-get gazelle
cd go && $(BAZEL) run @go_sdk//:bin/go -- get $(GO_GET_OPTS) $(GO_GET_MODULE)
.PHONY: go-list
go-list: bazel ## List Go modules.
cd go && $(BAZEL) run @go_sdk//:bin/go -- list -m all
.PHONY: go-mod-graph
go-mod-graph: bazel ## Show Go module graph.
cd go && $(BAZEL) run @go_sdk//:bin/go -- mod graph
.PHONY: go-mod-why
go-mod-why: bazel ## Explain why a Go module is needed.
cd go && $(BAZEL) run @go_sdk//:bin/go -- mod why $(GO_MOD_WHY_OPTS)
.PHONY: gazelle
gazelle: bazel tidy ## Run Gazelle to update Bazel dependency list based on Go imports.
$(BAZEL) run $(BAZEL_OPTS) //:gazelle
$(BAZEL) run $(BAZEL_OPTS) //:gazelle-update-repos
$(BAZEL) run $(BAZEL_OPTS) //:gazelle
.PHONY: tidy
tidy: bazel ## Update go.mod
cd go && $(BAZEL) run @go_sdk//:bin/go -- mod tidy
# Store our own copy of Google API Protobuf files per https://github.com/grpc-ecosystem/grpc-gateway#usage.
.PHONY: download-google-apis
download-google-apis: ## Download the latest Google API Protobuf files.
mkdir -p $(GOOGLE_API_DIR)
wget https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto -O $(GOOGLE_API_DIR)/annotations.proto
wget https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/field_behavior.proto -O $(GOOGLE_API_DIR)/field_behavior.proto
wget https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto -O $(GOOGLE_API_DIR)/http.proto
wget https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/httpbody.proto -O $(GOOGLE_API_DIR)/httpbody.proto
.PHONY: fmt
fmt: bazel ## Run go fmt against code.
cd go && $(BAZEL) run @go_sdk//:bin/go -- fmt ./...
.PHONY: test-fmt
test-fmt: bazel ## Run go fmt against code. Fail if any changes are made.
@go_fmt_temp=`mktemp --dry-run`; \
cd go && $(BAZEL) run @go_sdk//:bin/go -- fmt ./... | tee $$go_fmt_temp; \
fmt_count=`cat $$go_fmt_temp | wc -l`; \
rm -f $$go_fmt_temp; \
if [ "$$fmt_count" != "0" ] ; then \
echo "Format Failures found by 'go fmt': Please update the files above"; \
/bin/false; \
fi
.PHONY: helmfile-fmt
helmfile-fmt: $(YQ) ## Format Helmfile environment files.
for file in $(HELMFILE_ENVIRONMENT_FILES); do \