rename go module and flush out Earthfile build

This commit is contained in:
2025-04-25 13:25:27 -04:00
parent 10c79110a0
commit 9fe19d2cc2
12 changed files with 102 additions and 249 deletions

View File

@@ -33,5 +33,5 @@ linters-settings:
- blank # Blank section: contains all blank imports. - blank # Blank section: contains all blank imports.
- default # Default section: contains all imports that could not be matched to another section type. - default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/pulumi/) # Custom section: groups all imports with the github.com/pulumi/ prefix. - prefix(github.com/pulumi/) # Custom section: groups all imports with the github.com/pulumi/ prefix.
- prefix(github.com/brandonkal/pulumi-incus) # Custom section: local imports - prefix(git.kalinow.ski/nimbus/pulumi-incus) # Custom section: local imports
custom-order: true custom-order: true

75
Earthfile Normal file
View File

@@ -0,0 +1,75 @@
VERSION 0.8
# tfgen builds the tfgen binary and nodejs TypeScript SDK
tfgen:
FROM golang:1.24.2
WORKDIR /go/src/git.kalinow.ski/nimbus/pulumi-incus/provider
ENV WORKING_DIR=/go/src/git.kalinow.ski/nimbus/pulumi-incus
# ENV PULUMI_HOME=$(WORKING_DIR)/.pulumi
# ENV PATH=$(WORKING_DIR)/.pulumi/bin:$(PATH)
RUN mkdir -p ../.pulumi/examples-cache cmd/pulumi-resource-incus
COPY --dir provider/go.mod provider/go.sum provider/shim .
RUN go list -f "{{slice .Version 1}}" -m github.com/pulumi/pulumi/pkg/v3 > ../.pulumi/version
ENV PULUMI_HOME=${WORKING_DIR}/.pulumi
ENV PATH=${WORKING_DIR}/.pulumi/bin:$PATH
RUN curl -fsSL https://get.pulumi.com | HOME=${WORKING_DIR} sh -s -- --version "$(cat .pulumi/version)"
RUN pulumi plugin install converter terraform 1.0.16
RUN go mod download
ENV PROVIDER_VERSION=1.0.0-alpha.0+dev
ENV LDFLAGS_PROJ_VERSION="-X git.kalinow.ski/nimbus/pulumi-incus/provider/pkg/version.Version=${PROVIDER_VERSION}"
ENV PULUMI_CONVERT=1
ENV PULUMI_CONVERT_EXAMPLES_CACHE_DIR=/go/src/git.kalinow.ski/nimbus/pulumi-incus/provider/.pulumi/examples-cache
ENV PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=1
ENV PULUMI_MISSING_DOCS_ERROR=false
COPY --dir provider/resources.go provider/pkg .
COPY provider/cmd/pulumi-tfgen-incus cmd/pulumi-tfgen-incus
RUN echo '{}' > cmd/pulumi-resource-incus/bridge-metadata.json
RUN go build -o /bin/pulumi-tfgen-incus -ldflags "${LDFLAGS_PROJ_VERSION}" ./cmd/pulumi-tfgen-incus
RUN /bin/pulumi-tfgen-incus schema --out cmd/pulumi-resource-incus
RUN sed -i -e 's/souce/source/g' cmd/pulumi-resource-incus/schema.json
WORKDIR /go/src/git.kalinow.ski/nimbus/pulumi-incus
# Now that the schema.json is generated, we can generate sdks
RUN /bin/pulumi-tfgen-incus nodejs --out sdk/nodejs/
SAVE ARTIFACT sdk/nodejs
# nodejs builds the nodejs SDK using the generated tfgen file
nodejs:
FROM node:23-bookworm
WORKDIR /root/sdk/nodejs
RUN corepack enable pnpm
COPY +tfgen/nodejs .
RUN pnpm install && pnpm tsc && cp package.json pnpm-lock.yaml ./bin/
COPY README.md LICENSE bin
SAVE ARTIFACT bin AS LOCAL sdk/nodejs/bin
# publish publishes the nodejs SDK
publish:
FROM +nodejs
RUN --push --secret TOKEN=token-package-rw npm config set @kiterun:registry=https://git.kalinow.ski/api/packages/kiterun/npm/ && \
npm config set -- '//git.kalinow.ski/api/packages/kiterun/npm/:_authToken' "$TOKEN" && \
npm publish sdk/nodejs/bin
# provider builds and publishes the provider binaries
provider:
FROM +tfgen
WORKDIR /go/src/git.kalinow.ski/nimbus/pulumi-incus/provider
RUN mkdir -p /root/dist
COPY provider/cmd/pulumi-resource-incus/main.go cmd/pulumi-resource-incus/main.go
COPY README.md LICENSE ..
DO +BINARY --GOOS=linux --GOARCH=amd64
DO +BINARY --GOOS=linux --GOARCH=arm64
DO +BINARY --GOOS=darwin --GOARCH=amd64
DO +BINARY --GOOS=darwin --GOARCH=arm64
SAVE ARTIFACT /root/dist AS LOCAL dist
# ENV FILENAME=pulumi-resource-incus-v${VERSION}-linux-amd64.tar.gz
# RUN tar -czvf $FILENAME pulumi-resource-incus
# RUN --push --secret TOKEN=token-package-rw curl --user kiterun:$TOKEN --upload-file $FILENAME \
# https://git.kalinow.ski/api/packages/kiterun/generic/pulumi-incus/$PROVIDER_VERSION/$FILENAME
BINARY:
FUNCTION
ARG GOOS
ARG GOARCH
RUN cd $WORKING_DIR/provider && GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -o ../bin/$GOOS-$GOARCH/pulumi-resource-incus -ldflags "${LDFLAGS_PROJ_VERSION} -s -w" git.kalinow.ski/nimbus/pulumi-incus/provider/cmd/pulumi-resource-incus
RUN cd $WORKING_DIR && tar --gzip -cf /root/dist/pulumi-resource-incus-v${PROVIDER_VERSION}-$GOOS-$GOARCH.tar.gz README.md LICENSE -C bin/$GOOS-$GOARCH .

