Skip to content

Commit

Permalink
feat(pulumi): add pulumi azure integration
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Jan 17, 2024
1 parent a70d6c0 commit 8672884
Show file tree
Hide file tree
Showing 8 changed files with 692 additions and 23 deletions.
1 change: 1 addition & 0 deletions azure/az/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ az:
prod:
name: aks-my-prod
```
### Ownbrew
To install binary locally, add:
Expand Down
8 changes: 8 additions & 0 deletions azure/az/az.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@ func New(l log.Logger, cache cache.Cache, opts ...Option) (*AZ, error) {

return inst, nil
}

// ------------------------------------------------------------------------------------------------
// ~ Getter
// ------------------------------------------------------------------------------------------------

func (a *AZ) Config() Config {
return a.cfg
}
47 changes: 24 additions & 23 deletions onepassword/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,33 @@ Available commands:
package plugin

type Plugin struct {
l log.Logger
c cache.Cache
commands command.Commands
l log.Logger
oo *onepassword.OnePassword
cacche cache.Cache
commands command.Commands
}

func New(l log.Logger) (plugin.Plugin, error) {
inst := &Plugin{
l: l,
c: cache.MemoryCache{},
commands: command.Commands{},
}

// ...

// 1Password
if onePassword, err := onepassword.New(l, inst.c)); err != nil {
return nil, err
} else if cmd, err := onepassword.NewCommand(l, onePassword); err != nil {
return nil, err
} else {
inst.commands.Add(cmd)
}

// ...

return inst, nil
inst := &Plugin{
l: l,
cache: cache.MemoryCache{},
commands: command.Commands{},
}

// ...

inst.op, err := onepassword.New(l, inst.cache));
if err != nil {
return nil, errors.Wrap(err, "failed to create onepassword")
}

// ...

inst.commands.MustAdd(onepassword.NewCommand(l, onePassword))

// ...

return inst, nil
}
```

Expand Down
69 changes: 69 additions & 0 deletions pulumi/pulumi/azure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# POSH pulumi (azure) provider

## Usage

```go
package plugin

type Plugin struct {
l log.Logger
az *az.AZ
cache cache.Cache
kubectl *kubectl.Kubectl
commands command.Commands
}

func New(l log.Logger) (plugin.Plugin, error) {
inst := &Plugin{
l: l,
cache: cache.MemoryCache{},
commands: command.Commands{},
}

// ...

inst.op, err := onepassword.New(l, inst.cache));
if err != nil {
return nil, errors.Wrap(err, "failed to create onepassword")
}

inst.kubectl, err = kubectl.New(l, inst.cache)
if err != nil {
return nil, errors.Wrap(err, "failed to create kubectl")
}

inst.az, err = az.New(l, inst.cache)
if err != nil {
return nil, errors.Wrap(err, "failed to create az")
}

// ...

inst.commands.MustAdd(pulumi.NewCommand(l, inst.op, inst.az, inst.cache))

// ...

return inst, nil
}
```

### Config

```yaml
## az
pulumi:
path: .posh/pulumi
configPath: .posh/config/pulumi
passphrase:
account: xxxx
vault: xxxx
itemId: xxxx
field: password
backends:
prod:
location: Germany West Central
container: pulumi-state
subscription: xxx
resourceGroup: rg-my-name
storageAccount: sa-my-name
```
9 changes: 9 additions & 0 deletions pulumi/pulumi/azure/backend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package pulumi

type Backend struct {
Location string `json:"location" yaml:"location"`
Container string `json:"container" yaml:"container"`
Subscription string `json:"subscription" yaml:"subscription"`
ResourceGroup string `json:"resourceGroup" yaml:"resourceGroup"`
StorageAccount string `json:"storageAccount" yaml:"storageAccount"`
}
Loading

0 comments on commit 8672884

Please sign in to comment.