Skip to content

Commit

Permalink
fix: refactor compositions into configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic committed Dec 2, 2024
1 parent c3c628c commit 1c0fcbb
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 236 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
LIBRARY_VERSION:=0.0.5
LIBRARY_VERSION:=0.0.6
PROVIDER_VERSION:=0.21.0
JSONNET_BIN:=jrsonnet
CROSSPLANE?=crank
REGISTRY?=ghcr.io

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 +21,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 +50,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
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ Jsonnet library providing a namespaced set of compositions/XRDs for the Grafana
## 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.

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

0 comments on commit 1c0fcbb

Please sign in to comment.