mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #82414 from SataQiu/kubeadm-20190906
kubeadm: code clean up about kustomize
This commit is contained in:
commit
fa3dfa82b0
@ -178,11 +178,8 @@ func NewFakeStaticPodPathManager(moveFileFunc func(string, string) error) (Stati
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
kustomizeDir := ""
|
|
||||||
|
|
||||||
return &fakeStaticPodPathManager{
|
return &fakeStaticPodPathManager{
|
||||||
kubernetesDir: kubernetesDir,
|
kubernetesDir: kubernetesDir,
|
||||||
kustomizeDir: kustomizeDir,
|
|
||||||
realManifestDir: realManifestDir,
|
realManifestDir: realManifestDir,
|
||||||
tempManifestDir: upgradedManifestDir,
|
tempManifestDir: upgradedManifestDir,
|
||||||
backupManifestDir: backupManifestDir,
|
backupManifestDir: backupManifestDir,
|
||||||
|
@ -184,11 +184,12 @@ func (km *Manager) Kustomize(data []byte) ([]byte, error) {
|
|||||||
json6902 := km.json6902Patches.filterByResource(resource)
|
json6902 := km.json6902Patches.filterByResource(resource)
|
||||||
|
|
||||||
// if there are no patches, for the target resources, exit
|
// if there are no patches, for the target resources, exit
|
||||||
if len(strategicMerge)+len(json6902) == 0 {
|
patchesCnt := len(strategicMerge) + len(json6902)
|
||||||
|
if patchesCnt == 0 {
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[kustomize] Applying %d patches to %s Resource=%s/%s\n", len(strategicMerge)+len(json6902), resource.GroupVersionKind(), resource.GetNamespace(), resource.GetName())
|
fmt.Printf("[kustomize] Applying %d patches to %s Resource=%s/%s\n", patchesCnt, resource.GroupVersionKind(), resource.GetNamespace(), resource.GetName())
|
||||||
|
|
||||||
// create an in memory fs to use for the kustomization
|
// create an in memory fs to use for the kustomization
|
||||||
memFS := fs.MakeFakeFS()
|
memFS := fs.MakeFakeFS()
|
||||||
@ -207,7 +208,7 @@ func (km *Manager) Kustomize(data []byte) ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
name := "resource.yaml"
|
name := "resource.yaml"
|
||||||
_ = memFS.WriteFile(filepath.Join(fakeDir, name), b)
|
memFS.WriteFile(filepath.Join(fakeDir, name), b)
|
||||||
|
|
||||||
km.kustomizationFile.Resources = []string{name}
|
km.kustomizationFile.Resources = []string{name}
|
||||||
|
|
||||||
@ -219,7 +220,7 @@ func (km *Manager) Kustomize(data []byte) ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
name := fmt.Sprintf("patch-%d.yaml", i)
|
name := fmt.Sprintf("patch-%d.yaml", i)
|
||||||
_ = memFS.WriteFile(filepath.Join(fakeDir, name), b)
|
memFS.WriteFile(filepath.Join(fakeDir, name), b)
|
||||||
|
|
||||||
km.kustomizationFile.PatchesStrategicMerge = append(km.kustomizationFile.PatchesStrategicMerge, patch.StrategicMerge(name))
|
km.kustomizationFile.PatchesStrategicMerge = append(km.kustomizationFile.PatchesStrategicMerge, patch.StrategicMerge(name))
|
||||||
}
|
}
|
||||||
@ -228,7 +229,7 @@ func (km *Manager) Kustomize(data []byte) ([]byte, error) {
|
|||||||
km.kustomizationFile.PatchesJson6902 = []patch.Json6902{}
|
km.kustomizationFile.PatchesJson6902 = []patch.Json6902{}
|
||||||
for i, p := range json6902 {
|
for i, p := range json6902 {
|
||||||
name := fmt.Sprintf("patchjson-%d.yaml", i)
|
name := fmt.Sprintf("patchjson-%d.yaml", i)
|
||||||
_ = memFS.WriteFile(filepath.Join(fakeDir, name), []byte(p.Patch))
|
memFS.WriteFile(filepath.Join(fakeDir, name), []byte(p.Patch))
|
||||||
|
|
||||||
km.kustomizationFile.PatchesJson6902 = append(km.kustomizationFile.PatchesJson6902, patch.Json6902{Target: p.Target, Path: name})
|
km.kustomizationFile.PatchesJson6902 = append(km.kustomizationFile.PatchesJson6902, patch.Json6902{Target: p.Target, Path: name})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user