Skip to content

Instantly share code, notes, and snippets.

View gotwarlost's full-sized avatar

Krishnan Anantheswaran gotwarlost

View GitHub Profile
@gotwarlost
gotwarlost / all.txtar
Last active July 17, 2024 22:07
unit testing for cue crossplane functions
go install github.com/crossplane-contrib/function-cue/cmd/fn-cue-tools@v0.3.0
fn-cue-tools cue-test --test-dir ./tests/ ./implementation/
-- implementation/init.cue --
package implementation
#request: {...}
composite: #request.observed.composite.resource
compName: composite.metadata.name
@gotwarlost
gotwarlost / all.txtar
Created July 17, 2024 18:53
Tooling to convert composition implementation into a self-contained script embedded as text in the object
go install github.com/crossplane-contrib/function-cue/cmd/fn-cue-tools@v0.3.0
mkdir -p zz_generated/scripts
fn-cue-tools package-script ./implementation --pkg scripts --var replicatedmap >zz_generated/scripts/file-to-avoid.cue
cue eval ./definition --out yaml
-- cue.mod/module.cue --
module: "cue-functions.io/examples/simple"
language: version: "v0.9.0"
-- definition/composition.cue --
@gotwarlost
gotwarlost / all.txtar
Last active July 17, 2024 18:36
Tooling that converts an API type in cue to a crossplane Composite Resource definition (XRD)
go install github.com/crossplane-contrib/function-cue/cmd/fn-cue-tools@v0.3.0
mkdir -p zz_generated/schemas
fn-cue-tools openapi --pkg schemas ./api/ >zz_generated/schemas/generated-schema-to-avoid.cue
cue eval ./xrd --out yaml
-- api/api.cue --
package api
// A config map that is replicated to multiple namespaces
#ReplicatedMapV1alpha1: {
import React, { useState } from 'react';
import { View, TextInput, Button, Alert } from 'react-native';
import axios from 'axios';
import AsyncStorage from '@react-native-async-storage/async-storage';
const API_URL = 'http://your-api-url.com';
const LoginScreen = ({ navigation }) => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');

Works

$ cue def ./repro.cue | cue eval -H -
_request: [
            if _input.function != _|_ // explicit error (_|_ literal) in source
            {
        _input.function
    }, _input.test][0]
_input: {}

Keybase proof

I hereby claim:

  • I am gotwarlost on github.
  • I am gotwarlost (https://keybase.io/gotwarlost) on keybase.
  • I have a public key ASDTOp3wUGccqvyJG00asKwBbK8oYjIllJmWFvyYsipcawo

To claim this, I am signing this object:

@gotwarlost
gotwarlost / bash-loop.sh
Last active June 7, 2021 00:14
Repro of jsonnet-lint exponential(?) processing
#!/bin/bash
for i in {20..50}
do
echo ===
echo $i
echo ===
go run create-lint-problems.go $i
time jsonnet-lint caller.jsonnet
done
@gotwarlost
gotwarlost / main.go
Last active December 17, 2019 18:17
program that shows the new CA cert with the same key is not valid for old clients when the subject of the cert is differen
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
@gotwarlost
gotwarlost / go.mod
Created October 17, 2019 07:15
Pod events as seen by a watcher
module cd.splunkdev.com/kanantheswaran/podwatch
go 1.13
require (
github.com/gogo/protobuf v1.3.1 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/json-iterator/go v1.1.7 // indirect
@gotwarlost
gotwarlost / deploy.yaml
Created May 5, 2019 20:23
envoy sidecar errors when a service maps 2 service ports to the same container port
apiVersion: v1
kind: Namespace
metadata:
name: twosvcports
labels:
istio-injection: enabled
---
apiVersion: v1
kind: ServiceAccount
metadata: