setup tests
This commit is contained in:
parent
ba18683d9a
commit
cdffc565b0
|
@ -252,6 +252,7 @@ func (g *generator) getPkgContext(pkg, mod string) (*pkgContext, bool) {
|
|||
}
|
||||
|
||||
func (g *generator) getPulumiImport(pkg, vPath, mod string) string {
|
||||
// TODO: need to replace mod if we have an entry in the equivalent of go.ModuleToPackage
|
||||
imp := fmt.Sprintf("github.com/pulumi/pulumi-%s/sdk%s/go/%s/%s", pkg, vPath, pkg, mod)
|
||||
// namespaceless invokes "aws:index:..."
|
||||
if mod == "" {
|
||||
|
@ -595,6 +596,7 @@ func (g *generator) useLookupInvokeForm(token string) bool {
|
|||
// is aliased, returning that alias if available.
|
||||
func (g *generator) getModOrAlias(pkg, mod string) string {
|
||||
if mods, ok := g.contexts[pkg]; ok {
|
||||
// TODO: need the equivalent of mod go.ModuleToPackage here
|
||||
if ctx, ok := mods[mod]; ok {
|
||||
imp := fmt.Sprintf("%s/%s", ctx.importBasePath, ctx.modToPkg[mod])
|
||||
if alias, ok := ctx.pkgImportAliases[imp]; ok {
|
||||
|
|
|
@ -24,6 +24,9 @@ func TestGenProgram(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.Name() != "kubernetes-operator.pp" {
|
||||
continue
|
||||
}
|
||||
if filepath.Ext(f.Name()) != ".pp" {
|
||||
continue
|
||||
}
|
||||
|
|
214
pkg/codegen/internal/test/testdata/kubernetes-operator.pp
vendored
Normal file
214
pkg/codegen/internal/test/testdata/kubernetes-operator.pp
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
resource pulumi_kubernetes_operatorDeployment "kubernetes:apps/v1:Deployment" {
|
||||
apiVersion = "apps/v1"
|
||||
kind = "Deployment"
|
||||
metadata = {
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
spec = {
|
||||
# Currently only 1 replica supported, until leader election: https://github.com/pulumi/pulumi-kubernetes-operator/issues/33
|
||||
replicas = 1
|
||||
selector = {
|
||||
matchLabels = {
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
}
|
||||
template = {
|
||||
metadata = {
|
||||
labels = {
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
}
|
||||
spec = {
|
||||
serviceAccountName = "pulumi-kubernetes-operator"
|
||||
imagePullSecrets = [
|
||||
{
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
]
|
||||
containers = [
|
||||
{
|
||||
name = "pulumi-kubernetes-operator"
|
||||
image = "pulumi/pulumi-kubernetes-operator:v0.0.2"
|
||||
command = [
|
||||
"pulumi-kubernetes-operator"
|
||||
]
|
||||
args = [
|
||||
"--zap-level=debug"
|
||||
]
|
||||
imagePullPolicy = "Always"
|
||||
env = [
|
||||
{
|
||||
name = "WATCH_NAMESPACE"
|
||||
valueFrom = {
|
||||
fieldRef = {
|
||||
fieldPath = "metadata.namespace"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "POD_NAME"
|
||||
valueFrom = {
|
||||
fieldRef = {
|
||||
fieldPath = "metadata.name"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "OPERATOR_NAME"
|
||||
value = "pulumi-kubernetes-operator"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource pulumi_kubernetes_operatorRole "kubernetes:rbac.authorization.k8s.io/v1:Role" {
|
||||
apiVersion = "rbac.authorization.k8s.io/v1"
|
||||
kind = "Role"
|
||||
metadata = {
|
||||
# TODO creationTimestamp = null
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
rules = [
|
||||
{
|
||||
apiGroups = [
|
||||
""
|
||||
]
|
||||
resources = [
|
||||
"pods",
|
||||
"services",
|
||||
"services/finalizers",
|
||||
"endpoints",
|
||||
"persistentvolumeclaims",
|
||||
"events",
|
||||
"configmaps",
|
||||
"secrets"
|
||||
]
|
||||
verbs = [
|
||||
"create",
|
||||
"delete",
|
||||
"get",
|
||||
"list",
|
||||
"patch",
|
||||
"update",
|
||||
"watch"
|
||||
]
|
||||
},
|
||||
{
|
||||
apiGroups = [
|
||||
"apps"
|
||||
]
|
||||
resources = [
|
||||
"deployments",
|
||||
"daemonsets",
|
||||
"replicasets",
|
||||
"statefulsets"
|
||||
]
|
||||
verbs = [
|
||||
"create",
|
||||
"delete",
|
||||
"get",
|
||||
"list",
|
||||
"patch",
|
||||
"update",
|
||||
"watch"
|
||||
]
|
||||
},
|
||||
{
|
||||
apiGroups = [
|
||||
"monitoring.coreos.com"
|
||||
]
|
||||
resources = [
|
||||
"servicemonitors"
|
||||
]
|
||||
verbs = [
|
||||
"get",
|
||||
"create"
|
||||
]
|
||||
},
|
||||
{
|
||||
apiGroups = [
|
||||
"apps"
|
||||
]
|
||||
resourceNames = [
|
||||
"pulumi-kubernetes-operator"
|
||||
]
|
||||
resources = [
|
||||
"deployments/finalizers"
|
||||
]
|
||||
verbs = [
|
||||
"update"
|
||||
]
|
||||
},
|
||||
{
|
||||
apiGroups = [
|
||||
""
|
||||
]
|
||||
resources = [
|
||||
"pods"
|
||||
]
|
||||
verbs = [
|
||||
"get"
|
||||
]
|
||||
},
|
||||
{
|
||||
apiGroups = [
|
||||
"apps"
|
||||
]
|
||||
resources = [
|
||||
"replicasets",
|
||||
"deployments"
|
||||
]
|
||||
verbs = [
|
||||
"get"
|
||||
]
|
||||
},
|
||||
{
|
||||
apiGroups = [
|
||||
"pulumi.com"
|
||||
]
|
||||
resources = [
|
||||
"*"
|
||||
]
|
||||
verbs = [
|
||||
"create",
|
||||
"delete",
|
||||
"get",
|
||||
"list",
|
||||
"patch",
|
||||
"update",
|
||||
"watch"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
resource pulumi_kubernetes_operatorRoleBinding "kubernetes:rbac.authorization.k8s.io/v1:RoleBinding" {
|
||||
kind = "RoleBinding"
|
||||
apiVersion = "rbac.authorization.k8s.io/v1"
|
||||
metadata = {
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
subjects = [
|
||||
{
|
||||
kind = "ServiceAccount"
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
]
|
||||
roleRef = {
|
||||
kind = "Role"
|
||||
name = "pulumi-kubernetes-operator"
|
||||
apiGroup = "rbac.authorization.k8s.io"
|
||||
}
|
||||
}
|
||||
|
||||
resource pulumi_kubernetes_operatorServiceAccount "kubernetes:core/v1:ServiceAccount" {
|
||||
apiVersion = "v1"
|
||||
kind = "ServiceAccount"
|
||||
metadata = {
|
||||
name = "pulumi-kubernetes-operator"
|
||||
}
|
||||
}
|
0
pkg/codegen/internal/test/testdata/kubernetes-operator.pp.go
vendored
Normal file
0
pkg/codegen/internal/test/testdata/kubernetes-operator.pp.go
vendored
Normal file
Loading…
Reference in a new issue