Don't create NS when dry run strategy is specified.
Change-Id: Ib573d51128b0d0cfab0860e89c691b3b06f8c411
This commit is contained in:
parent
d97dccb4cf
commit
eea34fba72
@ -74,7 +74,7 @@ func NewApplier(eventCh chan events.Event, f cmdutil.Factory) *Applier {
|
|||||||
func (a *Applier) ApplyBundle(bundle document.Bundle, ao ApplyOptions) {
|
func (a *Applier) ApplyBundle(bundle document.Bundle, ao ApplyOptions) {
|
||||||
defer close(a.eventChannel)
|
defer close(a.eventChannel)
|
||||||
log.Debugf("Getting infos for bundle, inventory id is %s", ao.BundleName)
|
log.Debugf("Getting infos for bundle, inventory id is %s", ao.BundleName)
|
||||||
infos, err := a.getInfos(ao.BundleName, bundle)
|
infos, err := a.getInfos(ao.BundleName, bundle, ao.DryRunStrategy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(a.eventChannel, err)
|
handleError(a.eventChannel, err)
|
||||||
return
|
return
|
||||||
@ -90,7 +90,10 @@ func (a *Applier) ApplyBundle(bundle document.Bundle, ao ApplyOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Applier) getInfos(bundleName string, bundle document.Bundle) ([]*resource.Info, error) {
|
func (a *Applier) getInfos(
|
||||||
|
bundleName string,
|
||||||
|
bundle document.Bundle,
|
||||||
|
dryRun clicommon.DryRunStrategy) ([]*resource.Info, error) {
|
||||||
if bundle == nil {
|
if bundle == nil {
|
||||||
return nil, ErrNilBundle{}
|
return nil, ErrNilBundle{}
|
||||||
}
|
}
|
||||||
@ -117,7 +120,7 @@ func (a *Applier) getInfos(bundleName string, bundle document.Bundle) ([]*resour
|
|||||||
return nil, innerErr
|
return nil, innerErr
|
||||||
}
|
}
|
||||||
log.Debugf("Making sure that inventory object namespace %s exists", invDoc.GetNamespace())
|
log.Debugf("Making sure that inventory object namespace %s exists", invDoc.GetNamespace())
|
||||||
innerErr = a.ensureNamespaceExists(invDoc.GetNamespace())
|
innerErr = a.ensureNamespaceExists(invDoc.GetNamespace(), dryRun)
|
||||||
if innerErr != nil {
|
if innerErr != nil {
|
||||||
return nil, innerErr
|
return nil, innerErr
|
||||||
}
|
}
|
||||||
@ -130,7 +133,11 @@ func (a *Applier) getInfos(bundleName string, bundle document.Bundle) ([]*resour
|
|||||||
return a.ManifestReaderFactory(false, bundle, a.Factory).Read()
|
return a.ManifestReaderFactory(false, bundle, a.Factory).Read()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Applier) ensureNamespaceExists(name string) error {
|
func (a *Applier) ensureNamespaceExists(name string, dryRun clicommon.DryRunStrategy) error {
|
||||||
|
if dryRun != clicommon.DryRunNone {
|
||||||
|
log.Printf("Dryrun strategy is specified, otherwise Namespace '%s' would have been created", name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
clientSet, err := a.Factory.KubernetesClientSet()
|
clientSet, err := a.Factory.KubernetesClientSet()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user