Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Create a top-level directory for provider template
Browse files Browse the repository at this point in the history
Signed-off-by: Vandana Pathak <[email protected]>
  • Loading branch information
Vandana Pathak authored and vuil committed Oct 12, 2022
1 parent 59b5a1d commit f173e65
Show file tree
Hide file tree
Showing 300 changed files with 195 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/plugin_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "cmd/cli/plugin/cluster/**"
- "cmd/cli/plugin/managementcluster/**"
- 'tkg/**'
- 'pkg/v1/providers/**'
- 'providers/**'
- '.github/workflows/plugin_tests.yaml'

concurrency:
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: [ main, release-* ]
paths:
- 'tkg/**'
- 'pkg/v1/providers/**'
- 'providers/**'
- '.github/workflows/providers.yaml'

jobs:
Expand All @@ -22,8 +22,8 @@ jobs:
- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: pkg/v1/providers
config_file: pkg/v1/providers/.yamllint
file_or_dir: providers
config_file: providers/.yamllint

- name: Set up Go 1.x
uses: actions/setup-go@v3
Expand Down Expand Up @@ -68,21 +68,21 @@ jobs:
echo PRNUM==${{ steps.extract_pr.outputs.prnum }}
echo BASEBRANCH=${{ steps.extract_pr.outputs.basebranch }}
env BASEBRANCH=${{ steps.extract_pr.outputs.basebranch }}
status=$(test -s ./pkg/v1/providers/tests/clustergen/testdata/clustergen.diff.txt; echo $?)
status=$(test -s ./providers/tests/clustergen/testdata/clustergen.diff.txt; echo $?)
CLUSTERCTL=clusterctl CLI_REPO=$PWD ./hack/clustergen/ci-validate-clustergen.sh ${{ steps.extract_pr.outputs.branch }} ${{ steps.extract_pr.outputs.basebranch }}
echo "##[set-output name=diffstatus;]$status"
echo $status > ./pkg/v1/providers/tests/clustergen/testdata/clustergen.status
echo ${{ steps.extract_pr.outputs.prnum }} > ./pkg/v1/providers/tests/clustergen/testdata/prnum
echo $status > ./providers/tests/clustergen/testdata/clustergen.status
echo ${{ steps.extract_pr.outputs.prnum }} > ./providers/tests/clustergen/testdata/prnum
id: clustergen

- id: publish-clustergen-results-as-artifacts
uses: actions/upload-artifact@v3
with:
name: clustergen-output
path: |
./pkg/v1/providers/tests/clustergen/testdata/prnum
./pkg/v1/providers/tests/clustergen/testdata/clustergen.status
./pkg/v1/providers/tests/clustergen/testdata/clustergen.diff.txt
./pkg/v1/providers/tests/clustergen/testdata/clustergen_cc.diff.txt
./pkg/v1/providers/tests/clustergen/testdata/clustergen_noncc_vs_cc.diff.txt
./pkg/v1/providers/tests/clustergen/testdata/clustergen.html
./providers/tests/clustergen/testdata/prnum
./providers/tests/clustergen/testdata/clustergen.status
./providers/tests/clustergen/testdata/clustergen.diff.txt
./providers/tests/clustergen/testdata/clustergen_cc.diff.txt
./providers/tests/clustergen/testdata/clustergen_noncc_vs_cc.diff.txt
./providers/tests/clustergen/testdata/clustergen.html
2 changes: 1 addition & 1 deletion .github/workflows/tkg_integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'tkg/**'
- '!packageclients/**'
- '!cmd/cli/plugin/package/test/**'
- 'pkg/v1/providers/**'
- 'providers/**'
- '.github/workflows/tkg_integration_tests.yaml'

concurrency:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tkg_integration_tests_clusterclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- 'packages/**'
- '!packageclients/**'
- '!cmd/cli/plugin/package/test/**'
- 'pkg/v1/providers/**'
- 'providers/**'
- '.github/workflows/tkg_integration_tests*.yaml'

push:
Expand All @@ -30,7 +30,7 @@ on:
- 'packages/**'
- '!packageclients/**'
- '!cmd/cli/plugin/package/test/**'
- 'pkg/v1/providers/**'
- 'providers/**'
- '.github/workflows/tkg_integration_tests*.yaml'

