-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds support for the complete netplan specification.
- Loading branch information
Showing
20 changed files
with
6,238 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Copyright (c) 2024 VMware, Inc. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Required vars | ||
SCHEMA_IN ?= | ||
OUTPUT_GO ?= | ||
TOOLS_DIR ?= | ||
QUICK_DIR ?= | ||
START_TYP ?= | ||
|
||
# If you update this file, please follow | ||
# https://suva.sh/posts/well-documented-makefiles | ||
|
||
# Ensure Make is run with bash shell as some syntax below is bash-specific | ||
SHELL := /usr/bin/env bash | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
# Get the information about the platform on which the tools are built/run. | ||
GOHOSTOS := $(shell go env GOHOSTOS) | ||
GOHOSTARCH := $(shell go env GOHOSTARCH) | ||
GOHOSTOSARCH := $(GOHOSTOS)_$(GOHOSTARCH) | ||
|
||
# Directories. | ||
BIN_DIR := bin | ||
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin/$(GOHOSTOSARCH) | ||
export PATH := $(abspath $(BIN_DIR)):$(abspath $(TOOLS_BIN_DIR)):$(PATH) | ||
|
||
# Binaries. | ||
QUICKTYPE := $(QUICK_DIR)/node_modules/.bin/quicktype | ||
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports | ||
|
||
# Images. | ||
QUICKTYPE_IMAGE_NAME := vmop-quicktype | ||
QUICKTYPE_IMAGE_VERSION := latest | ||
QUICKTYPE_IMAGE ?= $(QUICKTYPE_IMAGE_NAME):$(QUICKTYPE_IMAGE_VERSION) | ||
|
||
# CRI_BIN is the path to the container runtime binary. | ||
ifeq (,$(strip $(GITHUB_RUN_ID))) | ||
# Prefer podman locally. | ||
CRI_BIN := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null) | ||
else | ||
# Prefer docker in GitHub actions. | ||
CRI_BIN := $(shell command -v docker 2>/dev/null || command -v podman 2>/dev/null) | ||
endif | ||
export CRI_BIN | ||
|
||
# Select how to run quicktype. | ||
ifeq (,$(shell command -v npm)) | ||
QUICKTYPE_METHOD ?= $(CRI_BIN) | ||
endif | ||
|
||
# Tooling binaries | ||
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports | ||
|
||
|
||
## -------------------------------------- | ||
## Help | ||
## -------------------------------------- | ||
|
||
help: ## Display this help | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
|
||
## -------------------------------------- | ||
## Tooling Binaries | ||
## -------------------------------------- | ||
|
||
TOOLING_BINARIES := $(GOIMPORTS) | ||
tools: $(TOOLING_BINARIES) ## Build tooling binaries | ||
$(TOOLING_BINARIES): | ||
make -C $(TOOLS_DIR) $(@F) | ||
|
||
|
||
## -------------------------------------- | ||
## Image | ||
## -------------------------------------- | ||
|
||
.PHONY: image-build | ||
image-build: ## Build the container images | ||
cd $(QUICK_DIR) && $(CRI_BIN) build -t $(QUICKTYPE_IMAGE) -f Dockerfile | ||
|
||
|
||
## -------------------------------------- | ||
## Binaries | ||
## -------------------------------------- | ||
|
||
quicktype: $(QUICKTYPE) ## Install quicktype | ||
$(QUICKTYPE): $(QUICK_DIR)/package.json | ||
cd $(QUICK_DIR) && npm ci --user quicktype | ||
|
||
|
||
## -------------------------------------- | ||
## Generate | ||
## -------------------------------------- | ||
|
||
$(OUTPUT_GO): $(SCHEMA_IN) | $(GOIMPORTS) | ||
ifeq (container,$(QUICKTYPE_METHOD)) | ||
$(OUTPUT_GO): image-build | ||
$(CRI_BIN) run -it --rm \ | ||
-v $$(pwd):/output \ | ||
-v $$(pwd)/$(SCHEMA_IN):/schema.json \ | ||
$(QUICKTYPE_IMAGE) | ||
mv -f schema.go $@ | ||
$(GOIMPORTS) -w $@ | ||
else | ||
$(OUTPUT_GO): | $(QUICKTYPE) | ||
$(QUICKTYPE) \ | ||
--src $(SCHEMA_IN) --src-lang schema \ | ||
--out $@ --lang go --package schema \ | ||
--top-level $(START_TYP) | ||
$(GOIMPORTS) -w $@ | ||
endif | ||
|
||
generate-go: ## Generate the go source code from the schemas | ||
$(MAKE) $(OUTPUT_GO) | ||
|
||
|
||
## -------------------------------------- | ||
## Cleanup | ||
## -------------------------------------- | ||
|
||
.PHONY: clean | ||
clean: ## Run all the clean targets | ||
rm -f $(OUTPUT_GO) | ||
|
||
.PHONY: clobber | ||
clobber: ## Remove all of the tooling as well | ||
$(MAKE) clean | ||
rm -fr $(BIN_DIR) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.