View File

@@ -1,8 +1,8 @@
# WARNING: This file is autogenerated - changes will be overwritten when regenerated by https://github.com/pulumi/ci-mgmt # WARNING: This file is autogenerated - changes will be overwritten when regenerated by https://github.com/pulumi/ci-mgmt
PACK := incus PACK := incus
ORG := brandonkal ORG := nimbus
PROJECT := github.com/$(ORG)/pulumi-$(PACK) PROJECT := git.kalinow.ski/$(ORG)/pulumi-$(PACK)
PROVIDER_PATH := provider PROVIDER_PATH := provider
VERSION_PATH := $(PROVIDER_PATH)/pkg/version.Version VERSION_PATH := $(PROVIDER_PATH)/pkg/version.Version
CODEGEN := pulumi-tfgen-$(PACK) CODEGEN := pulumi-tfgen-$(PACK)

View File

@@ -49,7 +49,7 @@ func getGoBaseOptions(t *testing.T) integration.ProgramTestOptions {
base := getBaseOptions(t) base := getBaseOptions(t)
baseJS := base.With(integration.ProgramTestOptions{ baseJS := base.With(integration.ProgramTestOptions{
Dependencies: []string{ Dependencies: []string{
fmt.Sprintf("github.com/brandonkal/pulumi-incus/sdk=%s", rootSdkPath), fmt.Sprintf("git.kalinow.ski/nimbus/pulumi-incus/sdk=%s", rootSdkPath),
}, },
Env: []string{ Env: []string{
fmt.Sprintf("PULUMI_GO_DEP_ROOT=%s", goDepRoot), fmt.Sprintf("PULUMI_GO_DEP_ROOT=%s", goDepRoot),

View File

@@ -1,4 +1,4 @@
module github.com/brandonkal/pulumi-incus/examples module git.kalinow.ski/nimbus/pulumi-incus/examples
go 1.22 go 1.22

View File

@@ -83,13 +83,6 @@
}, },
"incus_network_lb": { "incus_network_lb": {
"current": "incus:index/networkLoadBalancer:NetworkLoadBalancer", "current": "incus:index/networkLoadBalancer:NetworkLoadBalancer",
"past": [
{
"name": "incus:index/networkLb:NetworkLb",
"inCodegen": true,
"majorVersion": 1
}
],
"majorVersion": 1, "majorVersion": 1,
"fields": { "fields": {
"backend": { "backend": {
@@ -179,13 +172,5 @@
} }
} }
}, },
"auto-settings": { "auto-settings": {}
"resources": {
"incus_network_lb": {
"aliases": [
"incus:index/networkLb:NetworkLb"
]
}
}
}
} }

View File

@@ -20,7 +20,7 @@ import (
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge"
incus "github.com/brandonkal/pulumi-incus/provider" incus "git.kalinow.ski/nimbus/pulumi-incus/provider"
) )
//go:embed schema.json //go:embed schema.json

File diff suppressed because one or more lines are too long

View File

@@ -17,8 +17,8 @@ package main
import ( import (
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen"
incus "github.com/brandonkal/pulumi-incus/provider" incus "git.kalinow.ski/nimbus/pulumi-incus/provider"
"github.com/brandonkal/pulumi-incus/provider/pkg/version" "git.kalinow.ski/nimbus/pulumi-incus/provider/pkg/version"
) )
func main() { func main() {

View File

@@ -1,4 +1,4 @@
module github.com/brandonkal/pulumi-incus/provider module git.kalinow.ski/nimbus/pulumi-incus/provider
go 1.23.7 go 1.23.7

View File

@@ -31,7 +31,7 @@ import (
"github.com/pulumi/pulumi/pkg/v3/codegen/schema" "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/brandonkal/pulumi-incus/provider/pkg/version" "git.kalinow.ski/nimbus/pulumi-incus/provider/pkg/version"
) )
// all of the token components used below. // all of the token components used below.
@@ -110,7 +110,7 @@ func Provider() tfbridge.ProviderInfo {
// - "github.com/hashicorp/terraform-plugin-framework/provider".Provider (for plugin-framework) // - "github.com/hashicorp/terraform-plugin-framework/provider".Provider (for plugin-framework)
// //
//nolint:lll //nolint:lll
P: pfbridge.ShimProvider(incus.Provider()()), P: pfbridge.ShimProvider(incus.Provider(version.Version)()),
Name: "incus", Name: "incus",
Version: version.Version, Version: version.Version,
@@ -135,7 +135,6 @@ func Provider() tfbridge.ProviderInfo {
// For all available categories, see `Keywords` in // For all available categories, see `Keywords` in
// https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package. // https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package.
Keywords: []string{"incus", "category/cloud", "containers", "nimbus"}, Keywords: []string{"incus", "category/cloud", "containers", "nimbus"},
License: "Apache-2.0",
Homepage: "https://linuxcontainers.org", Homepage: "https://linuxcontainers.org",
Repository: "https://git.kalinow.ski/nimbus/pulumi-incus", Repository: "https://git.kalinow.ski/nimbus/pulumi-incus",
// The GitHub Org for the provider - defaults to `terraform-providers`. Note that this should // The GitHub Org for the provider - defaults to `terraform-providers`. Note that this should
@@ -178,7 +177,7 @@ func Provider() tfbridge.ProviderInfo {
Golang: &tfbridge.GolangInfo{ Golang: &tfbridge.GolangInfo{
// Set where the SDK is going to be published to. // Set where the SDK is going to be published to.
ImportBasePath: path.Join( ImportBasePath: path.Join(
"github.com/brandonkal/pulumi-incus/sdk/", "git.kalinow.ski/nimbus/pulumi-incus/sdk/",
tfbridge.GetModuleMajorVersion(version.Version), tfbridge.GetModuleMajorVersion(version.Version),
"go", "go",
mainPkg, mainPkg,

View File

@@ -6,6 +6,6 @@ import (
) )
// Provider returns a Terraform Plugin Framework provider // Provider returns a Terraform Plugin Framework provider
func Provider() func() tfprovider.Provider { func Provider(version string) func() tfprovider.Provider {
return provider.NewIncusProvider("dev") return provider.NewIncusProvider(version)
} }