Skip to content

Commit

Permalink
release: cli (#367)
Browse files Browse the repository at this point in the history
### Summary

cli: v0.5.0
  • Loading branch information
fracek authored May 23, 2024
2 parents dcb512c + c9eb5ce commit a101221
Show file tree
Hide file tree
Showing 34 changed files with 1,847 additions and 472 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions charts/operator/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: operator
description: The Apibara operator for Kubernetes
type: application
version: 0.1.0
appVersion: "0.2.2"
home: https://www.apibara.com
sources:
- https://github.com/apibara/dna/tree/main/charts/operator
41 changes: 41 additions & 0 deletions charts/operator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Apibara Operator

The Apibara Operator is a Kubernetes operator to deploy indexers.

## Usage

The chart is published to an OCI Helm repository.

Inspect the chart with the `helm show` command:

```
$ helm show readme oci://quay.io/apibara-charts/operator
---
Pulled: quay.io/apibara-charts/operator:0.1.0
Digest: sha256:a248767bcfbb2973b616052dcc38b791f1b6ff13f2db40b61951183f85c0729e
# Apibara Operator
The Apibara Operator is a Kubernetes operator to deploy indexers.
```

Install the chart with `helm install`.

```
$ helm install capy oci://quay.io/apibara-charts/operator
---
Pulled: quay.io/apibara-charts/operator:0.1.0
Digest: sha256:a248767bcfbb2973b616052dcc38b791f1b6ff13f2db40b61951183f85c0729e
NAME: capy
LAST DEPLOYED: Fri May 10 21:00:30 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
capy-operator has been installed. Check its status by running:
kubectl --namespace default get pods
```

Customize the release using `values.yaml` as usual.
1,373 changes: 1,373 additions & 0 deletions charts/operator/crds/custom-resource-definitions.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions charts/operator/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ template "operator.fullname" . }} has been installed. Check its status by running:

kubectl --namespace {{ template "operator.namespace" . }} get pods
69 changes: 69 additions & 0 deletions charts/operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Namespace where to install the operator.
*/}}
{{- define "operator.namespace" -}}
{{- default .Release.Namespace .Values.namespace -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "operator.labels" -}}
helm.sh/chart: {{ include "operator.chart" . }}
{{ include "operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "operator.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
45 changes: 45 additions & 0 deletions charts/operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "operator.fullname" . }}
namespace: {{ include "operator.namespace" . }}
labels:
{{- include "operator.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "operator.selectorLabels" . | nindent 6 }}
strategy:
type: Recreate
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "operator.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
automountServiceAccountToken: true
serviceAccountName: {{ include "operator.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if gt (len .Values.customArgs) 0 }}
args:
{{- toYaml .Values.customArgs | nindent 12 }}
{{- end }}
env:
- name: "RUST_LOG"
value: "INFO"
{{- if .Values.extraEnv }}
{{- toYaml .Values.extraEnv | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
59 changes: 59 additions & 0 deletions charts/operator/templates/rbac-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "operator.fullname" . }}-role
rules:
- apiGroups:
- ""
resources:
- events
verbs:
- "*"
- apiGroups:
- ""
resources:
- endpoints
- configmaps
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- pods
- pods/status
- pods/finalizers
verbs:
- "*"
- apiGroups:
- ""
resources:
- services
- services/status
- services/finalizers
verbs:
- "*"
- apiGroups:
- "apibara.com"
resources:
- indexers
- indexers/status
- indexers/finalizers
verbs:
- "*"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "operator.fullname" . }}-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "operator.fullname" . }}-role
subjects:
- kind: ServiceAccount
name: {{ template "operator.serviceAccountName" . }}
namespace: {{ template "operator.namespace" . }}
13 changes: 13 additions & 0 deletions charts/operator/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "operator.serviceAccountName" . }}
namespace: {{ include "operator.namespace" . }}
labels:
{{- include "operator.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/operator/templates/tests/indexers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.test.enabled }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "operator.fullname" . }}-test-api-key
namespace: {{ include "operator.namespace" . }}
stringData:
production: {{ .Values.test.apiKey }}
---
apiVersion: apibara.com/v1alpha2
kind: Indexer
metadata:
name: {{ include "operator.fullname" . }}-test-indexer
namespace: {{ include "operator.namespace" . }}
spec:
source:
gitHub:
repo: dna
owner: apibara
revision: main
subpath: examples/console
sink:
script: starknet_to_console.js
type: console
env:
- name: AUTH_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "operator.fullname" . }}-test-api-key
key: production
{{- end }}
50 changes: 50 additions & 0 deletions charts/operator/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
image:
repository: quay.io/apibara/operator
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

# namespace: apibara-system

replicaCount: 1

# Custom args for the operator, e.g. `["--namespace", "my-namespace"]`
customArgs:
- start

# Additional environment variables to set
extraEnv: []

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: "apibara-operator-manager"

podAnnotations: {}

resources:
{}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

# Values used for testing
test:
enabled: false
# DNA auth token
apiKey: ""
10 changes: 10 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Common Changelog](https://common-changelog.org/), and
this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.0] - 2024-05-23

_Improve `apibara test` command when working with floating point numbers._

### Added

- Add a `testOptions` section to `apibara test` snapshots.
- Add the `testOptions.floatingPointDecimals` option to control up to how many
decimal places to compare floating point numbers in snapshots.

## [0.4.2] - 2024-01-19

_Allow network access._
Expand Down
Loading

0 comments on commit a101221

Please sign in to comment.