Skip to content

Commit

Permalink
Adding ability to have the executor not create a namespace. (#99)
Browse files Browse the repository at this point in the history
* Adding ability to have the executor not create a namespace.
* Adding Executor configuration struct.
* Changing the signature of new executor
* Changing name of field based on PR feedback
  • Loading branch information
Shawn Hurley authored and jmrodri committed Jun 7, 2018
1 parent 582cf05 commit d86f8bb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
4 changes: 4 additions & 0 deletions bundle/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (e *executor) Bind(
e.actionStarted()
// Create namespace name that will be used to generate a name.
ns := fmt.Sprintf("%s-%.4s-", instance.Spec.FQName, bindAction)
// Determine if we should be using the context namespace from the executor config.
if e.skipCreateNS {
ns = instance.Context.Namespace
}
// Create the podname
pn := fmt.Sprintf("bundle-%s", uuid.New())
targets := []string{instance.Context.Namespace}
Expand Down
4 changes: 4 additions & 0 deletions bundle/deprovision.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (e *executor) Deprovision(instance *ServiceInstance) <-chan StatusMessage {
}
// Create namespace name that will be used to generate a name.
ns := fmt.Sprintf("%s-%.4s-", instance.Spec.FQName, deprovisionAction)
// Determine if we should be using the context namespace from the executor config.
if e.skipCreateNS {
ns = instance.Context.Namespace
}
// Create the podname
pn := fmt.Sprintf("bundle-%s", uuid.New())
targets := []string{instance.Context.Namespace}
Expand Down
21 changes: 14 additions & 7 deletions bundle/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,24 @@ type executor struct {
statusChan chan StatusMessage
mutex sync.Mutex
stateManager runtime.StateManager
skipCreateNS bool
}

// ExecutorConfig - configuration for the executor.
type ExecutorConfig struct {
// This will tell the executor to use the context namespace as the
// namespace for the bundle to be created in.
SkipCreateNS bool
}

// NewExecutor - Creates a new Executor for running an APB.
func NewExecutor() Executor {
exec := &executor{
statusChan: make(chan StatusMessage),
lastStatus: StatusMessage{State: StateNotYetStarted},
func NewExecutor(config ExecutorConfig) Executor {
return &executor{
statusChan: make(chan StatusMessage),
lastStatus: StatusMessage{State: StateNotYetStarted},
skipCreateNS: config.SkipCreateNS,
stateManager: runtime.Provider,
}

exec.stateManager = runtime.Provider
return exec
}

// PodName - Returns the name of the pod running the APB
Expand Down
5 changes: 5 additions & 0 deletions bundle/provision_or_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func (e *executor) provisionOrUpdate(method executionMethod, instance *ServiceIn

// Create namespace name that will be used to generate a name.
ns := fmt.Sprintf("%s-%.4s-", instance.Spec.FQName, method)

// Determine if we should be using the context namespace from the executor config.
if e.skipCreateNS {
ns = instance.Context.Namespace
}
// Create the podname
pn := fmt.Sprintf("bundle-%s", uuid.New())
targets := []string{instance.Context.Namespace}
Expand Down
4 changes: 4 additions & 0 deletions bundle/unbind.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (e *executor) Unbind(
e.actionStarted()
// Create namespace name that will be used to generate a name.
ns := fmt.Sprintf("%s-%.4s-", instance.Spec.FQName, unbindAction)
// Determine if we should be using the context namespace from the executor config.
if e.skipCreateNS {
ns = instance.Context.Namespace
}
// Create the podname
pn := fmt.Sprintf("bundle-%s", uuid.New())
targets := []string{instance.Context.Namespace}
Expand Down

0 comments on commit d86f8bb

Please sign in to comment.