mirror of https://github.com/dapr/cli.git
Fix CRD handling for upgrades and removals (#977)
* Fix CRD handling for upgrades and removals Signed-off-by: yaron2 <schneider.yaron@live.com> * nolint Signed-off-by: yaron2 <schneider.yaron@live.com> * linter, fix crd name Signed-off-by: yaron2 <schneider.yaron@live.com>
This commit is contained in:
parent
1c0c3def78
commit
436253778a
|
|
@ -14,10 +14,12 @@ limitations under the License.
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
helm "helm.sh/helm/v3/pkg/action"
|
||||
|
||||
"github.com/dapr/cli/pkg/print"
|
||||
"github.com/dapr/cli/utils"
|
||||
)
|
||||
|
||||
|
|
@ -39,7 +41,7 @@ func Uninstall(namespace string, uninstallAll bool, timeout uint) error {
|
|||
for _, crd := range crdsFullResources {
|
||||
_, err := utils.RunCmdAndWait("kubectl", "delete", "crd", crd)
|
||||
if err != nil {
|
||||
return err
|
||||
print.WarningStatusEvent(os.Stdout, "Failed to remove CRD %s: %s", crd, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ package kubernetes
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
|
@ -33,12 +34,14 @@ var crds = []string{
|
|||
"components",
|
||||
"configuration",
|
||||
"subscription",
|
||||
"resiliency",
|
||||
}
|
||||
|
||||
var crdsFullResources = []string{
|
||||
"components.dapr.io",
|
||||
"configurations.dapr.io",
|
||||
"subscriptions.dapr.io",
|
||||
"resiliencies.dapr.io",
|
||||
}
|
||||
|
||||
type UpgradeConfig struct {
|
||||
|
|
@ -134,9 +137,15 @@ func highAvailabilityEnabled(status []StatusOutput) bool {
|
|||
func applyCRDs(version string) error {
|
||||
for _, crd := range crds {
|
||||
url := fmt.Sprintf("https://raw.githubusercontent.com/dapr/dapr/%s/charts/dapr/crds/%s.yaml", version, crd)
|
||||
_, err := utils.RunCmdAndWait("kubectl", "apply", "-f", url)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
resp, _ := http.Get(url) // nolint:gosec
|
||||
if resp != nil && resp.StatusCode == 200 {
|
||||
defer resp.Body.Close()
|
||||
|
||||
_, err := utils.RunCmdAndWait("kubectl", "apply", "-f", url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue