Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
smyja committed Jun 26, 2023
1 parent 257b7a0 commit a8c7263
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 13 additions & 3 deletions plugins/render/api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
"gopkg.in/yaml.v2"
)

type Config struct {
Expand Down Expand Up @@ -39,15 +40,24 @@ func APIKey() schema.CredentialType {
},
},
},
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
DefaultProvisioner: provision.TempFile(renderConfig, provision.AtFixedPath(ConfigPath())),
Importer: importer.TryAll(
importer.TryEnvVarPair(defaultEnvVarMapping),
TryRenderConfigFile(),
),
}
}

var defaultEnvVarMapping = map[string]sdk.FieldName{
// var defaultEnvVarMapping = map[string]sdk.FieldName{
// }
func renderConfig(in sdk.ProvisionInput) ([]byte, error) {
config := Config{

}
contents, err := yaml.Marshal(&config)
if err != nil {
return nil, err
}
return []byte(contents), nil
}

func TryRenderConfigFile() sdk.Importer {
Expand Down
8 changes: 8 additions & 0 deletions plugins/render/render.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package render

import (
"os"

Check failure on line 4 in plugins/render/render.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofmt`-ed with `-s` (gofmt)
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/needsauth"
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
)
func ConfigPath() string {
configDir, err := os.UserConfigDir()
if err != nil {
return "~/.render/config.yaml"
}
return configDir + "/render/config.yaml"
}

func RenderCLI() schema.Executable {
return schema.Executable{
Expand Down

0 comments on commit a8c7263

Please sign in to comment.