-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from kndpio/93-configuration-and-registry-dele…
…te-commands-do-not-update-engine-helm-release updated registry and configs delete to be removed from engine
- Loading branch information
Showing
5 changed files
with
98 additions
and
24 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
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,51 @@ | ||
package configuration | ||
|
||
import ( | ||
"github.com/charmbracelet/log" | ||
|
||
"k8s.io/client-go/rest" | ||
|
||
"github.com/kndpio/kndp/internal/engine" | ||
) | ||
|
||
func DeleteConfiguration(url string, config *rest.Config, logger *log.Logger) error { | ||
|
||
installer, err := engine.GetEngine(config) | ||
if err != nil { | ||
logger.Errorf(" %v\n", err) | ||
} | ||
|
||
release, _ := installer.GetRelease() | ||
|
||
if release.Config == nil || release.Config["configuration"] == nil { | ||
logger.Warn("Not found any applied configuration.") | ||
} else { | ||
configs := release.Config["configuration"].(map[string]interface{}) | ||
oldPackages := configs["packages"].([]interface{}) | ||
|
||
newPackages := []interface{}{} | ||
for _, config := range oldPackages { | ||
if config != url { | ||
newPackages = append( | ||
newPackages, | ||
config, | ||
) | ||
} | ||
} | ||
release.Config["configuration"] = map[string]interface{}{ | ||
"packages": newPackages, | ||
} | ||
if len(oldPackages) == len(newPackages) { | ||
logger.Warn("Configuration URL not found applied configurations.") | ||
return nil | ||
} | ||
} | ||
|
||
err = installer.Upgrade("", release.Config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
logger.Info("Configuration removed successfully.") | ||
return nil | ||
} |
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