concurrency:
Expand Down
10 changes: 5 additions & 5 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
/docs @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tkg-iam-owners @vmware-tanzu/tkg-addons-owners @vmware-tanzu/tanzu-framework-lcm-reviewers @vmware-tanzu/tanzu-framework-docs
/tkg/auth @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tkg-iam-owners
/pkg/v1/cli @vmware-tanzu/tanzu-framework-reviewers
/pkg/v1/providers @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-lcm-reviewers @vmware-tanzu/tkg-infra-x
/pkg/v1/providers/ytt/02_addons/auth @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tkg-iam-owners
/pkg/v1/providers/ytt/02_addons/avi @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/ako-owners
/pkg/v1/providers/ytt/03_customizations/02_avi @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/ako-owners
/providers @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-lcm-reviewers @vmware-tanzu/tkg-infra-x
/providers/ytt/02_addons/auth @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tkg-iam-owners
/providers/ytt/02_addons/avi @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/ako-owners
/providers/ytt/03_customizations/02_avi @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/ako-owners
/tkg @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-lcm-reviewers
/packageclients/pkg/kappclient @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tkg-addons-owners
/tkg/tkgconfigpaths @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-release-team
Expand All @@ -30,7 +30,7 @@
/cmd/cli/plugin/feature @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-api-machinery-owners
/cmd/cli/plugin-admin/codegen @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-api-machinery-owners
/pkg/v1/codegen @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-api-machinery-owners
/pkg/v1/providers/ytt/02_addons/management-packages @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-api-machinery-owners
/providers/ytt/02_addons/management-packages @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-api-machinery-owners
/hack/packages @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-api-machinery-owners
/docs/api-machinery @vmware-tanzu/tanzu-framework-reviewers @vmware-tanzu/tanzu-framework-api-machinery-owners
# Package owners. Add individual packages here if they need to be owned by a specific team.
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ TOOLS_DIR := $(abspath hack/tools)
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
BIN_DIR := bin
ADDONS_DIR := addons
YTT_TESTS_DIR := pkg/v1/providers/tests
YTT_TESTS_DIR := providers/tests
PACKAGES_SCRIPTS_DIR := $(abspath hack/packages/scripts)
UI_DIR := tkg/web
GO_MODULES=$(shell find . -path "*/go.mod" | grep -v "^./pinniped/" | xargs -I _ dirname _)
PROVIDER_BUNDLE_ZIP = pkg/v1/providers/client/manifest/providers.zip
PROVIDER_BUNDLE_ZIP = providers/client/manifest/providers.zip
TKG_PROVIDER_BUNDLE_ZIP = tkg/tkgctl/client/manifest/providers.zip

PINNIPED_GIT_REPOSITORY = https://github.com/vmware-tanzu/pinniped.git
Expand Down Expand Up @@ -204,7 +204,7 @@ prep-build-cli: ensure-pinniped-repo ## Prepare for building the CLI
$(GO) mod tidy
EMBED_PROVIDERS_TAG=embedproviders
ifeq "${BUILD_TAGS}" "${EMBED_PROVIDERS_TAG}"
make -C pkg/v1/providers -f Makefile generate-provider-bundle-zip
make -C providers -f Makefile generate-provider-bundle-zip
cp -f ${PROVIDER_BUNDLE_ZIP} $(TKG_PROVIDER_BUNDLE_ZIP)
endif

Expand Down Expand Up @@ -490,13 +490,13 @@ test: generate manifests build-cli-mocks ## Run tests
## Skip running TKG integration tests
$(MAKE) ytt -C $(TOOLS_DIR)

echo "Verifying cluster-api packages and pkg/v1/providers are in sync..."
echo "Verifying cluster-api packages and providers are in sync..."
make -C hack/providers-sync-tools validate
echo "... cluster-api packages are in sync"

## Test the YTT cluster templates
echo "Changing into the provider test directory to verify ytt cluster templates..."
cd ./pkg/v1/providers/tests/unit && PATH=$(abspath hack/tools/bin):"$(PATH)" $(GO) test -coverprofile coverage1.txt -v -timeout 120s ./
cd ./providers/tests/unit && PATH=$(abspath hack/tools/bin):"$(PATH)" $(GO) test -coverprofile coverage1.txt -v -timeout 120s ./
echo "... ytt cluster template verification complete!"

echo "Verifying package tests..."
Expand Down Expand Up @@ -740,11 +740,11 @@ generate-package-secret: ## Generate the default package values secret. Usage: m

.PHONY: clustergen
clustergen: ## Generate diff between 'before' and 'after' of cluster configuration outputs using clustergen
CLUSTERGEN_BASE=${CLUSTERGEN_BASE} make -C pkg/v1/providers -f Makefile cluster-generation-diffs
CLUSTERGEN_BASE=${CLUSTERGEN_BASE} make -C providers -f Makefile cluster-generation-diffs

