Skip to content

Commit 6e81615

Browse files
committed
Allow passing private npm registry and credentials for make generate-go
1 parent bf5a74e commit 6e81615

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

hack/quicktype/Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,22 @@ image-build-quicktype: $(QUICKTYPE_IMAGE_RECEIPT)
9797
## Binaries
9898
## --------------------------------------
9999

100+
# Allow passing private NPM registry url and token.
101+
NPM_FLAGS :=
102+
ifneq ($(strip $(NPM_REGISTRY)),)
103+
# Registry set (no token required)
104+
NPM_REGISTRY := $(NPM_REGISTRY:https://%=%)
105+
NPM_FLAGS := --registry=https://$(NPM_REGISTRY)
106+
107+
# If a token is provided, add auth
108+
ifneq ($(strip $(NPM_TOKEN)),)
109+
NPM_FLAGS += --//$(NPM_REGISTRY):_authToken=$(NPM_TOKEN)
110+
endif
111+
endif
112+
100113
quicktype: $(QUICKTYPE)
101114
$(QUICKTYPE): $(QUICK_DIR)/package.json
102-
cd $(QUICK_DIR) && npm ci --user quicktype
115+
cd $(QUICK_DIR) && npm ci $(NPM_FLAGS) quicktype
103116

104117

105118
## --------------------------------------

pkg/util/cloudinit/schema/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ This directory contains schema files relates to Cloud-Init:
1313
## Generating the Go source code
1414

1515
Run `make generate-go` to generate the Go source code. If the local system has `npm`, it is used, otherwise a container image is used with either Docker or Podman.
16+
17+
This relies on `npm ci quicktype`. If you need to use a private npm registry which might requires authentication,
18+
you can set `NPM_TOKEN` and `NPM_REGISTRY` variables.`

pkg/util/netplan/schema/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ This directory contains schema files relates to Netplan:
1313
## Generating the Go source code
1414

1515
Run `make generate-go` to generate the Go source code. If the local system has `npm`, it is used, otherwise a container image is used with either Docker or Podman.
16+
17+
This relies on `npm ci quicktype`. If you need to use a private npm registry which might requires authentication,
18+
you can set `NPM_TOKEN` and `NPM_REGISTRY` variables.`

0 commit comments

Comments
 (0)