Skip to content
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

fix: refactor compositions into configurations and docs #5

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,31 @@ jobs:
version: ${{ github.event.inputs.version }}
command: -h

- name: move crossplane cli
run: "mkdir -p $TARGET_PATH && mv ./crossplane $TARGET_PATH"
env:
TARGET_PATH: "${{ github.workspace }}/bin"

- name: setup jsonnet-fmt
run: |
go install "github.com/google/go-jsonnet/cmd/[email protected]"
echo "$HOME/go/bin" >> "$GITHUB_PATH"

- name: setup jrsonnet
uses: Duologic/tanka-exporter-workflow/.github/actions/jrsonnet-install@main

- name: Build xpkg
run: make build
run: "make -B build"
shell: bash
env:
CROSSPLANE: './crossplane'
CROSSPLANE: '${{ github.workspace }}/bin/crossplane'

- name: Check if file changed
id: changed
uses: tj-actions/verify-changed-files@v20
with:
files: |
!crossplane
!bin

- name: No files changed
if: "${{ steps.changed.outputs.files_changed == 'true' }}"
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
LIBRARY_VERSION:=0.0.5
LIBRARY_VERSION:=0.0.6
PROVIDER_VERSION:=0.21.0
JSONNET_BIN:=jrsonnet
CROSSPLANE?=crank
REGISTRY?=ghcr.io
SHELL:=/bin/bash

VENDOR_DEPTHS:=$(shell find generator/vendor -type f)

grafanaplane: grafanaplane/raw.libsonnet grafanaplane/compositions.libsonnet
grafanaplane: grafanaplane/raw.libsonnet grafanaplane/configurations.libsonnet

generator/crds.yaml:
cd generator && \
Expand All @@ -21,12 +22,12 @@ grafanaplane/raw.libsonnet: generator/main.libsonnet generator/namespaced.libson
generator/main.libsonnet) && \
xargs -n1 jsonnetfmt -i <<< "$${FILES}"

grafanaplane/compositions.libsonnet: generator/compositions.libsonnet generator/namespaced.libsonnet generator/crds.yaml $(VENDOR_DEPTHS)
grafanaplane/configurations.libsonnet: generator/configurations.libsonnet generator/namespaced.libsonnet generator/crds.yaml $(VENDOR_DEPTHS)
$(JSONNET_BIN) \
-J generator/vendor \
-A 'configurationVersion=$(LIBRARY_VERSION)-$(PROVIDER_VERSION)' \
generator/compositions.libsonnet | \
jsonnetfmt - > grafanaplane/compositions.libsonnet
generator/configurations.libsonnet | \
jsonnetfmt - > grafanaplane/configurations.libsonnet

packages: generator/packages.libsonnet generator/namespaced.libsonnet generator/crds.yaml $(VENDOR_DEPTHS)
rm -rf packages && \
Expand All @@ -50,7 +51,7 @@ tag:
git tag $(LIBRARY_VERSION)-$(PROVIDER_VERSION)

.PHONY: build
build: grafanaplane/raw.libsonnet grafanaplane/compositions.libsonnet packages
build: grafanaplane/raw.libsonnet grafanaplane/configurations.libsonnet packages

.PHONY: push
push: push_packages
14 changes: 10 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
# grafanaplane

Jsonnet library providing a namespaced set of compositions/XRDs for the Grafana Crossplane provider. The compositions, XRDs and the library for creating the XRD objects is generated.
This repository provides a set of Crossplane Configurations packages and and accompanying Jsonnet library.

The Configuration packages provide a set of (namespaced) composition/XRD pairs that map directly to their non-namespaced Managed resources equivalents.

The library consists of two parts, the manually written functions to get started quicly and the full library in `raw/`. They can be used in combination with each other.

Most of this library is generated: the Compositions/XRDs packages, Configurations and the library in `raw/`.

## Install

```
jb install github.com/Duologic/grafana-crossplane-libsonnet/[email protected].4-0.21.0
jb install github.com/grafana/grafana-crossplane-libsonnet/[email protected].6-0.21.0
```

## Usage

```jsonnet
local grafanaplane = import 'github.com/Duologic/grafana-crossplane-libsonnet/grafanaplane/main.libsonnet';
local grafanaplane = import 'github.com/grafana/grafana-crossplane-libsonnet/grafanaplane/main.libsonnet';
```


## Subpackages

* [compositions](compositions.md)
* [configurations](configurations.md)
* [oss](oss/index.md)
* [raw](raw/index.md)
* [sm](sm/index.md)
71 changes: 0 additions & 71 deletions docs/compositions.md

This file was deleted.

22 changes: 22 additions & 0 deletions docs/configurations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# configurations

This package contains Configurations for the generated Compositions and CompositeResourceDefinitions (XRD). A single configuration imports compositions for a resource group. For more granular selection of XRDs, consider using the manifests in 'packages/' on the root of this repository.

The Configurations can be imported like this:

```jsonnet
local grafanaplane = import 'github.com/grafana/grafana-crossplane-libsonnet/grafanaplane/main.libsonnet';
local configurations = grafanaplane.configurations;

[
configuration.alerting,
configuration.cloud,
configuration.enterprise,
configuration.ml,
configuration.oncall,
configuration.oss,
configuration.slo,
configuration.sm
]
```

21 changes: 0 additions & 21 deletions generator/compositions.libsonnet

This file was deleted.

19 changes: 16 additions & 3 deletions generator/configurations.libsonnet
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
local namespaced = import './namespaced.libsonnet';
local crossplane = import 'github.com/jsonnet-libs/crossplane-libsonnet/crossplane/1.14/main.libsonnet';

local configuration(key) =
local configuration(key, version) =
local conf = crossplane.pkg.v1.configuration;
conf.new(key)
+ conf.spec.withPackage('xpkg.upbound.io/grafana/' + key);
+ conf.spec.withPackage('ghcr.io/grafana/crossplane/' + key + ':' + version);

{}
local groups =
std.set(
std.map(
function(def)
std.splitLimit(def.definition.spec.group, '.', 1)[0],
namespaced
)
);

function(configurationVersion) {
[group]: configuration(group, configurationVersion)
for group in groups
}
106 changes: 0 additions & 106 deletions grafanaplane/compositions.libsonnet

This file was deleted.

Loading