.PHONY: generate-embedproviders
generate-embedproviders: ## Generate provider bundle to be embedded for local testing
make -C pkg/v1/providers -f Makefile generate-provider-bundle-zip
make -C providers -f Makefile generate-provider-bundle-zip
cp -f ${PROVIDER_BUNDLE_ZIP} $(TKG_PROVIDER_BUNDLE_ZIP)

## --------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions docs/cli/tkgctl/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Library components in tkgctl

This library includes coresponding [providers](/pkg/v1/providers) to provide the templates and ytt overlays required to generate cluster configuration YAML documents.
This library includes coresponding [providers](/providers) to provide the templates and ytt overlays required to generate cluster configuration YAML documents.

## [tkgctl library](/tkg/tkgctl)

Expand Down Expand Up @@ -89,8 +89,8 @@ reference:
* This uses bundled go-bindata file which contains kick-start UI bits
* API is developed using swagger specification which gets used by UI as well as backend

## [Providers](/pkg/v1/providers)
## [Providers](/providers)

* This package maintains a set of CAPI provider CRDs, cluster templates, and ytt overlays required by the library.
* This allows cluster configuration generation to be customizable potentially without modifying a single line of golang code.
* More information regarding providers are [here](/pkg/v1/providers)
* More information regarding providers are [here](/providers)
4 changes: 2 additions & 2 deletions docs/design/bringyourownhost-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ The prod plan: three control plane nodes and three worker nodes.
## Detailed Design

1. Add the “**infrastructure-byoh**” folder which contains the YTT templates to generate the YAML files, so that CAPI can provision BYOH workload clusters using these YAML files.
Update "pkg/v1/providers/config.yaml" and create new YTT under folder " pkg/v1/providers/infrastructure-byoh/v0.1.0/" to support BYOH as a new type of provider.
Update "providers/config.yaml" and create new YTT under folder " providers/infrastructure-byoh/v0.1.0/" to support BYOH as a new type of provider.

2. Add the configuration item to let users define control plane endpoint for BYOH workload cluster.
Update "pkg/v1/providers/config_default.yaml" and tanzu-framework go code, so that new configurations can be read to create BYOH workload cluster.
Update "providers/config_default.yaml" and tanzu-framework go code, so that new configurations can be read to create BYOH workload cluster.

3. Configurations to provision BYOH workload clusters should be validated in case of invalid configuration input.

Expand Down
4 changes: 2 additions & 2 deletions hack/check-mdlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ docker run --rm -v "$(pwd)":/build \
-i tkg/web/node_modules \
-i docs/cli/commands \
-i test/cli/mock \
-i pkg/v1/providers/ytt/vendir \
-i pkg/v1/providers/provider-bundle/providers/ytt/vendir \
-i providers/ytt/vendir \
-i providers/provider-bundle/providers/ytt/vendir \
-i pinniped .
2 changes: 1 addition & 1 deletion hack/check/.yamllintconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends: relaxed

ignore: |
*/tkg/web/node_modules/
*/pkg/v1/providers/provider-bundle
*/providers/provider-bundle
rules:
line-length: disable
Expand Down
2 changes: 1 addition & 1 deletion hack/clustergen/ci-validate-clustergen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CLI_REPO=${CLI_REPO:-${PWD}/../..}
GIT_BRANCH_PROVIDERS=$1
GIT_BRANCH_PROVIDERS_BASE=$2

cd pkg/v1/providers
cd providers

# TODO: As we are using providers as library, clustergen should not rely on building binary
# each time with new providers, instead we should write some go testing tool which runs
Expand Down
22 changes: 11 additions & 11 deletions hack/providers-sync-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

Tanzu-framework is moving towards packaging cluster-api componentry. While this
transition is happening, tanzu-framework will have cluster-api components in
two locations: `packages/cluster-api*` and `pkg/v1/providers`.
two locations: `packages/cluster-api*` and `providers`.

These tools exist to ensure cluster-api related packages in the
`packages` directory stay in sync with the content in
`pkg/v1/providers`.
`providers`.

## How it works

Expand All @@ -24,32 +24,32 @@ overlays.
1. The first set of overlays come from the package's overlays.

