mirror of
https://github.com/helm/helm.git
synced 2026-03-22 10:30:02 -04:00
Merge 15886c3aa7 into 42f78ba60e
This commit is contained in:
commit
5520a922a8
2 changed files with 52 additions and 3 deletions
|
|
@ -442,11 +442,22 @@ func (i *Install) RunWithContext(ctx context.Context, ch ci.Charter, vals map[st
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := i.cfg.KubeClient.Create(
|
||||
resourceList,
|
||||
kube.ClientCreateOptionServerSideApply(i.ServerSideApply, false)); err != nil && !apierrors.IsAlreadyExists(err) {
|
||||
namespaceExist := false
|
||||
_, err = i.cfg.KubeClient.Get(resourceList, false)
|
||||
if err == nil {
|
||||
namespaceExist = true
|
||||
} else if !apierrors.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !namespaceExist {
|
||||
if _, err := i.cfg.KubeClient.Create(
|
||||
resourceList,
|
||||
kube.ClientCreateOptionServerSideApply(i.ServerSideApply, false)); err != nil && !apierrors.IsAlreadyExists(err) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If Replace is true, we need to supersede the last release.
|
||||
|
|
|
|||
|
|
@ -1297,3 +1297,41 @@ func TestInstallRelease_WaitOptionsPassedDownstream(t *testing.T) {
|
|||
// Verify that WaitOptions were passed to GetWaiter
|
||||
is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter")
|
||||
}
|
||||
|
||||
func TestInstall_CreateNamespaceAlreadyExists(t *testing.T) {
|
||||
is := assert.New(t)
|
||||
|
||||
// Namespace already exists in cluster
|
||||
config := actionConfigFixtureWithDummyResources(t, createDummyResourceList(true))
|
||||
|
||||
instAction := installActionWithConfig(config)
|
||||
instAction.CreateNamespace = true
|
||||
instAction.Namespace = "spaced"
|
||||
|
||||
resi, err := instAction.Run(buildChart(), nil)
|
||||
is.NoError(err)
|
||||
|
||||
res, err := releaserToV1Release(resi)
|
||||
is.NoError(err)
|
||||
is.Equal("spaced", res.Namespace)
|
||||
is.Equal("Install complete", res.Info.Description)
|
||||
}
|
||||
|
||||
func TestInstall_CreateNamespaceNotExists(t *testing.T) {
|
||||
is := assert.New(t)
|
||||
|
||||
// Empty cluster state, thats mean namespace not present
|
||||
config := actionConfigFixture(t)
|
||||
|
||||
instAction := installActionWithConfig(config)
|
||||
instAction.CreateNamespace = true
|
||||
instAction.Namespace = "spaced"
|
||||
|
||||
resi, err := instAction.Run(buildChart(), nil)
|
||||
is.NoError(err)
|
||||
|
||||
res, err := releaserToV1Release(resi)
|
||||
is.NoError(err)
|
||||
is.Equal("spaced", res.Namespace)
|
||||
is.Equal("Install complete", res.Info.Description)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue