Skip to content

Commit

Permalink
feat(provider): Init
Browse files Browse the repository at this point in the history
Adds Init function to allow the provider doing initial setup related things
  • Loading branch information
sh0rez committed Jul 30, 2019
1 parent 6a3fdd8 commit 3155414
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/tk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func main() {
if err != nil {
log.Fatalln("Setting up provider:", err)
}
if err := prov.Init(); err != nil {
log.Fatalln("initializing provider:", err)
}

rootCmd.AddCommand(providerCmd())

Expand Down
4 changes: 4 additions & 0 deletions pkg/provider/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ type Kubernetes struct {

var client = Kubectl{}

// Init makes the provider ready to be used
func (k *Kubernetes) Init() error {
}

// Reconcile receives the raw evaluated jsonnet as a marshaled json dict and
// shall return it reconciled as a state object of the target system
func (k *Kubernetes) Reconcile(raw map[string]interface{}) (state interface{}, err error) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import "github.com/spf13/cobra"

// Provider describes methods for functionality more advanced than evaluating jsonnet
type Provider interface {
// Init may be used to do some setup related tasks.
// Called before any other requests to the provider are made
Init() error

// Reconcile receives the raw evaluated jsonnet as a marshaled json dict and
// shall return it reconciled as a state object of the target system
// `state` must be one of {`map[string]interface`, `[]map[string]interface`}
Expand Down

0 comments on commit 3155414

Please sign in to comment.