mirror of
https://github.com/rancher/rke.git
synced 2025-08-12 04:03:01 +00:00
Make sure we properly separate included addon manifests
This commit is contained in:
parent
c9c64d67e9
commit
fcdeca19f0
@ -70,55 +70,44 @@ func (c *Cluster) deployAddonsInclude(ctx context.Context) error {
|
|||||||
log.Infof(ctx, "[addons] No included addon paths or urls..")
|
log.Infof(ctx, "[addons] No included addon paths or urls..")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, addon := range c.AddonsInclude {
|
for _, addon := range c.AddonsInclude {
|
||||||
if strings.HasPrefix(addon, "http") {
|
if strings.HasPrefix(addon, "http") {
|
||||||
addonYAML, err := getAddonFromURL(addon)
|
addonYAML, err := getAddonFromURL(addon)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof(ctx, "[addons] Adding addon from url %s", addon)
|
log.Infof(ctx, "[addons] Adding addon from url %s", addon)
|
||||||
logrus.Debugf("URL Yaml: %s", addonYAML)
|
logrus.Debugf("URL Yaml: %s", addonYAML)
|
||||||
|
|
||||||
if err := validateUserAddonYAML(addonYAML); err != nil {
|
if err := validateUserAddonYAML(addonYAML); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
manifests = append(manifests, addonYAML...)
|
manifests = append(manifests, addonYAML...)
|
||||||
|
|
||||||
} else if isFilePath(addon) {
|
} else if isFilePath(addon) {
|
||||||
addonYAML, err := ioutil.ReadFile(addon)
|
addonYAML, err := ioutil.ReadFile(addon)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof(ctx, "[addons] Adding addon from %s", addon)
|
log.Infof(ctx, "[addons] Adding addon from %s", addon)
|
||||||
logrus.Debugf("FilePath Yaml: %s", string(addonYAML))
|
logrus.Debugf("FilePath Yaml: %s", string(addonYAML))
|
||||||
|
|
||||||
|
// make sure we properly separated manifests
|
||||||
|
addonYAMLStr := string(addonYAML)
|
||||||
|
if !strings.HasPrefix(addonYAMLStr, "---") {
|
||||||
|
addonYAML = []byte(fmt.Sprintf("%s\n%s", "---", addonYAMLStr))
|
||||||
|
}
|
||||||
if err := validateUserAddonYAML(addonYAML); err != nil {
|
if err := validateUserAddonYAML(addonYAML); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
manifests = append(manifests, addonYAML...)
|
manifests = append(manifests, addonYAML...)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.Warnf(ctx, "[addons] Unable to determine if %s is a file path or url, skipping", addon)
|
log.Warnf(ctx, "[addons] Unable to determine if %s is a file path or url, skipping", addon)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof(ctx, "[addons] Deploying %s", UserAddonsIncludeResourceName)
|
log.Infof(ctx, "[addons] Deploying %s", UserAddonsIncludeResourceName)
|
||||||
|
|
||||||
logrus.Debugf("[addons] Compiled addons yaml: %s", string(manifests))
|
logrus.Debugf("[addons] Compiled addons yaml: %s", string(manifests))
|
||||||
|
|
||||||
if err := c.doAddonDeploy(ctx, string(manifests), UserAddonsIncludeResourceName); err != nil {
|
return c.doAddonDeploy(ctx, string(manifests), UserAddonsIncludeResourceName)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateUserAddonYAML(addon []byte) error {
|
func validateUserAddonYAML(addon []byte) error {
|
||||||
@ -134,7 +123,6 @@ func isFilePath(addonPath string) bool {
|
|||||||
if _, err := os.Stat(addonPath); os.IsNotExist(err) {
|
if _, err := os.Stat(addonPath); os.IsNotExist(err) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user