-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pubsub krm #36
base: master
Are you sure you want to change the base?
pubsub krm #36
Changes from all commits
7d697f1
9a3e77e
b5bae0f
e0a7e76
9a41edd
e04fe0d
06dd449
a62ba6a
dd53bce
c3a36d0
5d20283
7d4d3a2
92171a2
2f4b591
89b2083
88dd6ac
fda9906
43b2acd
7a1a42d
28218ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ build: check-function-var | |
crd: check-function-var | ||
controller-gen crd paths=./pkg/workloads output:crd:dir=crd/workloads | ||
controller-gen crd paths=./pkg/pgbouncer output:crd:dir=crd/pgbouncer | ||
controller-gen crd paths=./pkg/pubsub output:crd:dir=crd/pubsub | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, this exists. we shouldn't have to hardcode, and we should be able to call this from within the dockerfile. If we have different implementations for the same thing, it is error prone and confusing. |
||
|
||
check-function-var: | ||
ifndef function | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's start figuring out how we can generate these. |
||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/bukukasio/krm-functions/pkg/pubsub" | ||
"github.com/spf13/cobra" | ||
"sigs.k8s.io/kustomize/kyaml/fn/framework" | ||
"sigs.k8s.io/kustomize/kyaml/fn/framework/command" | ||
) | ||
|
||
func cmd() *cobra.Command { | ||
p := &framework.VersionedAPIProcessor{FilterProvider: framework.GVKFilterMap{ | ||
"PubsubTopic": { | ||
"krm/v1": &pubsub.PubsubTopic{}, | ||
}, | ||
"PubsubSubscription": { | ||
"krm/v1": &pubsub.PubsubSubscription{}, | ||
}, | ||
}, | ||
} | ||
cmd := command.Build(p, command.StandaloneEnabled, false) | ||
cmd.Short = "" | ||
cmd.Long = "" | ||
return cmd | ||
} | ||
|
||
func main() { | ||
if err := cmd().Execute(); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
generators: | ||
- pubsub.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: krm/v1 | ||
kind: PubsubTopic | ||
metadata: | ||
name: tokko-api-pubsub | ||
annotations: | ||
config.kubernetes.io/function: | | ||
container: | ||
image: gcr.io/beecash-prod/infra/krm-functions/pubsub:latest | ||
spec: | ||
prefix: dev- | ||
env: dev | ||
topics: | ||
- name: tokko.team-management-sync | ||
config: | ||
messageRetentionDuration: 864000s | ||
- name: common.application-event | ||
--- | ||
|
||
apiVersion: krm/v1 | ||
kind: PubsubSubscription | ||
metadata: | ||
name: tokko-api-pubsub | ||
annotations: | ||
config.kubernetes.io/function: | | ||
container: | ||
image: gcr.io/beecash-prod/infra/krm-functions/pubsub:latest | ||
spec: | ||
prefix: dev- | ||
env: dev | ||
subscriptions: | ||
- name: tokko-subscription.catalog-integration-product-added | ||
topicRef: common.application-event | ||
config: | ||
filter: attributes.eventType = "PRODUCT_UPDATES" AND attributes.eventName = "PRODUCT_ADDED" | ||
- name: tokko-subscription.chat-inbox.team-management-sync | ||
topicRef: tokko.team-management-sync | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fnutils | ||
|
||
import "sigs.k8s.io/kustomize/kyaml/yaml" | ||
|
||
const ( | ||
CONFIG_CONNECTOR_ANNOTATION = "cnrm.cloud.google.com/project-id" | ||
) | ||
|
||
func AnnotateConfigConnectorObject(items []*yaml.RNode, project string) ([]*yaml.RNode, error) { | ||
for i := range items { | ||
if err := items[i].PipeE(yaml.SetAnnotation(CONFIG_CONNECTOR_ANNOTATION, project)); err != nil { | ||
return nil, err | ||
} | ||
} | ||
return items, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package utils | ||
|
||
const ( | ||
GCP_STAGING_PROJECT = "beecash-staging" | ||
GCP_PROD_PROJECT = "tokko-production" | ||
) | ||
|
||
func GetProject(env string) string{ | ||
if env == "prod" { | ||
return GCP_PROD_PROJECT | ||
} else { | ||
return GCP_STAGING_PROJECT | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't need to hardcode individual directories, make a
make
directive to do this, so that it can work both within and outside of the container.