1. The second set of overlays are specific to edits needed to
`pkg/v1/providers`, and exist in the `hack/provider-sync-tools/<some
`providers`, and exist in the `hack/provider-sync-tools/<some
cluster-api package>/overlay`. An example of such an edit would be the
controller image in the CRDs of the package.

This tooling will prevent edits made directly to the cluster-api related
folders in `pkg/v1/providers`. Instead of directly editing those files,
folders in `providers`. Instead of directly editing those files,
overlays should be created in `hack/provider-sync-tools/<some cluster-api
package>/overlay`. Running the `make all` target in this folder will render the
package contents along with the overlays, and then place the edited files in
`pkg/v1/providers`.
`providers`.

The validate task will ensure that the rendered content from the package and
overlays have no diff with the content of `pkg/v1/providers`.
overlays have no diff with the content of `providers`.

## What to do in common scenarios

1. Making a tweak to `pkg/v1/providers/<cluster-api-folder>`
1. Making a tweak to `providers/<cluster-api-folder>`
- add an overlay file to `hack/provider-sync-tools/<some cluster-api
package>/overlays`.
NOTE: There are many files in `pkg/v1/providers/<cluster-api-folder>/` and
NOTE: There are many files in `providers/<cluster-api-folder>/` and
only some of them are copied from upstream cluster-api, typically CRDs.
These sync tools are intended to sync the files that come from upstream
and the tweaks to files that come from upstream. Files in
`pkg/v1/providers/<cluster-api-folder>` that are not from upstream should
`providers/<cluster-api-folder>` that are not from upstream should
be edited in place, i.e. cluster configuration files.
- run `make all` to and check to see that `pkg/v1/providers/<cluster-api
- run `make all` to and check to see that `providers/<cluster-api
folder>` contents looks as desired.
- commit the changes

Expand All @@ -58,5 +58,5 @@ overlays have no diff with the content of `pkg/v1/providers`.
vendir file to match the desired version
- run the unit tests in the package(s), ensuring they're passing.
- `cd hack/provider-sync-tools && make all`
- ensure the `pkg/v1/providers/<cluster-api-folder>` looks as desired.
- ensure the `providers/<cluster-api-folder>` looks as desired.
- commit the changes
2 changes: 1 addition & 1 deletion hack/providers-sync-tools/move.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function place_rendered_files() {

local version=$(cat ../../packages/${source_package_name}/vendir.yml | grep tag | sed 's/^.*tag: //')

cp -r "${rendered_dir}/upstream/." "../../pkg/v1/providers/${provider_name}/${version}/"
cp -r "${rendered_dir}/upstream/." "../../providers/${provider_name}/${version}/"
}

place_rendered_files "cluster-api" "cluster-api"
Expand Down
2 changes: 1 addition & 1 deletion hack/providers-sync-tools/render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ render_upstream_package_file "cluster-api-provider-vsphere"

# infrastructure-docker: The infrastructure-components.yaml is named
# infrastructure-components-development.yaml upstream. Renaming it to
# infrastructure-components.yaml here to match pkg/v1/providers naming.
# infrastructure-components.yaml here to match providers naming.
mv cluster-api-provider-docker/build/rendered/upstream/infrastructure-components{-development,}.yaml
6 changes: 3 additions & 3 deletions hack/providers-sync-tools/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ function validate_rendered_files() {
local rendered_files="$(find "${rendered_dir}/upstream" -type f)"
set +e
for rendered_file in ${rendered_files}; do
diff -s "../../pkg/v1/providers/${provider_name}/${version}/$(basename ${rendered_file})" "${rendered_file}"
diff -s "../../providers/${provider_name}/${version}/$(basename ${rendered_file})" "${rendered_file}"
local exit_code="${?}"
if [[ ${exit_code} -ne 0 ]]; then
echo "[Error] Files ${rendered_file} and ../../pkg/v1/providers/${provider_name}/${version}/$(basename ${rendered_file}) are different."
echo "[Error] pkg/v1/providers is out of sync with packages/cluster-api*. See 'hack/providers-sync-tools/README.md'."
echo "[Error] Files ${rendered_file} and ../../providers/${provider_name}/${version}/$(basename ${rendered_file}) are different."
echo "[Error] providers is out of sync with packages/cluster-api*. See 'hack/providers-sync-tools/README.md'."
exit ${exit_code}
fi
done
Expand Down
2 changes: 1 addition & 1 deletion packages/tkg-clusterclass/hack/sync-cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -euo pipefail

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PROVIDERS_DIR=${SCRIPT_DIR}/../../../pkg/v1/providers
PROVIDERS_DIR=${SCRIPT_DIR}/../../../providers
PKGS_DIR=${SCRIPT_DIR}/../..
BINNAME="$( basename "${BASH_SOURCE[0]}" )"

Expand Down
Loading

0 comments on commit f173e65

Please sign in to comment.