Skip to content

Commit 72ad1ed

Browse files
Merge pull request #3149 from sudomakeinstall2/add-extra-manifest-to-converter
OCPBUGS-65595: ztp: siteconfig-converter: Generate extra-manifest without using siteconfig-generator binary
2 parents ec14dcc + 2b4a145 commit 72ad1ed

File tree

6 files changed

+1016
-76
lines changed

6 files changed

+1016
-76
lines changed

ztp/tools/siteconfig-converter/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Variables
44
BINARY_NAME = siteconfig-converter
5-
GO_FILES = main.go convert.go
6-
TEST_FILES = convert_test.go
5+
GO_FILES = main.go convert.go extraManifests.go
6+
TEST_FILES = convert_test.go extraManifests_test.go
77
GOOS ?= $(shell go env GOOS)
88
GOARCH ?= $(shell go env GOARCH)
99
EXAMPLE_FILE = samples/example-sno1.yaml

ztp/tools/siteconfig-converter/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ The manifests will be generated in the `./output` directory
1515

1616
```
1717
podman run -d --rm --name ztp ${IMAGE} tail -f /dev/null
18-
podman cp ztp:/usr/bin/siteconfig-generator ./
1918
podman cp ztp:/usr/bin/siteconfig-converter ./
2019
podman stop ztp
2120
sudo cp siteconfig-converter siteconfig-generator /usr/local/bin
@@ -25,7 +24,7 @@ tree output-cluster-instance
2524
output-cluster-instance
2625
├── cnfdf26.yaml
2726
├── extra-manifests
28-
│   └── cnfdf26_machineconfig_98-var-lib-containers-partitioned.yaml
27+
│   └── 98-var-lib-containers-partitioned.yaml
2928
└── kustomization-configMapGenerator-snippet.yaml
3029
```
3130

@@ -233,7 +232,7 @@ The `siteconfig-converter` tool automatically generates ConfigMap kustomization
233232

234233
This process:
235234
1. Creates the `extra-manifests` directory in the output directory
236-
2. Extracts all the extra manifests using the `siteconfig-generator` binary into this directory
235+
2. Extracts all the extra manifests into this directory
237236
3. Creates a `kustomization-configMapGenerator-snippet.yaml` file which includes a kustomize `configMapGenerator` that will sync the extra manifests ConfigMap on the hub cluster.
238237

239238
The extra manifest ConfigMap is automatically added to the `extraManifestRefs` field of the `ClusterInstance`.
@@ -257,16 +256,13 @@ $ tree output
257256
output
258257
├── cnfdf28.yaml
259258
├── extra-manifests
260-
│ ├── cnfdf28_machineconfig_98-var-lib-containers-partitioned.yaml
261-
│ └── cnfdf28_machineconfig_99-set-core-user-password.yaml
259+
│ ├── 98-var-lib-containers-partitioned.yaml
260+
│ └── set-core-user-password.yaml
262261
└── kustomization-configMapGenerator-snippet.yaml
263262
```
264263

265264
You can merge the generated kustomization file with your original one to generate the ConfigMap and the `ClusterInstance`.
266265

267-
**Requirements:**
268-
- The `siteconfig-generator` binary must be available in your system PATH (available in the `ztp-site-generator` container)
269-
270266
For the complete directory structure and detailed workflow, refer to the [SiteConfig documentation](https://github.com/stolostron/siteconfig/blob/main/docs/argocd.md#generate-extra-manifests-configmap-using-kustomize).
271267

272268
### Suppressed Manifests

ztp/tools/siteconfig-converter/convert.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -453,22 +453,14 @@ func convertToClusterInstance(siteConfig *SiteConfig, outputDir string, clusterT
453453
"Use a ConfigMap which contains the already merged MachineConfigs and reference it through extraManifestsRefs instead.\n")
454454
}
455455

456-
// Check for extraManifestOnly
457456
if cluster.ExtraManifestOnly {
458-
warningsCollector.AddWarning("WARNING: extraManifestOnly field is not supported in ClusterInstance and will be ignored. \n")
457+
warningsCollector.AddWarning("WARNING: extraManifestOnly field is not part of ClusterInstance spec. " +
458+
"Extra manifests will be generated from this SiteConfig and included in the extraManifestsRefs ConfigMap, but the full ClusterInstance CR set will also be generated.\n")
459459
}
460460

461-
// Check for extraManifests
462-
if (cluster.ExtraManifests.SearchPaths != nil && len(*cluster.ExtraManifests.SearchPaths) > 0) ||
463-
(cluster.ExtraManifests.Filter != nil && len(cluster.ExtraManifests.Filter.Exclude) > 0) {
464-
warningsCollector.AddWarning("WARNING: extraManifests field is not supported in ClusterInstance and will be ignored. " +
465-
"Create one or more configmaps with the exact desired set of CRs for the cluster and include them in the extraManifestsRefs.\n")
466-
}
467-
468-
// Check for extraManifestPath
469461
if cluster.ExtraManifestPath != "" {
470462
warningsCollector.AddWarning(fmt.Sprintf("WARNING: extraManifestPath field '%s' is not supported in ClusterInstance and will be ignored. "+
471-
"Create one or more configmaps with the exact desired set of CRs for the cluster and include them in the extraManifestsRefs.\n",
463+
"Use extraManifests field instead\n",
472464
cluster.ExtraManifestPath))
473465
}
474466

0 commit comments

Comments
 (0)