[PULUMI] CA provider

This commit is contained in:
Kat Inskip 2023-03-09 15:43:39 -08:00
parent 64507a991c
commit b224bd4935
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
27 changed files with 2727 additions and 313 deletions

View file

@ -0,0 +1,84 @@
// Copyright 2016-2022, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"os"
command "github.com/kittywitch/provider-opensshcertificate/pkg/provider"
)
// copied from encoding/json for use with JSONMarshal above
func MarshalIndent(v any) ([]byte, error) {
// json.Marshal normally escapes HTML. This one doesn't
// https://stackoverflow.com/questions/28595664/how-to-stop-json-marshal-from-escaping-and
var buffer bytes.Buffer
encoder := json.NewEncoder(&buffer)
encoder.SetEscapeHTML(false)
encoder.SetIndent("", " ")
err := encoder.Encode(v)
if err != nil {
return nil, err
}
return buffer.Bytes(), nil
}
func main() {
flag.Usage = func() {
const usageFormat = "Usage: %s <schema-file>"
fmt.Fprintf(flag.CommandLine.Output(), usageFormat, os.Args[0])
flag.PrintDefaults()
}
var version string
flag.StringVar(&version, "version", "0.1.0", "the provider version to record in the generated code")
flag.Parse()
args := flag.Args()
if len(args) < 1 {
flag.Usage()
return
}
s, err := command.Schema(version)
if err != nil {
panic(err)
}
// sort keys
var arg map[string]any
err = json.Unmarshal([]byte(s), &arg)
if err != nil {
panic(err)
}
// remove version key
delete(arg, "version")
// use custom marshal indent to skip html escaping
out, err := MarshalIndent(arg)
if err != nil {
panic(err)
}
schemaPath := args[0]
err = os.WriteFile(schemaPath, out, 0600)
if err != nil {
panic(err)
}
}

View file

@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
meow "github.com/kittywitch/provider-opensshcertificate/pkg/provider"
p "github.com/pulumi/pulumi-go-provider"
)
func main() {
err := p.RunProvider("opensshcertificate", "0.1.0", meow.Provider())
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %s", err.Error())
os.Exit(1)
}
}

View file

@ -0,0 +1,88 @@
{
"config": {},
"description": "I hope the people who worked on pulumi stub their toe every day",
"displayName": "OpenSSH Cert",
"homepage": "https://kittywit.ch",
"keywords": [
"pulumi",
"openssh",
"category/utility",
"kind/native"
],
"language": {
"go": {
"generateResourceContainerTypes": true,
"importBasePath": "github.com/kittywitch/provider-opensshcertificate/sdk/go/provider"
}
},
"license": "WTFPL",
"logoUrl": "https://raw.githubusercontent.com/pulumi/pulumi-command/master/assets/logo.svg",
"name": "opensshcertificate",
"provider": {},
"publisher": "Pulumi",
"repository": "https://github.com/kittywitch/kittywitch",
"resources": {
"opensshcertificate:provider:OpenSSHCertificate": {
"inputProperties": {
"algorithm": {
"type": "string"
},
"cakey": {
"type": "string"
},
"duration": {
"type": "string"
},
"hostname": {
"type": "string"
},
"kind": {
"type": "string"
},
"userkey": {
"type": "string"
}
},
"properties": {
"algorithm": {
"type": "string"
},
"cakey": {
"type": "string"
},
"content": {
"type": "string"
},
"duration": {
"type": "string"
},
"hostname": {
"type": "string"
},
"kind": {
"type": "string"
},
"userkey": {
"type": "string"
}
},
"required": [
"algorithm",
"kind",
"hostname",
"cakey",
"userkey",
"duration",
"content"
],
"requiredInputs": [
"algorithm",
"kind",
"hostname",
"cakey",
"userkey",
"duration"
]
}
}
}