From eec53c8c5bf93d608f9ae0b85f1ff4ccf0973490 Mon Sep 17 00:00:00 2001 From: kpoliwka Date: Tue, 16 Apr 2024 11:29:58 +0200 Subject: [PATCH 01/21] add azure webserwer example --- examples/azure-webserver/.gitignore | 10 ++ examples/azure-webserver/Main.scala | 122 +++++++++++++++++++++++++ examples/azure-webserver/Pulumi.yaml | 3 + examples/azure-webserver/README.md | 66 +++++++++++++ examples/azure-webserver/project.scala | 8 ++ 5 files changed, 209 insertions(+) create mode 100644 examples/azure-webserver/.gitignore create mode 100644 examples/azure-webserver/Main.scala create mode 100644 examples/azure-webserver/Pulumi.yaml create mode 100644 examples/azure-webserver/README.md create mode 100644 examples/azure-webserver/project.scala diff --git a/examples/azure-webserver/.gitignore b/examples/azure-webserver/.gitignore new file mode 100644 index 00000000..7da74da6 --- /dev/null +++ b/examples/azure-webserver/.gitignore @@ -0,0 +1,10 @@ +### Scala an JVM +*.class +*.log +.bsp +.scala-build + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +kubeconfig.json diff --git a/examples/azure-webserver/Main.scala b/examples/azure-webserver/Main.scala new file mode 100644 index 00000000..96eeb9f2 --- /dev/null +++ b/examples/azure-webserver/Main.scala @@ -0,0 +1,122 @@ +import besom.* +import besom.api.azurenative + +@main def main = Pulumi.run { + // Get the desired username and password for our VM. + val username = config.requireString("username") + val password = config.requireString("password") + + // All resources will share a resource group. + val resourceGroupName = azurenative.resources.ResourceGroup("server-rg").name + + // Create a network for all VMs. + val virtualNetwork = azurenative.network.VirtualNetwork( + name = "server-network", + azurenative.network.VirtualNetworkArgs( + resourceGroupName = resourceGroupName, + addressSpace = azurenative.network.inputs.AddressSpaceArgs( + addressPrefixes = List( + "10.0.0.0/16" + ) + ) + ) + ) + + // Create a subnet within the Virtual Network. + val subnet = azurenative.network.Subnet( + name = "default", + azurenative.network.SubnetArgs( + resourceGroupName = resourceGroupName, + virtualNetworkName = virtualNetwork.name, + addressPrefix = "10.0.1.0/24" + ) + ) + + // Now allocate a public IP and assign it to our NIC. + val publicIp = azurenative.network.PublicIpAddress( + name = "server-ip", + azurenative.network.PublicIpAddressArgs( + resourceGroupName = resourceGroupName, + publicIPAllocationMethod = azurenative.network.enums.IpAllocationMethod.Dynamic + ) + ) + + val networkInterface = azurenative.network.NetworkInterface( + name = "server-nic", + azurenative.network.NetworkInterfaceArgs( + resourceGroupName = resourceGroupName, + ipConfigurations = List( + azurenative.network.inputs.NetworkInterfaceIpConfigurationArgs( + name = "webserveripcfg", + subnet = azurenative.network.inputs.SubnetArgs(id = subnet.id), + privateIPAllocationMethod = azurenative.network.enums.IpAllocationMethod.Dynamic, + publicIPAddress = azurenative.network.inputs.PublicIpAddressArgs(id = publicIp.id) + ) + ) + ) + ) + + val initScript = + """#!/bin/bash + |echo "Hello, World!" > index.html + |nohup python -m SimpleHTTPServer 80 & + |""".stripMargin + + // Now create the VM, using the resource group and NIC allocated above. + val vm = azurenative.compute.VirtualMachine( + name = "server-vm", + azurenative.compute.VirtualMachineArgs( + resourceGroupName = resourceGroupName, + networkProfile = azurenative.compute.inputs.NetworkProfileArgs( + networkInterfaces = List( + azurenative.compute.inputs.NetworkInterfaceReferenceArgs(id = networkInterface.id) + ) + ), + hardwareProfile = azurenative.compute.inputs.HardwareProfileArgs( + vmSize = azurenative.compute.enums.VirtualMachineSizeTypes.Standard_A0 + ), + osProfile = azurenative.compute.inputs.OsProfileArgs( + computerName = "hostname", + adminUsername = username, + adminPassword = password, + customData = base64.encode(initScript), + linuxConfiguration = azurenative.compute.inputs.LinuxConfigurationArgs( + disablePasswordAuthentication = false + ) + ), + storageProfile = azurenative.compute.inputs.StorageProfileArgs( + osDisk = azurenative.compute.inputs.OsDiskArgs( + createOption = azurenative.compute.enums.DiskCreateOptionTypes.FromImage, + name = "myosdisk1" + ), + imageReference = azurenative.compute.inputs.ImageReferenceArgs( + publisher = "canonical", + offer = "UbuntuServer", + sku = "16.04-LTS", + version = "latest" + ) + ) + ) + ) + + // TODO uncomment when bug https://github.com/VirtusLab/besom/issues/432 will be fixed +// val ipAddress = +// azurenative.network +// .getPublicIPAddress( +// azurenative.network.GetPublicIpAddressArgs( +// resourceGroupName = resourceGroupName, +// publicIpAddressName = publicIp.name +// ) +// ) +// .ipAddress + + Stack(publicIp).exports( + vmName = vm.name + // TODO uncomment when bug https://github.com/VirtusLab/besom/issues/432 will be fixed + // ipAddress = ipAddress + ) +} + +object base64: + def encode(v: String): String = + java.util.Base64.getEncoder.encodeToString(v.getBytes) diff --git a/examples/azure-webserver/Pulumi.yaml b/examples/azure-webserver/Pulumi.yaml new file mode 100644 index 00000000..e137b1ed --- /dev/null +++ b/examples/azure-webserver/Pulumi.yaml @@ -0,0 +1,3 @@ +name: azure-webserver +description: Azure web server example +runtime: scala diff --git a/examples/azure-webserver/README.md b/examples/azure-webserver/README.md new file mode 100644 index 00000000..692703be --- /dev/null +++ b/examples/azure-webserver/README.md @@ -0,0 +1,66 @@ +# Web Server Using Azure Virtual Machine + +This example provisions a Linux web server in an Azure Virtual Machine and gives it a public IP address. + +## Deploying the App + +To deploy your infrastructure, follow the below steps. + +### Prerequisites + +1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/) +2. [Configure Azure Credentials](https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/) + +## Running the App + +1. Create a new stack: + + ``` + $ pulumi stack init dev + ``` + +2. Configure the app deployment. The username and password here will be used to configure the Virtual Machine. The + password must adhere to the [Azure restrictions on VM passwords]( + https://docs.microsoft.com/en-us/azure/virtual-machines/windows/faq#what-are-the-password-requirements-when-creating-a-vm). + + The supplied password must be between 6-72 characters long and must satisfy at least 3 of password complexity + requirements from the following: + - Contains an uppercase character + - Contains a lowercase character + - Contains a numeric digit + - Contains a special character + - Control characters are not allowed + + ``` + $ pulumi config set azure-native:location westus # any valid Azure region will do + $ pulumi config set username webmaster + $ pulumi config set password --secret + ``` + + Note that `--secret` ensures your password is encrypted safely. + +3. Stand up the cluster by invoking pulumi + ```bash + $ pulumi up + ``` + +4. Get the IP address of the newly-created instance from the stack's outputs: + + Go to azure portal to service `Virtual Machines`. + Find newly created virtual machine and get `Public IP address` from it. + +5. Check to see that your server is now running: + + ``` + $ curl http:// + Hello, World! + ``` +6. From there, feel free to experiment. Simply making edits and running `pulumi up` will incrementally update your + stack. + +7. Once you've finished experimenting, tear down your stack's resources by destroying and removing it: + + ```bash + $ pulumi destroy --yes + $ pulumi stack rm --yes + ``` \ No newline at end of file diff --git a/examples/azure-webserver/project.scala b/examples/azure-webserver/project.scala new file mode 100644 index 00000000..275a20c8 --- /dev/null +++ b/examples/azure-webserver/project.scala @@ -0,0 +1,8 @@ +//> using scala "3.3.1" +//> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" + +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-azure-native:2.36.0-core.0.3-SNAPSHOT" + +//> using repository sonatype:snapshots From f5890dd59e961a083f1d469a7558252431207c83 Mon Sep 17 00:00:00 2001 From: kpoliwka Date: Tue, 16 Apr 2024 11:33:08 +0200 Subject: [PATCH 02/21] add azure webserwer example --- examples/azure-webserver/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/azure-webserver/README.md b/examples/azure-webserver/README.md index 692703be..9ee6415b 100644 --- a/examples/azure-webserver/README.md +++ b/examples/azure-webserver/README.md @@ -25,11 +25,11 @@ To deploy your infrastructure, follow the below steps. The supplied password must be between 6-72 characters long and must satisfy at least 3 of password complexity requirements from the following: - - Contains an uppercase character - - Contains a lowercase character - - Contains a numeric digit - - Contains a special character - - Control characters are not allowed + - Contains an uppercase character + - Contains a lowercase character + - Contains a numeric digit + - Contains a special character + - Control characters are not allowed ``` $ pulumi config set azure-native:location westus # any valid Azure region will do @@ -46,7 +46,7 @@ To deploy your infrastructure, follow the below steps. 4. Get the IP address of the newly-created instance from the stack's outputs: - Go to azure portal to service `Virtual Machines`. + Go to azure portal to service `Virtual Machines`. Find newly created virtual machine and get `Public IP address` from it. 5. Check to see that your server is now running: From ea292109946e5c62108a63c652cc0cd0f40688c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bia=C5=82y?= Date: Thu, 11 Apr 2024 13:24:10 +0200 Subject: [PATCH 03/21] changes to docs for 0.3, first draft (#447) * changes to docs for 0.3.x * updated changelog for 0.3.0 --- codegen/src/CodeGen.scala | 22 +++++ codegen/src/CodeGen.test.scala | 40 ++++++++ website/docs/architecture.md | 4 +- website/docs/async.md | 162 +++++++++++++++++++++++++++++++++ website/docs/basics.md | 11 ++- website/docs/changelog.md | 17 ++++ website/docs/constructors.md | 142 ++++++----------------------- website/docs/io.md | 78 ++++++++++++++++ website/sidebars.js | 2 + 9 files changed, 358 insertions(+), 120 deletions(-) create mode 100644 website/docs/async.md create mode 100644 website/docs/io.md diff --git a/codegen/src/CodeGen.scala b/codegen/src/CodeGen.scala index fb720f34..5a56e5ba 100644 --- a/codegen/src/CodeGen.scala +++ b/codegen/src/CodeGen.scala @@ -498,9 +498,31 @@ class CodeGen(using val unionDecoders = unionDecoderGivens(resourceProperties) + def argsDefaultMsg = if argsDefault.isEmpty then "" else "This resource has a default configuration." + val baseCompanion = if (hasOutputExtensions) { m"""|object $baseClassName extends besom.ResourceCompanion[$baseClassName]: + | /** Resource constructor for $baseClassName. + | * + | * @param name [[besom.util.NonEmptyString]] The unique (stack-wise) name of the resource in Pulumi state (not on provider's side). + | * NonEmptyString is inferred automatically from non-empty string literals, even when interpolated. If you encounter any + | * issues with this, please try using `: NonEmptyString` type annotation. If you need to convert a dynamically generated + | * string to NonEmptyString, use `NonEmptyString.apply` method - `NonEmptyString(str): Option[NonEmptyString]`. + | * + | * @param args [[${argsClassName}]] The configuration to use to create this resource. $argsDefaultMsg + | * + | * @param opts [[${resourceOptsClass}]] Resource options to use for this resource. + | * Defaults to empty options. If you need to set some options, use [[besom.opts]] function to create them, for example: + | * + | * {{{ + | * val res = $baseClassName( + | * "my-resource", + | * ${argsClassName}(...), // your args + | * opts(provider = myProvider) + | * ) + | * }}} + | */ | def apply(using ctx: besom.types.Context)( | name: besom.util.NonEmptyString, | args: ${argsClassName}${argsDefault}, diff --git a/codegen/src/CodeGen.test.scala b/codegen/src/CodeGen.test.scala index 88af46cd..ce6e3b7e 100644 --- a/codegen/src/CodeGen.test.scala +++ b/codegen/src/CodeGen.test.scala @@ -75,6 +75,26 @@ class CodeGenTest extends munit.FunSuite { |) extends besom.ProviderResource | |object Provider extends besom.ResourceCompanion[Provider]: + | /** Resource constructor for Provider. + | * + | * @param name [[besom.util.NonEmptyString]] The unique (stack-wise) name of the resource in Pulumi state (not on provider's side). + | * NonEmptyString is inferred automatically from non-empty string literals, even when interpolated. If you encounter any + | * issues with this, please try using `: NonEmptyString` type annotation. If you need to convert a dynamically generated + | * string to NonEmptyString, use `NonEmptyString.apply` method - `NonEmptyString(str): Option[NonEmptyString]`. + | * + | * @param args [[ProviderArgs]] The configuration to use to create this resource. This resource has a default configuration. + | * + | * @param opts [[besom.CustomResourceOptions]] Resource options to use for this resource. + | * Defaults to empty options. If you need to set some options, use [[besom.opts]] function to create them, for example: + | * + | * {{{ + | * val res = Provider( + | * "my-resource", + | * ProviderArgs(...), // your args + | * opts(provider = myProvider) + | * ) + | * }}} + | */ | def apply(using ctx: besom.types.Context)( | name: besom.util.NonEmptyString, | args: ProviderArgs = ProviderArgs(), @@ -204,6 +224,26 @@ class CodeGenTest extends munit.FunSuite { | ctx.call[besom.api.googlenative.container.v1.ClusterGetKubeconfigArgs, besom.api.googlenative.container.v1.ClusterGetKubeconfigResult, besom.api.googlenative.container.v1.Cluster]("google-native:container/v1:Cluster/getKubeconfig", args, this, opts) | |object Cluster extends besom.ResourceCompanion[Cluster]: + | /** Resource constructor for Cluster. + | * + | * @param name [[besom.util.NonEmptyString]] The unique (stack-wise) name of the resource in Pulumi state (not on provider's side). + | * NonEmptyString is inferred automatically from non-empty string literals, even when interpolated. If you encounter any + | * issues with this, please try using `: NonEmptyString` type annotation. If you need to convert a dynamically generated + | * string to NonEmptyString, use `NonEmptyString.apply` method - `NonEmptyString(str): Option[NonEmptyString]`. + | * + | * @param args [[ClusterArgs]] The configuration to use to create this resource. This resource has a default configuration. + | * + | * @param opts [[besom.CustomResourceOptions]] Resource options to use for this resource. + | * Defaults to empty options. If you need to set some options, use [[besom.opts]] function to create them, for example: + | * + | * {{{ + | * val res = Cluster( + | * "my-resource", + | * ClusterArgs(...), // your args + | * opts(provider = myProvider) + | * ) + | * }}} + | */ | def apply(using ctx: besom.types.Context)( | name: besom.util.NonEmptyString, | args: ClusterArgs = ClusterArgs(), diff --git a/website/docs/architecture.md b/website/docs/architecture.md index eda022d1..ab227cbf 100644 --- a/website/docs/architecture.md +++ b/website/docs/architecture.md @@ -2,7 +2,6 @@ title: Overview --- - Pulumi runtime is **asynchronous by design**. The goal is to allow the user's program to declare all the necessary resources as fast as possible so that Pulumi engine can make informed decisions about which parts of the deployment plan can be executed in parallel and therefore yield good performance. @@ -30,9 +29,10 @@ Besom stands alone in this choice and due to it **has some differences** in comp Following sections explain and showcase said differences: -- [Resource constructors](constructors.md) - resource constructors are pure functions that return Outputs - [Context](context.md) - context is passed around implicitly via Scala's Context Function - [Exports](exports.md) - your program is a function that returns Stack along with its Stack Outputs +- [Inputs and Outputs](io.md) - Outputs are static or dynamic properties passed to Inputs to configure resources +- [Resource constructors](constructors.md) - resource constructors are pure functions that return Outputs - [Laziness](laziness.md) - dangling resources are possible and resource constructors are memoized - [Apply method](apply_methods.md) - use `map` and `flatMap` to compose Outputs, not `apply` - [Logging](logging.md) - all logging statements need to be composed into the main flow diff --git a/website/docs/async.md b/website/docs/async.md new file mode 100644 index 00000000..874d38f5 --- /dev/null +++ b/website/docs/async.md @@ -0,0 +1,162 @@ +--- +title: Resource constructor asynchronicity +--- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Resources in Besom have an interesting property related to the fact that Pulumi's runtime is asynchronous. +One could suspect that in following snippet resources are created sequentially due to monadic syntax: + +```scala +for + a <- aws.s3.Bucket("first") + b <- aws.s3.Bucket("second") +yield () +``` + +This isn't true. Pulumi expects that a language SDK will declare resources as fast as possible. Due to this +fact resource constructors return immediately after they spawn a Resource object. A resource object is just a +plain case class with each property expressed in terms of Outputs. The work necessary for resolution of these +properties is executed asynchronously. In the example above both buckets will be created in parallel. + +Given that a piece of code is worth more than a 1000 words, below you can find code snippets that explain these +semantics using known Scala technologies. In each of them `Output` is replaced with a respective async datatype +to explain what internals of Besom are actually doing when resource constructors are called (oversimplified a +bit). + + + + +```scala +// internal function, here just to represent types +def resolveResourceAsync(name: String, args: Args, promises: Promise[_]*): Future[Unit] = ??? + +// resource definition +case class Bucket(bucket: Future[String]) +object Bucket: + def apply(name: String, args: BucketArgs = BucketArgs()): Future[Bucket] = + // create a promise for bucket property + val bucketNamePromise = Promise[String]() + // kicks off async resolution of the resource properties + resolveResourceAsync(name, args, bucketNamePromise) + // returns immediately + Future.successful(Bucket(bucketNamePromise.future)) + +// this just returns a Future[Unit] that will be resolved immediately +for + a <- Bucket("first") + b <- Bucket("second") +yield () +``` + + + + +```scala +// internal function, here just to represent types +def resolveResourceAsync(name: String, args: Args, promises: Deferred[IO, _]*): IO[Unit] = ??? + +// resource definition +case class Bucket(bucket: IO[String]) +object Bucket: + def apply(name: String, args: BucketArgs = BucketArgs()): IO[Bucket] = + for + // create a deferred for bucket property + bucketNameDeferred <- Deferred[IO, String]() + // kicks off async resolution of the resource properties + _ <- resolveResourceAsync(name, args, bucketNameDeferred).start + yield Bucket(bucketNameDeferred.get) // returns immediately + +// this just returns a IO[Unit] that will be resolved immediately +for + a <- Bucket("first") + b <- Bucket("second") +yield () +``` + + + + +```scala +// internal function, here just to represent types +def resolveResourceAsync(name: String, args: Args, promises: Promise[_]*): Task[Unit] = ??? + +// resource definition +case class Bucket(bucket: Task[String]) +object Bucket: + def apply(name: String, args: BucketArgs = BucketArgs()): Task[Bucket] = + for + // create a promise for bucket property + bucketNamePromise <- Promise.make[Exception, String]() + // kicks off async resolution of the resource properties + _ <- resolveResourceAsync(name, args, bucketNameDeferred).fork + yield Bucket(bucketNameDeferred.await) // returns immediately + +// this just returns a Task[Unit] that will be resolved immediately +for + a <- Bucket("first") + b <- Bucket("second") +yield () +``` + + + + +:::info +A good observer will notice that all these computations started in a fire-and-forget fashion have to be awaited somehow +and that is true. Besom does await for all spawned Outputs to be resolved before finishing the run via a built-in task +tracker passed around in `Context`. +::: + +There is an explicit way to inform Pulumi engine that some of the resources have to be created, updated or +deleted sequentially. To do that, one has to pass [resource options](https://www.pulumi.com/docs/concepts/options/) +to adequate resource constructors with `dependsOn` property set to resource to await for. Here's an example: + +```scala +for + a <- Bucket("first") + b <- Bucket("second", BucketArgs(), opts(dependsOn = a)) +yield () +``` + +There's also `deletedWith` property that allows one to declare that some resources will get cleaned up when another +resource is deleted and that trying to delete them *after* that resource is deleted will fail. A good example of such +relationship might be Kubernetes, where deletion of a namespace takes down all resources that belong do that namespace. + +This manual wiring is only necessary for cases when there are no data dependencies between defined resources. In a case +like this: + +```scala + val defaultMetadata = k8s.meta.v1.inputs.ObjectMetaArgs( + labels = Map("app" -> "my-app") + ) + + val deployment = k8s.apps.v1.Deployment( + name = "my-app-deployment", + k8s.apps.v1.DeploymentArgs( + metadata = defaultMetadata, + spec = k8s.apps.v1.inputs.DeploymentSpecArgs( + // removed for brevity + ) + ) + ) + + val service = k8s.core.v1.Service( + name = "my-app-service", + k8s.core.v1.ServiceArgs( + spec = k8s.core.v1.inputs.ServiceSpecArgs( + selector = appLabels, + // removed for brevity + ), + metadata = defaultMetadata + ), + opts(dependsOn = deployment) + ) +``` + +there is no data dependency between kubernetes deployment and kubernetes service because kubernetes links these +entities using labels. There's a guarantee that service points towards the correct deployment because a programming +language is being used and that allows to define a common constant value that is reused to define them. There is, +however, no output property of Deployment used in definition of Service and therefore Pulumi engine can't infer +that it should actually wait with the creation of Service until Deployment is up. In such cases one can use +`dependsOn` property to inform the engine about such a relationship between resources. diff --git a/website/docs/basics.md b/website/docs/basics.md index c0a9590a..ee1a1e1d 100644 --- a/website/docs/basics.md +++ b/website/docs/basics.md @@ -218,7 +218,8 @@ Inputs and Outputs are the primary [asynchronous data types in Pulumi](https://www.pulumi.com/docs/concepts/inputs-outputs/), and they signify values that will be provided by the engine later, when the resource is created and its properties can be fetched. -`Input[A]` type is an alias for `Output[A]` type used by [resource](#resources) arguments. +`Input[A]` type is an alias for `Output[A]` type used by [resource](#resources) arguments. Inputs are +[very elastic](io.md/#inputs) in what they can receive to facilitate preview-friendly, declarative model of programming. Outputs are values of type `Output[A]` and behave very much like [monads](https://en.wikipedia.org/wiki/Monad_(functional_programming)). @@ -229,7 +230,7 @@ Outputs are used to: - automatically captures dependencies between [resources](#resources) - provide a way to express transformations on its value before it's known -- deffer the evaluation of its value until it's known +- defer the evaluation of its value until it's known - track the _secretness_ of its value Output transformations available in Besom: @@ -238,9 +239,11 @@ Output transformations available in Besom: output - [lifting](lifting.md) directly read properties off an output value - [interpolation](interpolator.md) concatenate string outputs with other strings directly -- `sequence` method combines multiple outputs into a single output of a list +- `sequence` method combines multiple outputs into a single output of a collection (`parSequence` variant is also available + for explicit parallel evaluation) - `zip` method combines multiple outputs into a single output of a tuple -- `traverse` method transforms a map of outputs into a single output of a map +- `traverse` method transforms a collection of values into a single output of a collection ((`parTraverse` variant is also available + for explicit parallel evaluation)) To create an output from a plain value, use the `Output` constructor, e.g.: diff --git a/website/docs/changelog.md b/website/docs/changelog.md index 7fc72bad..565071ed 100644 --- a/website/docs/changelog.md +++ b/website/docs/changelog.md @@ -71,8 +71,25 @@ assert(json.parseJson.convertTo[Color] == color) ## Bug Fixes +* fixed infinite loop in encoders [#407](https://github.com/VirtusLab/besom/issues/407) when a recursive type is encountered +* fixed cause passing in AggregateException to improve debugging of decoders [#426](https://github.com/VirtusLab/besom/issues/426) +* fixed Pulumi side effects memoization issues in Component API [#429]https://github.com/VirtusLab/besom/pull/429 +* fixed traverse problem caused by export bug in compiler with a temporary workaround [#430](https://github.com/VirtusLab/besom/issues/430) + ## Other Changes +* custom timeouts have scaladocs now [#419](https://github.com/VirtusLab/besom/pull/419) +* overhauled serde layer with refied outputs implemented to improve parity with upstream Pulumi engine [#414](https://github.com/VirtusLab/besom/pull/414) +* StackReferences are now documented [#428](https://github.com/VirtusLab/besom/pull/428) +* updated AWS EKS hello world example [#399](https://github.com/VirtusLab/besom/pull/399/files) +* Component API now disallows returning component instances wrapped in Outputs to prevent users from dry run issues [#441](https://github.com/VirtusLab/besom/pull/441) +* added parSequence parSequence and parTraverse combinators on Output [#440](https://github.com/VirtusLab/besom/pull/440) +* added Output.when combinator [#439](https://github.com/VirtusLab/besom/pull/439) +* improved compilation errors around `Output.eval` and `Output#flatMap` [#443](https://github.com/VirtusLab/besom/pull/443) +* all Output combinators have scaladocs now [#445](https://github.com/VirtusLab/besom/pull/445) +* added extension-based combinators for `Output[Option[A]]`, `Output[List[A]]` etc [#445](https://github.com/VirtusLab/besom/pull/445) +* added support for overlays (package-specific extensions) in besom codegen, this opens a way for support of Helm, magic lambdas and other advanced features [#402](https://github.com/VirtusLab/besom/pull/402) + **Full Changelog**: https://github.com/VirtusLab/besom/compare/v0.2.2...v0.3.0 0.2.2 (22-02-2024) diff --git a/website/docs/constructors.md b/website/docs/constructors.md index d3934882..3560e009 100644 --- a/website/docs/constructors.md +++ b/website/docs/constructors.md @@ -1,17 +1,11 @@ --- -title: Resource constructors and asynchronicity +title: Resource constructors --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; ## Resources Resources are the [primary construct of Pulumi](basics.md#resources) programs. -## Outputs - -Outputs are the [primary asynchronous data structure of Pulumi](basics.md#inputs-and-outputs) programs. - ## Resource constructor syntax Most Pulumi SDKs expect you to create resource objects by invoking their constructors with `new` keyword, @@ -45,122 +39,42 @@ We have retained the CamelCase naming convention of resource constructors for pa You can always expect resource constructor names to start with capital letter. ::: -## Resource asynchronicity - -Resources in Besom have an interesting property related to the fact that Pulumi's runtime is asynchronous. -One could suspect that in following snippet resources are created sequentially due to monadic syntax: +Resource constructors always take 3 arguments: -```scala -for - a <- aws.s3.Bucket("first") - b <- aws.s3.Bucket("second") -yield () -``` + * resource name - this is an unique name of the resource in Pulumi's state management. Uniqueness is limited + to stack and the string has to be a `NonEmptyString` (most of the time Besom will be able to infer automatically + if `String` literal is non-empty but in case of ambiguity you can just add a type ascription `: NonEmptyString` + or, in case of dynamically obtained values, use `NonEmptyString`'s `apply` method that returns + `Option[NonEmptyString]`). -This isn't true. Pulumi expects that a language SDK will declare resources as fast as possible. Due to this -fact resource constructors return immediately after they spawn a Resource object. A resource object is just a -plain case class with each property expressed in terms of Outputs. The work necessary for resolution of these -properties is executed asynchronously. In the example above both buckets will be created in parallel. + * resource args - each resource has it's own companion args class (for instance, `aws.s3.Bucket` has a + `aws.s3.BucketArgs`) that takes `Input`s of values necessary to configure the resource. Args can be optional + when there are reasonable defaults and no input is necessary from the user. -Given that a piece of code is worth more than a 1000 words, below you can find code snippets that explain these -semantics using known Scala technologies. In each of them `Output` is replaced with a respective async datatype -to explain what internals of Besom are actually doing when resource constructors are called (oversimplified a -bit). + * resource options - [resource options](https://www.pulumi.com/docs/concepts/options/) are additional properties + that tell Pulumi engine how to apply changes related to this particular resource. Resource options are always + optional. These options dictate the order of creation (explicit dependency between resources otherwise unrelated + on data level), destruction, the way of performing updates (for instance delete and recreate) and which provider + instance to use. There are 3 types of resource options: + * `CustomResourceOptions` used with most of the resources defined in provider packages + * `ComponentResourceOptions` used with resources, both user-defined and remote components (defined in provider packages) + and finally + * `StackReferenceResourceOptions` used with [StackReferences](basics.md/#stack-references). + + To ease the use of resource options a shortcut context function is provided that allows user to summon the constructor + of expected resource options type by just typing `opts(...)`. Here's an example: - - ```scala -// internal function, here just to represent types -def resolveResourceAsync(name: String, args: Args, promises: Promise[_]*): Future[Unit] = ??? - -// resource definition -case class Bucket(bucket: Future[String]) -object Bucket: - def apply(name: String, args: BucketArgs = BucketArgs()): Future[Bucket] = - // create a promise for bucket property - val bucketNamePromise = Promise[String]() - // kicks off async resolution of the resource properties - resolveResourceAsync(name, args, bucketNamePromise) - // returns immediately - Future.successful(Bucket(bucketNamePromise.future)) - -// this just returns a Future[Unit] that will be resolved immediately -for - a <- Bucket("first") - b <- Bucket("second") -yield () -``` - - - +val myAwsProvider: Output[aws.Provider] = aws.Provider("my-aws-provider", aws.ProviderArgs(...)) -```scala -// internal function, here just to represent types -def resolveResourceAsync(name: String, args: Args, promises: Deferred[IO, _]*): IO[Unit] = ??? - -// resource definition -case class Bucket(bucket: IO[String]) -object Bucket: - def apply(name: String, args: BucketArgs = BucketArgs()): IO[Bucket] = - for - // create a deferred for bucket property - bucketNameDeferred <- Deferred[IO, String]() - // kicks off async resolution of the resource properties - _ <- resolveResourceAsync(name, args, bucketNameDeferred).start - yield Bucket(bucketNameDeferred.get) // returns immediately - -// this just returns a IO[Unit] that will be resolved immediately -for - a <- Bucket("first") - b <- Bucket("second") -yield () +val s3Bucket: Output[aws.s3.Bucket] = aws.s3.Bucket( + "my-bucket", + aws.s3.BucketArgs(...), + opts(provider = myAwsProvider) +) ``` - - - -```scala -// internal function, here just to represent types -def resolveResourceAsync(name: String, args: Args, promises: Promise[_]*): Task[Unit] = ??? - -// resource definition -case class Bucket(bucket: Task[String]) -object Bucket: - def apply(name: String, args: BucketArgs = BucketArgs()): Task[Bucket] = - for - // create a promise for bucket property - bucketNamePromise <- Promise.make[Exception, String]() - // kicks off async resolution of the resource properties - _ <- resolveResourceAsync(name, args, bucketNameDeferred).fork - yield Bucket(bucketNameDeferred.await) // returns immediately - -// this just returns a Task[Unit] that will be resolved immediately -for - a <- Bucket("first") - b <- Bucket("second") -yield () -``` - - - - -There is a way to inform Pulumi engine that some of the resources have to be created, updated or deleted -sequentially. To do that, one has to pass [resource options](https://www.pulumi.com/docs/concepts/options/) -to adequate resource constructors with `dependsOn` property set to resource to await for. Here's an example: -```scala -for - a <- Bucket("first") - b <- Bucket("second", BucketArgs(), opts(dependsOn = a)) -yield () -``` - - -:::info -A good observer will notice that all these forks have to be awaited somehow and that is true. Besom -does await for all spawned Outputs to be resolved before finishing the run. -::: - ## Compile time checking Besom tries to catch as many errors as possible at compile time, examples of our compile time checks are: diff --git a/website/docs/io.md b/website/docs/io.md new file mode 100644 index 00000000..560548cf --- /dev/null +++ b/website/docs/io.md @@ -0,0 +1,78 @@ +--- +title: Inputs and Outputs +--- + +Outputs are the [primary asynchronous data structure of Pulumi](basics.md#inputs-and-outputs) programs. + +### Outputs + +Outputs are: + * pure and lazy - meaning that they suspend evaluation of code until interpretation, which is perfomed by Besom + runtime that runs `Pulumi.run` function at the, so called, end-of-the-world. + + * monadic - meaning that they expose `map` and `flatMap` operators and can be used in for-comprehensions + +Outputs are capable of consuming other effects for which there exists an instance of `ToFuture` typeclass. Besom +provides 3 such instances: + +- package `besom-core` provides an instance for `scala.concurrent.Future` +- package `besom-cats` provides an instance for `cats.effect.IO` +- package `besom-zio` provides an instance for `zio.Task` + +### Inputs + +Inputs are Besom types used wherever a value is expected to be provided by user primarily to ease the use of the +configuration necessary for resource constructors to spawn infrastructure resources. Inputs allow user to provide both +raw values, values that are wrapped in an `Output`, both of the former or nothing at all when dealing with optional +fields or even singular raw values or lists of values for fields that expect multiple values. + +To make this more digestable - the basic `Input[A]` type is declared as: + +```scala +opaque type Input[+A] >: A | Output[A] = A | Output[A] +``` + +ane the `Input.Optional[A]` variant is declared as: + +```scala +opaque type Optional[+A] >: Input[A | Option[A]] = Input[A | Option[A]] +``` + +This allows for things like this: + +```scala +val int1: Input[Int] = 23 +val int2: Input[Int] = Output(23) +// what if it's an optional value? +val maybeInt1: Input.Optional[Int] = 23 +val maybeInt2: Input.Optional[Int] = None +val maybeInt3: Input.Optional[Int] = Some(23) +// yes, but also: +val maybeInt4: Input.Optional[Int] = Output(23) +val maybeInt5: Input.Optional[Int] = Output(Option(23)) +val maybeInt6: Input.Optional[Int] = Output(None) +``` + +This elastic and permissive model was designed to allow a more declarative style and facilitate the implicit +parallelism of evaluation. In fact, Outputs are meant to be thought of as short pipelines that one uses +to transform properties and values obtained from one resource to be used as argument for another. If you're +used to the classic way of working with monadic programs with chains of `flatMap` and `map` or for-comprehensions +this might seem a bit odd to you - why would we take values wrapped in Outputs as arguments? The answer is: previews! + +Outputs incorporate semantics of `Option` to support Pulumi's preview / dry-run feature that allows one to see what +changes will be applied when the program is executed against the actual environment. This, however, means that Outputs +can short-circuit when a computed (provided by the engine) value is missing in dry-run and most properties on resources +belong to this category. It is entirely possible to structure a Besom program the same way one would structure a program +that uses Cats Effect IO or ZIO but once you `flatMap` on an Output value that can be only obtained from actual environment +short-circuiting logic will kick in and all the subsequent `flatMap`/`map` steps will be skipped yielding a broken view +of the changes that will get applied in your next change to the infrastructure. To avoid this problem it is highly +recommended to write Besom programs in a style highly reminiscent of direct style and use for-comprehensions only to transform +properties passed from configuration or declared resources to another resources. This way the graph of resources is fully +known in dry-run phase and can be properly inspected. Full power of monadic composition should be reserved for situations +where it is strictly necessary. + +:::info +We are working on a solution that would allow us to track computed `Output` values on the type level and therefore inform +the user (via a compile-time information or warning) that a dynamic subtree of resources will be spawned by their code +that won't be visible in preview. +::: \ No newline at end of file diff --git a/website/sidebars.js b/website/sidebars.js index 788024e2..0c0906eb 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -43,7 +43,9 @@ const sidebars = { 'architecture', 'context', 'exports', + 'io', 'constructors', + 'async', 'laziness', 'apply_methods', 'logging', From 9747d7992bab7d5e150594594dd938182b018976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 14:06:17 +0200 Subject: [PATCH 04/21] Bump version to 0.3.0-SNAPSHOT --- besom-cats/project.scala | 2 +- besom-zio/project.scala | 2 +- core/project.scala | 3 ++- examples/aws-eks/project.scala | 8 ++++---- examples/aws-s3-folder/project.scala | 6 +++--- examples/aws-secrets-manager/project.scala | 6 +++--- examples/aws-webserver/project.scala | 8 ++++---- examples/docker-multi-container-app/infra/project.scala | 6 +++--- examples/gcp-cloudrun/infra/project.scala | 8 ++++---- examples/gcp-static-page/project.scala | 6 +++--- examples/kubernetes-guestbook/components/project.scala | 6 +++--- examples/kubernetes-guestbook/simple/project.scala | 6 +++--- examples/kubernetes-nginx/project.scala | 6 +++--- experimental/project.scala | 6 +++--- integration-tests/project.scala | 3 ++- .../resources/cats-purrl-example/project.scala | 8 ++++---- integration-tests/resources/compiler-plugin/project.scala | 4 ++-- integration-tests/resources/config-example/project.scala | 4 ++-- .../resources/executors/gradle/build.gradle.kts | 2 +- integration-tests/resources/executors/maven/pom.xml | 4 ++-- integration-tests/resources/executors/sbt/build.sbt | 2 +- .../resources/executors/scala-cli/project.scala | 4 ++-- .../resources/kubernetes-secrets/project.scala | 6 +++--- integration-tests/resources/logger-example/project.scala | 4 ++-- .../resources/memoization/source-stack/project.scala | 6 +++--- .../resources/memoization/target-stack/project.scala | 4 ++-- integration-tests/resources/random-example/project.scala | 6 +++--- .../resources/references/source-stack/project.scala | 6 +++--- .../resources/references/target-stack/project.scala | 4 ++-- integration-tests/resources/tls-example/project.scala | 6 +++--- integration-tests/resources/zio-tls-example/project.scala | 8 ++++---- language-plugin/bootstrap/project.scala | 2 +- scripts/project.scala | 3 ++- templates/aws/project.scala | 6 +++--- templates/default/project.scala | 6 +++--- templates/gcp/project.scala | 6 +++--- templates/kubernetes/project.scala | 6 +++--- version.txt | 2 +- 38 files changed, 97 insertions(+), 94 deletions(-) diff --git a/besom-cats/project.scala b/besom-cats/project.scala index 18834fea..c106a8fb 100644 --- a/besom-cats/project.scala +++ b/besom-cats/project.scala @@ -2,7 +2,7 @@ //> using options "-java-output-version:11" "-encoding:utf-8", "-Ykind-projector:underscores" //> using options "-deprecation", "-feature" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.typelevel::cats-effect:3.3.14" //> using test.dep "org.scalameta::munit:1.0.0-M10" diff --git a/besom-zio/project.scala b/besom-zio/project.scala index c1be4816..2782e7a3 100644 --- a/besom-zio/project.scala +++ b/besom-zio/project.scala @@ -2,7 +2,7 @@ //> using options "-java-output-version:11" "-encoding:utf-8", "-Ykind-projector:underscores" //> using options "-deprecation", "-feature" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "dev.zio::zio:2.0.17" //> using test.dep "org.scalameta::munit:1.0.0-M10" diff --git a/core/project.scala b/core/project.scala index 2a091c0b..1d008d85 100644 --- a/core/project.scala +++ b/core/project.scala @@ -2,7 +2,7 @@ //> using options "-java-output-version:11", "-Ysafe-init", "-Xmax-inlines:64" //> using options "-Werror", "-Wunused:all", "-deprecation", "-feature", -language:noAutoTupling -//> using dep "org.virtuslab::besom-json:0.2.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-json:0.3.0-SNAPSHOT" //> using dep "com.lihaoyi::sourcecode:0.3.1" //> using dep "com.google.protobuf:protobuf-java-util:3.24.4" //> using dep "io.grpc:grpc-netty:1.57.2" @@ -28,3 +28,4 @@ //> using publish.developer "KacperFKorban|Kacper Korban|https://github.com/KacperFKorban" //> using publish.developer "pawelprazak|Paweł Prażak|https://github.com/pawelprazak" //> using repository sonatype:snapshots +//> using repository sonatype:snapshots diff --git a/examples/aws-eks/project.scala b/examples/aws-eks/project.scala index 8faa4fa9..67052b82 100644 --- a/examples/aws-eks/project.scala +++ b/examples/aws-eks/project.scala @@ -1,9 +1,9 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-awsx:2.5.0-core.0.2" -//> using dep "org.virtuslab::besom-eks:2.2.1-core.0.2" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-awsx:2.6.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-eks:2.3.0-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/examples/aws-s3-folder/project.scala b/examples/aws-s3-folder/project.scala index f545fd22..ccbcd4f0 100644 --- a/examples/aws-s3-folder/project.scala +++ b/examples/aws-s3-folder/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-aws:6.23.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/examples/aws-secrets-manager/project.scala b/examples/aws-secrets-manager/project.scala index f545fd22..ccbcd4f0 100644 --- a/examples/aws-secrets-manager/project.scala +++ b/examples/aws-secrets-manager/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-aws:6.23.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/examples/aws-webserver/project.scala b/examples/aws-webserver/project.scala index b4349952..3602af9a 100644 --- a/examples/aws-webserver/project.scala +++ b/examples/aws-webserver/project.scala @@ -1,8 +1,8 @@ //> using scala 3.3.1 //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-aws:6.23.0-core.0.2 -//> using dep org.virtuslab::besom-tls:5.0.0-core.0.2 +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT +//> using dep org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT //> using repository sonatype:snapshots diff --git a/examples/docker-multi-container-app/infra/project.scala b/examples/docker-multi-container-app/infra/project.scala index 9f54684f..816fd605 100644 --- a/examples/docker-multi-container-app/infra/project.scala +++ b/examples/docker-multi-container-app/infra/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-docker:4.5.1-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/examples/gcp-cloudrun/infra/project.scala b/examples/gcp-cloudrun/infra/project.scala index a3d0e6d2..2de654fc 100644 --- a/examples/gcp-cloudrun/infra/project.scala +++ b/examples/gcp-cloudrun/infra/project.scala @@ -1,9 +1,9 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-gcp:7.9.0-core.0.2" -//> using dep "org.virtuslab::besom-docker:4.5.1-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3-SNAPSHOT" //> using exclude "app/*" diff --git a/examples/gcp-static-page/project.scala b/examples/gcp-static-page/project.scala index 15006efd..a0e42c60 100644 --- a/examples/gcp-static-page/project.scala +++ b/examples/gcp-static-page/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-gcp:7.9.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/examples/kubernetes-guestbook/components/project.scala b/examples/kubernetes-guestbook/components/project.scala index 41316550..f250530f 100644 --- a/examples/kubernetes-guestbook/components/project.scala +++ b/examples/kubernetes-guestbook/components/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.8.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using exclude "simple/*" //> using repository sonatype:snapshots diff --git a/examples/kubernetes-guestbook/simple/project.scala b/examples/kubernetes-guestbook/simple/project.scala index be431b36..3ef822d6 100644 --- a/examples/kubernetes-guestbook/simple/project.scala +++ b/examples/kubernetes-guestbook/simple/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.8.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using exclude "components/*" //> using repository sonatype:snapshots diff --git a/examples/kubernetes-nginx/project.scala b/examples/kubernetes-nginx/project.scala index 355d7d33..5444f00e 100644 --- a/examples/kubernetes-nginx/project.scala +++ b/examples/kubernetes-nginx/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.8.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/experimental/project.scala b/experimental/project.scala index fe3e6886..2c81b14b 100644 --- a/experimental/project.scala +++ b/experimental/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.2-SNAPSHOT" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using dep "io.github.iltotore::iron:2.5.0" //> using repository sonatype:snapshots diff --git a/integration-tests/project.scala b/integration-tests/project.scala index 2f4fbab2..aa04f3da 100644 --- a/integration-tests/project.scala +++ b/integration-tests/project.scala @@ -4,7 +4,8 @@ //> using exclude "*/resources/*" //> using toolkit 0.2.1 -//> using dep org.virtuslab::besom-codegen:0.2.3-SNAPSHOT +//> using dep org.virtuslab::besom-codegen:0.3.0-SNAPSHOT //> using dep org.scalameta::munit::1.0.0-M10 //> using repository sonatype:snapshots +//> using repository sonatype:snapshots diff --git a/integration-tests/resources/cats-purrl-example/project.scala b/integration-tests/resources/cats-purrl-example/project.scala index 9cd7166d..bf29cd9f 100644 --- a/integration-tests/resources/cats-purrl-example/project.scala +++ b/integration-tests/resources/cats-purrl-example/project.scala @@ -1,8 +1,8 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots -//> using dep org.virtuslab::besom-cats:0.2.3-SNAPSHOT -//> using dep "org.virtuslab::besom-purrl:0.5.0-core.0.2-SNAPSHOT" +//> using dep org.virtuslab::besom-cats:0.3.0-SNAPSHOT +//> using dep "org.virtuslab::besom-purrl:0.5.0-core.0.3-SNAPSHOT" diff --git a/integration-tests/resources/compiler-plugin/project.scala b/integration-tests/resources/compiler-plugin/project.scala index 32cf3931..da394f9b 100644 --- a/integration-tests/resources/compiler-plugin/project.scala +++ b/integration-tests/resources/compiler-plugin/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots diff --git a/integration-tests/resources/config-example/project.scala b/integration-tests/resources/config-example/project.scala index 32cf3931..da394f9b 100644 --- a/integration-tests/resources/config-example/project.scala +++ b/integration-tests/resources/config-example/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots diff --git a/integration-tests/resources/executors/gradle/build.gradle.kts b/integration-tests/resources/executors/gradle/build.gradle.kts index 10f63cd0..2010853f 100644 --- a/integration-tests/resources/executors/gradle/build.gradle.kts +++ b/integration-tests/resources/executors/gradle/build.gradle.kts @@ -10,7 +10,7 @@ repositories { dependencies { implementation("org.scala-lang:scala3-library_3:3.3.1") - implementation("org.virtuslab:besom-core_3:0.2.2") + implementation("org.virtuslab:besom-core_3:0.3.0-SNAPSHOT") implementation("org.virtuslab:besom-fake-standard-resource_3:1.2.3-TEST") implementation("org.virtuslab:besom-fake-external-resource_3:2.3.4-TEST") if (project.hasProperty("besomBootstrapJar")) runtimeOnly(files(project.property("besomBootstrapJar") as String)) diff --git a/integration-tests/resources/executors/maven/pom.xml b/integration-tests/resources/executors/maven/pom.xml index 6ba8ff4f..543780b4 100644 --- a/integration-tests/resources/executors/maven/pom.xml +++ b/integration-tests/resources/executors/maven/pom.xml @@ -26,7 +26,7 @@ org.virtuslab besom-bootstrap_3 - 0.2.2 + 0.3.0-SNAPSHOT system ${besomBootstrapJar} @@ -43,7 +43,7 @@ org.virtuslab besom-core_3 - 0.2.2 + 0.3.0-SNAPSHOT org.virtuslab diff --git a/integration-tests/resources/executors/sbt/build.sbt b/integration-tests/resources/executors/sbt/build.sbt index dfe4cd26..0192e0d5 100644 --- a/integration-tests/resources/executors/sbt/build.sbt +++ b/integration-tests/resources/executors/sbt/build.sbt @@ -5,7 +5,7 @@ lazy val root = project scalacOptions ++= Seq("-java-output-version", "11"), javacOptions in (Compile, compile) ++= Seq("-source", "11", "-target", "11"), libraryDependencies ++= Seq( - "org.virtuslab" %% "besom-core" % "0.2.2", + "org.virtuslab" %% "besom-core" % "0.3.0-SNAPSHOT", "org.virtuslab" %% "besom-fake-standard-resource" % "1.2.3-TEST", "org.virtuslab" %% "besom-fake-external-resource" % "2.3.4-TEST" ) diff --git a/integration-tests/resources/executors/scala-cli/project.scala b/integration-tests/resources/executors/scala-cli/project.scala index 497c9d63..c8d50b5e 100644 --- a/integration-tests/resources/executors/scala-cli/project.scala +++ b/integration-tests/resources/executors/scala-cli/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-fake-standard-resource:1.2.3-TEST" //> using dep "org.virtuslab::besom-fake-external-resource:2.3.4-TEST" diff --git a/integration-tests/resources/kubernetes-secrets/project.scala b/integration-tests/resources/kubernetes-secrets/project.scala index 94c37ef2..682fe2a4 100644 --- a/integration-tests/resources/kubernetes-secrets/project.scala +++ b/integration-tests/resources/kubernetes-secrets/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-kubernetes:4.8.1-core.0.2-SNAPSHOT" +//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" diff --git a/integration-tests/resources/logger-example/project.scala b/integration-tests/resources/logger-example/project.scala index 32cf3931..da394f9b 100644 --- a/integration-tests/resources/logger-example/project.scala +++ b/integration-tests/resources/logger-example/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots diff --git a/integration-tests/resources/memoization/source-stack/project.scala b/integration-tests/resources/memoization/source-stack/project.scala index eaec00c0..90501bb5 100644 --- a/integration-tests/resources/memoization/source-stack/project.scala +++ b/integration-tests/resources/memoization/source-stack/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-tls:5.0.0-core.0.2-SNAPSHOT" +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" diff --git a/integration-tests/resources/memoization/target-stack/project.scala b/integration-tests/resources/memoization/target-stack/project.scala index 32cf3931..da394f9b 100644 --- a/integration-tests/resources/memoization/target-stack/project.scala +++ b/integration-tests/resources/memoization/target-stack/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots diff --git a/integration-tests/resources/random-example/project.scala b/integration-tests/resources/random-example/project.scala index f2e5e5bb..c36f21c2 100644 --- a/integration-tests/resources/random-example/project.scala +++ b/integration-tests/resources/random-example/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-random:4.15.1-core.0.2-SNAPSHOT" +//> using dep "org.virtuslab::besom-random:4.16.0-core.0.3-SNAPSHOT" diff --git a/integration-tests/resources/references/source-stack/project.scala b/integration-tests/resources/references/source-stack/project.scala index eaec00c0..90501bb5 100644 --- a/integration-tests/resources/references/source-stack/project.scala +++ b/integration-tests/resources/references/source-stack/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-tls:5.0.0-core.0.2-SNAPSHOT" +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" diff --git a/integration-tests/resources/references/target-stack/project.scala b/integration-tests/resources/references/target-stack/project.scala index 32cf3931..da394f9b 100644 --- a/integration-tests/resources/references/target-stack/project.scala +++ b/integration-tests/resources/references/target-stack/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots diff --git a/integration-tests/resources/tls-example/project.scala b/integration-tests/resources/tls-example/project.scala index eaec00c0..90501bb5 100644 --- a/integration-tests/resources/tls-example/project.scala +++ b/integration-tests/resources/tls-example/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-tls:5.0.0-core.0.2-SNAPSHOT" +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" diff --git a/integration-tests/resources/zio-tls-example/project.scala b/integration-tests/resources/zio-tls-example/project.scala index bff9ecdd..c038eab7 100644 --- a/integration-tests/resources/zio-tls-example/project.scala +++ b/integration-tests/resources/zio-tls-example/project.scala @@ -1,8 +1,8 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.2.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT //> using repository sonatype:snapshots -//> using dep org.virtuslab::besom-zio:0.2.3-SNAPSHOT -//> using dep "org.virtuslab::besom-tls:5.0.0-core.0.2-SNAPSHOT" +//> using dep org.virtuslab::besom-zio:0.3.0-SNAPSHOT +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" diff --git a/language-plugin/bootstrap/project.scala b/language-plugin/bootstrap/project.scala index a38b6a3d..8500a881 100644 --- a/language-plugin/bootstrap/project.scala +++ b/language-plugin/bootstrap/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -//> using dep org.virtuslab::besom-json:0.2.3-SNAPSHOT +//> using dep org.virtuslab::besom-json:0.3.0-SNAPSHOT //> using dep io.github.classgraph:classgraph:4.8.165 //> using repository sonatype:snapshots diff --git a/scripts/project.scala b/scripts/project.scala index 80dbe528..6c425e38 100644 --- a/scripts/project.scala +++ b/scripts/project.scala @@ -9,6 +9,7 @@ //> using dep org.scoverage::scalac-scoverage-serializer:2.0.11 //> using dep org.virtuslab::scala-yaml:0.0.8 //> using dep io.get-coursier:coursier_2.13:2.1.9 -//> using dep org.virtuslab::besom-codegen:0.2.3-SNAPSHOT +//> using dep org.virtuslab::besom-codegen:0.3.0-SNAPSHOT //> using repository sonatype:snapshots +//> using repository sonatype:snapshots diff --git a/templates/aws/project.scala b/templates/aws/project.scala index f545fd22..ccbcd4f0 100644 --- a/templates/aws/project.scala +++ b/templates/aws/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-aws:6.23.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/templates/default/project.scala b/templates/default/project.scala index 231b376f..9e56a780 100644 --- a/templates/default/project.scala +++ b/templates/default/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-random:4.15.1-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-random:4.16.0-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/templates/gcp/project.scala b/templates/gcp/project.scala index 15006efd..a0e42c60 100644 --- a/templates/gcp/project.scala +++ b/templates/gcp/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-gcp:7.9.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/templates/kubernetes/project.scala b/templates/kubernetes/project.scala index 355d7d33..5444f00e 100644 --- a/templates/kubernetes/project.scala +++ b/templates/kubernetes/project.scala @@ -1,7 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.2.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.8.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using repository sonatype:snapshots diff --git a/version.txt b/version.txt index 4f1f6f61..e09dd941 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.2.3-SNAPSHOT \ No newline at end of file +0.3.0-SNAPSHOT \ No newline at end of file From 42118746d88f8c2376bd406f9e8c4e7161b83882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 15:08:01 +0200 Subject: [PATCH 05/21] Promote scripts module to artifact - publish and use the scripts module --- Justfile | 26 +++++++++++++++++++------- scripts/project.scala | 13 ++++++++++++- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Justfile b/Justfile index 6bbf1c07..24929109 100644 --- a/Justfile +++ b/Justfile @@ -38,16 +38,16 @@ default: clean-all: clean-json clean-sdk clean-out clean-compiler-plugin clean-codegen clean-scripts clean-test-integration clean-test-templates clean-test-examples clean-test-markdown # Compiles everything -compile-all: compile-json compile-sdk compile-codegen compile-compiler-plugin build-language-plugin compile-scripts +compile-all: compile-json compile-sdk compile-codegen compile-scripts compile-compiler-plugin build-language-plugin # Tests everything -test-all: test-json test-sdk test-codegen test-integration test-templates test-examples test-markdown +test-all: test-json test-sdk test-codegen test-scripts test-integration test-templates test-examples test-markdown # Publishes everything locally -publish-local-all: publish-local-json publish-local-sdk publish-local-codegen install-language-plugin +publish-local-all: publish-local-json publish-local-sdk publish-local-codegen publish-local-scripts install-language-plugin # Publishes everything to Maven -publish-maven-all: publish-maven-json publish-maven-sdk publish-maven-codegen +publish-maven-all: publish-maven-json publish-maven-sdk publish-maven-codegen publish-maven-scripts # Runs all necessary checks before committing before-commit: compile-all test-all @@ -386,14 +386,26 @@ clean-test-markdown: # Scripts #################### -# Compiles scripts module +# Compiles Besom scripts module compile-scripts: publish-local-codegen - scala-cli --power compile scripts --suppress-experimental-feature-warning --suppress-directives-in-multiple-files-warning + scala-cli --power compile scripts --suppress-experimental-feature-warning -# Clean scripts module +# Clean Besom scripts module clean-scripts: scala-cli --power clean scripts +# Runs tests for Besom scripts +test-scripts: + scala-cli --power test scripts --suppress-experimental-feature-warning + +# Publishes locally Besom scripts module +publish-local-scripts: test-scripts + scala-cli --power publish local scripts --project-version {{besom-version}} --suppress-experimental-feature-warning + +# Publishes Besom scripts module +publish-maven-scripts: test-scripts + scala-cli --power publish scripts --project-version {{besom-version}} {{publish-maven-auth-options}} --suppress-experimental-feature-warning + # Use Besom scripts directly cli *ARGS: scala-cli run scripts {{ci-opts}} --suppress-experimental-feature-warning --suppress-directives-in-multiple-files-warning scripts -- {{ARGS}} diff --git a/scripts/project.scala b/scripts/project.scala index 6c425e38..dd2a9004 100644 --- a/scripts/project.scala +++ b/scripts/project.scala @@ -10,6 +10,17 @@ //> using dep org.virtuslab::scala-yaml:0.0.8 //> using dep io.get-coursier:coursier_2.13:2.1.9 //> using dep org.virtuslab::besom-codegen:0.3.0-SNAPSHOT +//> using test.dep org.scalameta::munit::1.0.0-M10 //> using repository sonatype:snapshots -//> using repository sonatype:snapshots + +//> using publish.name "besom-scripts" +//> using publish.organization "org.virtuslab" +//> using publish.url "https://github.com/VirtusLab/besom" +//> using publish.vcs "github:VirtusLab/besom" +//> using publish.license "Apache-2.0" +//> using publish.repository "central" +//> using publish.developer "lbialy|Łukasz Biały|https://github.com/lbialy" +//> using publish.developer "prolativ|Michał Pałka|https://github.com/prolativ" +//> using publish.developer "KacperFKorban|Kacper Korban|https://github.com/KacperFKorban" +//> using publish.developer "pawelprazak|Paweł Prażak|https://github.com/pawelprazak" From b9896e02e47f262837b9decd0ea47f6989b89a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 15:10:35 +0200 Subject: [PATCH 06/21] Add Version methods for tests - add Version.besomVersion - add Version.latestPackageVersion --- scripts/Version.scala | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/scripts/Version.scala b/scripts/Version.scala index 0f37713a..72aebce8 100644 --- a/scripts/Version.scala +++ b/scripts/Version.scala @@ -1,14 +1,18 @@ package besom.scripts +import besom.model.SemanticVersion + import scala.sys.exit +import scala.util.Try import scala.util.matching.Regex -import besom.model.SemanticVersion - object Version: + private val cwd = besomDir + lazy val besomVersion: String = os.read(cwd / "version.txt").trim + + private lazy val latestPackageVersions = fetchLatestPackageVersions() + def main(args: String*): Unit = - val cwd = besomDir - lazy val besomVersion = os.read(cwd / "version.txt").trim lazy val besomDependencyPattern: Regex = ("""^(//> using (?:test\.)?(?:dep|lib|plugin) +"?\S+::besom-)([^"]+)("?)$""").r @@ -16,7 +20,7 @@ object Version: val expectedFileNames = Vector("project.scala", "project-test.scala", "run.scala") def projectFiles(path: os.Path = cwd): Map[os.Path, String] = - println(s"Searching for project files in $path") + println(s"Searching for project files in $path\n") os.walk( path, skip = (p: os.Path) => p.last == ".git" || p.last == ".out" || p.last == ".bsp" || p.last == ".scala-build" || p.last == ".idea" @@ -38,7 +42,8 @@ object Version: args match case "show" :: Nil => - println(s"Showing all Besom dependencies") + println(s"Besom version: $besomVersion\n") + println(s"Showing all Besom dependencies...\n") projectFiles() .foreachEntry { case (f, content) => content.linesIterator.zipWithIndex.foreach { case (line, index) => @@ -104,7 +109,6 @@ object Version: } case "update" :: Nil => println(s"Bumping Besom packages version to latest") - val latestPackages = latestPackageVersions() projectFiles() .collect { case (path, content) if content.linesIterator.exists(besomDependencyPattern.matches) => path -> content @@ -114,7 +118,7 @@ object Version: .map { case line if line.contains("besom-fake-") => line // ignore case besomDependencyPattern(prefix, version, suffix) => - prefix + changeVersion(version, besomVersion, latestPackages.get) + suffix + prefix + changeVersion(version, besomVersion, latestPackageVersions.get) + suffix case line => line // pass through } .mkString("\n") + "\n" @@ -137,13 +141,19 @@ object Version: end match end main - private def latestPackageVersions(): Map[String, String] = + def latestPackageVersion(name: String): String = + Try(latestPackageVersions(name)).recover { case e: NoSuchElementException => + throw Exception(s"package $name not found", e) + }.get + + private def fetchLatestPackageVersions(): Map[String, String] = println(s"Searching for latest package versions") Packages .readPackagesMetadata(Packages.packagesDir) .map { metadata => - metadata.name -> metadata.version.getOrElse(throw Exception("Package version must be present after generating")).asString + metadata.name -> metadata.version.getOrElse(throw Exception("Package version must be present at this point")).asString } .toMap - end latestPackageVersions + end fetchLatestPackageVersions + end Version From a28a8fc0e4b45db467d4d91b9dba5eb453f37648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 15:12:18 +0200 Subject: [PATCH 07/21] Use scripts.Version in integration tests --- integration-tests/CoreTests.test.scala | 42 +++++++++++++++----------- integration-tests/integration.scala | 7 ++--- integration-tests/project.scala | 4 +-- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/integration-tests/CoreTests.test.scala b/integration-tests/CoreTests.test.scala index ea247157..ccb0a1aa 100644 --- a/integration-tests/CoreTests.test.scala +++ b/integration-tests/CoreTests.test.scala @@ -3,6 +3,7 @@ package besom.integration.core import besom.codegen.{CodeGen, Config, PackageMetadata} import besom.integration.common.* import besom.integration.common.pulumi.{FixtureArgs, FixtureOpts} +import besom.scripts.Version import os.* import scala.concurrent.duration.* @@ -72,14 +73,15 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { - val schemaName = "random" - val result = codegen.generatePackage(PackageMetadata(schemaName, providerRandomSchemaVersion)) + val schemaName = "random" + val latestVersion = Version.latestPackageVersion(schemaName) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "random-example", projectFiles = Map( "project.scala" -> - (defaultProjectFile + CodeGen.packageDependency(schemaName, providerRandomSchemaVersion)) + (defaultProjectFile + CodeGen.packageDependency(schemaName, latestVersion)) ) ) }, @@ -92,14 +94,15 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { - val schemaName = "tls" - val result = codegen.generatePackage(PackageMetadata(schemaName, providerTlsSchemaVersion)) + val schemaName = "tls" + val latestVersion = Version.latestPackageVersion(schemaName) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "tls-example", projectFiles = Map( "project.scala" -> - (defaultProjectFile + CodeGen.packageDependency(schemaName, providerTlsSchemaVersion)) + (defaultProjectFile + CodeGen.packageDependency(schemaName, latestVersion)) ) ) }, @@ -110,8 +113,9 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureMultiContext]( setup = { - val schemaName = "tls" - val result = codegen.generatePackage(PackageMetadata(schemaName, providerTlsSchemaVersion)) + val schemaName = "tls" + val latestVersion = Version.latestPackageVersion(schemaName) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( FixtureOpts(), @@ -119,7 +123,7 @@ class CoreTests extends munit.FunSuite { wd / "resources" / "memoization" / "source-stack", projectFiles = Map( "project.scala" -> - (defaultProjectFile + CodeGen.packageDependency(schemaName, providerTlsSchemaVersion)) + (defaultProjectFile + CodeGen.packageDependency(schemaName, latestVersion)) ) ), FixtureArgs( @@ -152,7 +156,8 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureMultiContext]( setup = { val schemaName = "tls" - val result = codegen.generatePackage(PackageMetadata(schemaName, providerTlsSchemaVersion)) + val latestVersion = Version.latestPackageVersion(schemaName) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( FixtureOpts(), @@ -160,7 +165,7 @@ class CoreTests extends munit.FunSuite { wd / "resources" / "references" / "source-stack", projectFiles = Map( "project.scala" -> - (defaultProjectFile + CodeGen.packageDependency(schemaName, providerTlsSchemaVersion)) + (defaultProjectFile + CodeGen.packageDependency(schemaName, latestVersion)) ) ), FixtureArgs( @@ -193,7 +198,8 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { val schemaName = "tls" - val result = codegen.generatePackage(PackageMetadata(schemaName, providerTlsSchemaVersion)) + val latestVersion = Version.latestPackageVersion(schemaName) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "zio-tls-example", @@ -201,7 +207,7 @@ class CoreTests extends munit.FunSuite { "project.scala" -> (defaultProjectFile + s"""//> using dep org.virtuslab::besom-zio:$coreVersion\n""" - + CodeGen.packageDependency(schemaName, providerTlsSchemaVersion)) + + CodeGen.packageDependency(schemaName, latestVersion)) ) ) }, @@ -213,7 +219,8 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { val schemaName = "purrl" - val result = codegen.generatePackage(PackageMetadata(schemaName, providerPurrlSchemaVersion)) + val latestVersion = Version.latestPackageVersion(schemaName) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "cats-purrl-example", @@ -221,7 +228,7 @@ class CoreTests extends munit.FunSuite { "project.scala" -> (defaultProjectFile + s"""//> using dep org.virtuslab::besom-cats:$coreVersion\n""" - + CodeGen.packageDependency(schemaName, providerPurrlSchemaVersion)) + + CodeGen.packageDependency(schemaName, latestVersion)) ) ) }, @@ -233,13 +240,14 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { val schemaName = "kubernetes" - val result = codegen.generatePackage(PackageMetadata(schemaName, providerKubernetesSchemaVersion)) + val latestVersion = Version.latestPackageVersion(schemaName) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "kubernetes-secrets", projectFiles = Map( "project.scala" -> - (defaultProjectFile + CodeGen.packageDependency(schemaName, providerKubernetesSchemaVersion)) + (defaultProjectFile + CodeGen.packageDependency(schemaName, latestVersion)) ) ) }, diff --git a/integration-tests/integration.scala b/integration-tests/integration.scala index 5e241f8b..5db0c1f4 100644 --- a/integration-tests/integration.scala +++ b/integration-tests/integration.scala @@ -2,6 +2,7 @@ package besom.integration.common import besom.codegen.generator.Result import besom.codegen.{Config, PackageMetadata} +import besom.scripts.Version import munit.{Tag, Test} import os.Shellable @@ -11,12 +12,8 @@ case object LocalOnly extends munit.Tag("LocalOnly") val javaVersion = Config.DefaultJavaVersion val scalaVersion = Config.DefaultScalaVersion -val coreVersion = os.read(os.pwd / "version.txt").trim +val coreVersion = Version.besomVersion val scalaPluginVersion = coreVersion -val providerRandomSchemaVersion = "4.15.1" -val providerTlsSchemaVersion = "5.0.0" -val providerPurrlSchemaVersion = "0.5.0" -val providerKubernetesSchemaVersion = "4.8.1" val languagePluginDir = os.pwd / ".out" / "language-plugin" diff --git a/integration-tests/project.scala b/integration-tests/project.scala index aa04f3da..913e0bf3 100644 --- a/integration-tests/project.scala +++ b/integration-tests/project.scala @@ -1,11 +1,9 @@ //> using scala 3.3.1 -//> using options -java-output-version:11 -deprecation //> using exclude "*/resources/*" -//> using toolkit 0.2.1 //> using dep org.virtuslab::besom-codegen:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-scripts:0.3.0-SNAPSHOT //> using dep org.scalameta::munit::1.0.0-M10 //> using repository sonatype:snapshots -//> using repository sonatype:snapshots From 2b4afa27f648f5b84a1092c5e61540dd1246fbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 14:31:26 +0200 Subject: [PATCH 08/21] Update CONTRIBUTING.md --- CONTRIBUTING.md | 129 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 99 insertions(+), 30 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea96972f..ead41443 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ We discuss features and file bugs on GitHub via ### Issues Feel free to pick up any existing issue that looks interesting to you -or fix a bug you stumble across while using Besom. +or fix a bug you stumble across while using Besom. No matter the size, we welcome all improvements. Before investing a lot of time, please let us know, so we can discuss the issue together. @@ -33,6 +33,7 @@ to make sure your issue is unique, to lighten the triage burden on our maintaine ### Adding examples Start with a template that is closest to your use case, and modify it, e.g.: + ```bash mkdir examples/my-example cd examples/my-example @@ -42,19 +43,21 @@ pulumi --logtostderr new https://github.com/VirtusLab/besom/tree/main/templates/ ## Branching and versioning strategy We mostly follow the Pulumi strategy: + - `main` branch contains current `*-SNAPSHOT` version - `vX.Y.Z` tag marks the `X.Y.Z` release - `release/vX.Y.Z` branch contains the `X.Y.Z` release - PRs must have a prefix with the **name of the author and issue number** e.g. `pprazak/123-fix-bug` > [!NOTE] -> Please make sure to **tag first** before creating a release branch. +> Please make sure to **tag first** before creating a release branch. Versioning is done using [Semantic Versioning](https://semver.org/), with following additions: + - `x.y.z` for core version, where: - - `x` no guarantees are made about compatibility, - - `y` should not break source compatibility, - - `z` should not break binary compatibility + - `x` no guarantees are made about compatibility, + - `y` should not break source compatibility, + - `z` should not break binary compatibility - `a.b.c-core.x.y` for provider version, where `a.b.c` is the schema version - `*-SNAPSHOT` versions are used for development versions @@ -128,6 +131,7 @@ therefore might need to manipulate `PATH` to prefer the local version. #### Publish locally core SDK packages Publish locally and install necessary Besom packages: + ```bash just publish-local-all ``` @@ -142,6 +146,7 @@ just cli packages local azure docker gcp kubernetes random tls ``` To generate all Provider SDKs (takes a very long time): + ```bash export GITHUB_TOKEN=$(gh auth token) just cli packages local-all @@ -163,6 +168,7 @@ as `org.virtuslab::besom-core:X.Y.Z` and `org.virtuslab::besom-:A.B.C-c Language host provider is published to Maven as `pulumi-language-scala-vX.Y.Z-OS-ARCH.tar.gz`. To use development version of the language host provider: + ```bash pulumi --logtostderr plugin install language scala $(cat version.txt) --server github://api.github.com/VirtusLab/besom ``` @@ -172,7 +178,9 @@ To use development version of the Besom SDKs add repository in your `project.sca ```scala //> using repository sonatype:snapshots ``` + or use a command line option: + ```bash --repository=sonatype:snapshots ``` @@ -187,10 +195,9 @@ pulumi --logtostderr new https://github.com/VirtusLab/besom/tree/main/templates/ After all the testing is done, you can publish a release. -It is recommended to use `just power-wash` before publishing a release: - ```bash -just power-wash +just publish-local-all +just test-all ``` #### Bump Besom version (skip for `SNAPSHOT` re-release) @@ -202,17 +209,18 @@ export GITHUB_TOKEN=$(gh auth token) just cli version bump X.Y.Z ``` -Publish SDKs locally to test and provide fresh dependencies for scripts: +#### Publish fresh packages locally + +It is recommended to use `just power-wash` before publishing a release: ```bash -just publish-local-all +just power-wash ``` -#### Create release branch (skip for `SNAPSHOT`) +Publish the new version of SDKs locally to test and provide fresh dependencies for scripts: ```bash -git checkout -b release/v$(cat version.txt) -git push --set-upstream origin release/v$(cat version.txt) +just publish-local-all ``` #### Update dependencies versions in all `project.scala` files (optional for patch versions) @@ -224,45 +232,76 @@ export GITHUB_TOKEN=$(gh auth token) just cli version update ``` -#### Update versions in all other places (skip for `SNAPSHOT`) +#### Update versions in all other places (skip for `SNAPSHOT`) Manually update versions in all other places, specifically documentation and website, using find&replace. -#### Create a release draft on GitHub +##### Create release branch + +```bash +git checkout -b release/v$(cat version.txt) +``` + +#### Create a release draft on GitHub and publish language host + +We need this done early to be able to publish the language host provider binaries. ```bash just upsert-gh-release ``` -#### Publish core and language host +Publish language host provider binaries: + ```bash just publish-language-plugins-all +``` + +Re-publish local language host provider binary (to fix local setup): + +```bash +just install-language-plugin +``` + +#### Publish SDKs to maven + +Publishing to maven requires: +- `OSSRH_USERNAME` - the Sonatype username +- `OSSRH_PASSWORD` - the Sonatype password +- `PGP_KEY_ID` - the signing key id (`gpg --list-keys` or `gpg --show-keys`) +- `PGP_PASSWORD` - the signing key passphrase + +Publish main SDK packages to Maven + +```bash just publish-maven-all ``` #### Publish packages (optional for patch versions) To publish critical package(s): + ```bash export GITHUB_TOKEN=$(gh auth token) -just clean-out cli packages maven aws azure gcp docker kubernetes random command tls eks +just cli packages maven aws azure gcp docker kubernetes random command tls eks ``` Tip: to check what packages are required for `examples` and `templates` use: + ```bash just cli version summary examples just cli version summary templates ``` Publish all packages: + ```bash export GITHUB_TOKEN=$(gh auth token) just clean-out cli packages maven-all ``` -Cation: publishing to Maven Central is irreversible. +**Cation**: publishing to Maven Central is **irreversible**. Tip: it's safer to publish the packages on-by-one or in batches due to how Maven Central behaves. -Note: `azure-native` publishing takes a long time (1-2 hours) it is recommended to handle it separately. +Note: `azure-native` publishing takes a long time (1-2 hours) it is recommended to handle it separately. In case of any issues, you can try to resolve the issues manually at https://oss.sonatype.org/index.html#stagingRepositories. @@ -274,11 +313,14 @@ According to our Git branching and versioning strategy, the release branch shoul Make sure to bump the git tag because GitHub Release probably already created the tag. ```bash +git push --set-upstream origin release/v$(cat version.txt) git tag -f v$(cat version.txt) git push -f origin v$(cat version.txt) ``` -Make sure to merge (DO NOT squash) the release branch to `main` and delete it. +Make sure to **DO NOT squash** but merge `release/vX.Y.Z` branch into `main` otherwise the tag will not propagate to main. +Make sure to **DO NOT (auto) delete** the release branch on merge, but on the other hand, let the `release/vX.Y.Z-SNAPSHOT` be deleted on +merge to not pollute git. #### After the release @@ -288,7 +330,7 @@ After the release, you can bump the version to the next `-SNAPSHOT` version: just cli version bump X.Y.Z-SNAPSHOT ``` -Remember to release the snapshot to maven. +Remember to release the snapshot to maven. ### Testing examples locally @@ -348,6 +390,7 @@ Both IDEs support rely on BSP and is experimental. ### BSP setup with `scala-compose` Build experimental `scala-compose` and place on `$PATH`: + ``` git clone git@github.com:VirtusLab/scala-compose.git cd scala-compose @@ -374,18 +417,22 @@ cp out/scala-compose/base-image/nativeImage.dest/scala-cli ~/bin/scala-compose ``` Use `scala-compose` in `besom` directory: + ```bash scala-compose setup-ide --conf-dir . ``` ### IntelliJ setup + IntelliJ support is experimental. 1. Make sure you have the latest IntelliJ 2. Install Scala plugin and set update chanel to "Nightly Builds" -3. Use [BSP with `scala-cli`](https://scala-cli.virtuslab.org/docs/cookbooks/intellij-multi-bsp) (also see [IntelliJ documentation](https://www.jetbrains.com/help/idea/bsp-support.html)) +3. Use [BSP with `scala-cli`](https://scala-cli.virtuslab.org/docs/cookbooks/intellij-multi-bsp) (also + see [IntelliJ documentation](https://www.jetbrains.com/help/idea/bsp-support.html)) To make sure you have `.bsp` directories, by running: + ```bash just setup-intellij ``` @@ -397,6 +444,7 @@ Additionally, please set `scalafmt` as the formatter. ### VSCode setup If you are using VSCode: + 1. Install [Metals](https://scalameta.org/metals/docs/editors/vscode#installation) 2. Open the project in Metals. @@ -405,19 +453,22 @@ Make sure you have `.bsp` directory before you open the project in VSCode. This might not be enough if your infrastructure is just a part (a module) of your existing Scala project. For this to work you have to make your build tool aware of the infrastructure code, for **sbt** create a corresponding module: + ```scala lazy val infra = project.in(file("infrastructure")).settings( - libraryDependencies ++= Seq( - "org.virtuslab" %% "besom-kubernetes" % "0.1.0", // or any other sdk you are using - "org.virtuslab" %% "besom-core" % "0.1.0" - )) + libraryDependencies ++= Seq( + "org.virtuslab" %% "besom-kubernetes" % "0.1.0", // or any other sdk you are using + "org.virtuslab" %% "besom-core" % "0.1.0" + )) ``` + This just informs your IDE about the existence of the infrastructure module, DO NOT remove dependencies from `project.scala`, because they are necessary in both places. ## Troubleshooting If you susspect the issue is related to serialization, try to skip the preview (dry run is known to be problematic): + ```bash pulumi up --skip-preview ``` @@ -425,9 +476,10 @@ pulumi up --skip-preview ### GitHub might be throttling your requests If you see an error like this: + - `git` failed to clone or checkout the repository - `pulumi` failed to download the provider (401) -GitHub might be throttling your requests, try to authenticate: + GitHub might be throttling your requests, try to authenticate: ```bash export GITHUB_TOKEN=$(gh auth token) @@ -439,8 +491,9 @@ Pulumi has a few options that can help with debugging. #### CLI command line -You can pass [debug options](https://www.pulumi.com/docs/support/troubleshooting/#verbose-logging) +You can pass [debug options](https://www.pulumi.com/docs/support/troubleshooting/#verbose-logging) to any `pulumi` CLI command, e.g.: + ```bash pulumi up -v9 --logtostderr 2> log.txt less -R log.txt @@ -451,6 +504,7 @@ Use the flag `--logflow` to apply the same log level to resource providers (but #### `Pulumi.yaml` `runtime.options` You can set `runtime.options` in `Pulumi.yaml` to pass options to the language host provider, e.g.: + ```yaml name: example runtime: @@ -473,6 +527,7 @@ More environment variables can be found in [Pulumi documentation](https://www.pu #### Tracing To collect and view [a trace](https://www.pulumi.com/docs/support/troubleshooting/#tracing): + ```bash pulumi up --tracing=file:./up.trace PULUMI_DEBUG_COMMANDS=1 pulumi view-trace ./up.trace @@ -480,7 +535,9 @@ PULUMI_DEBUG_COMMANDS=1 pulumi view-trace ./up.trace ### Downgrading Pulumi on Mac OS -As a workaround one can downgrade `pulumi` to a version, e.g. `3.94.2` using a [commit hash](https://github.com/Homebrew/homebrew-core/commits/master/Formula/p/pulumi.rb): +As a workaround one can downgrade `pulumi` to a version, e.g. `3.94.2` using +a [commit hash](https://github.com/Homebrew/homebrew-core/commits/master/Formula/p/pulumi.rb): + ``` curl -L -O https://raw.githubusercontent.com/Homebrew/homebrew-core/69b97f26bc78cf68eb30eedd0ca874b6e1914b19/Formula/p/pulumi.rb brew install pulumi.rb @@ -490,41 +547,49 @@ rm pulumi.rb ### Compilation issues Remove `.scala-build`, e.g.: + ```bash rm -rf core/.scala-build ``` To restart `bloop` compilation server: + ```bash scala-cli bloop exit ``` To clean the builds: + ```bash just clean-all ``` If a deep cleaning needed: + ```bash just power-wash ```` To set `bloop` verbosity: + ```bash scala-cli setup-ide -v -v -v . ``` To use a nightly version of Scala compiler: + ```bash scala-cli compile -S 3.nightly . ``` To increase Scala compiler verbosity: + ```bash scala-cli compile --scalac-option -verbose . ``` To inspect a running JVM byt its PID use `jcmd`, e.g.: + ```bash jcmd 25776 VM.flags jcmd 25776 GC.heap_info @@ -535,21 +600,25 @@ jcmd 25776 GC.heap_info ### Serde - gRPC/Protobuf serialization and deserialization The most important information about our serde: + - unknown values are neither empty nor non-empty - we simply don't know - maps (structs) don't preserve `Null` protobuf value (but we do preserve unknown values) - upstream uses special structures signatures [besom.internal.Constants.SpecialSig](core/src/main/scala/besom/internal/codecs.scala) to encode internal metadata that Pulumi uses Serialization main entry points: + - [besom.internal.RegistersOutputs](core/src/main/scala/besom/internal/RegistersOutputs.scala) - [besom.internal.PropertiesSerializer](core/src/main/scala/besom/internal/PropertiesSerializer.scala) - [besom.internal.Encoder](core/src/main/scala/besom/internal/codecs.scala) Deserialization main entry points: + - [besom.internal.ResourceDecoder](core/src/main/scala/besom/internal/ResourceDecoder.scala) - [besom.internal.Decoder](core/src/main/scala/besom/internal/codecs.scala) Other important files: + - [besom.internal.CodecMacros](core/src/main/scala/besom/internal/CodecMacros.scala) - [besom.internal.ResourceOps#invokeInternal](core/src/main/scala/besom/internal/ResourceOps.scala) - [besom.internal.ProtobufUtil](core/src/main/scala/besom/internal/ProtobufUtil.scala) @@ -557,5 +626,5 @@ Other important files: ## Getting Help We are sure there are rough edges, and we appreciate you helping out. -If you want to reach out to other folks in the Besom community +If you want to reach out to other folks in the Besom community please go to GitHub via [Issues](https://github.com/VirtusLab/besom/issues). From f24df5c27f235816c91e68c13cd4002ab44fbc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 16:35:26 +0200 Subject: [PATCH 09/21] Update upstream test schemas --- CONTRIBUTING.md | 4 +- .../testdata/embedded-crd-types/schema.json | 2 +- .../external-resource-schema/schema.json | 3 +- .../testdata/plain-and-default/schema.json | 52 +++++++++---------- .../testdata/replace-on-change/schema.json | 2 +- scripts/Schemas.scala | 18 +++---- 6 files changed, 40 insertions(+), 41 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ead41443..0f10db8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -282,7 +282,7 @@ To publish critical package(s): ```bash export GITHUB_TOKEN=$(gh auth token) -just cli packages maven aws azure gcp docker kubernetes random command tls eks +just clean-out cli packages maven aws azure gcp docker kubernetes random command tls eks ``` Tip: to check what packages are required for `examples` and `templates` use: @@ -467,7 +467,7 @@ DO NOT remove dependencies from `project.scala`, because they are necessary in b ## Troubleshooting -If you susspect the issue is related to serialization, try to skip the preview (dry run is known to be problematic): +If you suspect the issue is related to serialization, try to skip the preview (dry run is known to be problematic): ```bash pulumi up --skip-preview diff --git a/integration-tests/resources/testdata/embedded-crd-types/schema.json b/integration-tests/resources/testdata/embedded-crd-types/schema.json index 3fe106bd..cff4ca67 100644 --- a/integration-tests/resources/testdata/embedded-crd-types/schema.json +++ b/integration-tests/resources/testdata/embedded-crd-types/schema.json @@ -83,7 +83,7 @@ "@pulumi/kubernetes": "^3.0.0" }, "devDependencies": { - "typescript": "^3.7.0" + "typescript": "^4.3.5" } }, "python": { diff --git a/integration-tests/resources/testdata/external-resource-schema/schema.json b/integration-tests/resources/testdata/external-resource-schema/schema.json index 267db6cc..31775ef4 100644 --- a/integration-tests/resources/testdata/external-resource-schema/schema.json +++ b/integration-tests/resources/testdata/external-resource-schema/schema.json @@ -151,7 +151,8 @@ }, "go": { "generateResourceContainerTypes": true, - "generateExtraInputTypes": true + "generateExtraInputTypes": true, + "importBasePath": "external-resource-schema/example" }, "nodejs": { "dependencies": { diff --git a/integration-tests/resources/testdata/plain-and-default/schema.json b/integration-tests/resources/testdata/plain-and-default/schema.json index 40a7c7ff..de981898 100644 --- a/integration-tests/resources/testdata/plain-and-default/schema.json +++ b/integration-tests/resources/testdata/plain-and-default/schema.json @@ -4,100 +4,100 @@ "resources": { "foobar::ModuleResource": { "properties": { - "optional_bool": { + "optionalBool": { "type": "boolean" } }, "inputProperties": { - "plain_optional_const": { + "plainOptionalConst": { "type": "string", "const": "val", "default": "another", "plain": true }, - "plain_optional_string": { + "plainOptionalString": { "type": "string", "default": "buzzer", "plain": true }, - "plain_optional_bool": { + "plainOptionalBool": { "type": "boolean", "default": true, "plain": true }, - "plain_optional_number": { + "plainOptionalNumber": { "type": "number", "default": 42, "plain": true }, - "plain_required_string": { + "plainRequiredString": { "type": "string", "default": "buzzer", "plain": true }, - "plain_required_bool": { + "plainRequiredBool": { "type": "boolean", "default": true, "plain": true }, - "plain_required_number": { + "plainRequiredNumber": { "type": "number", "default": 42, "plain": true }, - "optional_const": { + "optionalConst": { "type": "string", "const": "val", "default": "another" }, - "optional_string": { + "optionalString": { "type": "string", "default": "buzzer" }, - "optional_bool": { + "optionalBool": { "type": "boolean", "default": true }, - "optional_number": { + "optionalNumber": { "type": "number", "default": 42 }, - "optional_enum": { + "optionalEnum": { "$ref": "#/types/foobar::EnumThing", "default": 8 }, - "plain_required_const": { + "plainRequiredConst": { "type": "string", "const": "val", "default": "another", "plain": true }, - "required_string": { + "requiredString": { "type": "string", "default": "buzzer" }, - "required_bool": { + "requiredBool": { "type": "boolean", "default": true }, - "required_number": { + "requiredNumber": { "type": "number", "default": 42 }, - "required_enum": { + "requiredEnum": { "$ref": "#/types/foobar::EnumThing", "default": 4 } }, "requiredInputs": [ - "plain_required_string", - "plain_required_bool", - "plain_required_number", - "plain_required_const", - "required_string", - "required_bool", - "required_number", - "required_enum" + "plainRequiredString", + "plainRequiredBool", + "plainRequiredNumber", + "plainRequiredConst", + "requiredString", + "requiredBool", + "requiredNumber", + "requiredEnum" ], "type": "object" } diff --git a/integration-tests/resources/testdata/replace-on-change/schema.json b/integration-tests/resources/testdata/replace-on-change/schema.json index e78c3f34..b5e73ebc 100644 --- a/integration-tests/resources/testdata/replace-on-change/schema.json +++ b/integration-tests/resources/testdata/replace-on-change/schema.json @@ -7,7 +7,7 @@ "rec": { "$ref": "#/types/example::Rec" }, - "replace": { + "replaceMe": { "type": "string", "replaceOnChanges": true } diff --git a/scripts/Schemas.scala b/scripts/Schemas.scala index a2c20b0b..306f91aa 100644 --- a/scripts/Schemas.scala +++ b/scripts/Schemas.scala @@ -16,28 +16,26 @@ object Schemas: sys.exit(1) def fetchSchemas(cwd: os.Path): Unit = - val pulumiRepoPath = cwd / "target" / "pulumi-codegen-testdata" - val pulumiJavaRepoPath = cwd / "target" / "pulumi-java-codegen-testdata" + val pulumiRepoPath = cwd / "target" / "pulumi-codegen-testdata" + val pulumiJavaRepoPath = cwd / "target" / "pulumi-java-codegen-testdata" + val relPulumiTestsPath = os.rel / "tests" / "testdata" / "codegen" + val relPulumiJavaTestsPath = os.rel / "pkg" / "codegen" / "testing" / "test" / "testdata" val pulumiRepo = sparseCheckout( pulumiRepoPath, "github.com/pulumi/pulumi.git", - List( - os.rel / "pkg" / "codegen" / "testing" / "test" / "testdata" - ) + List(relPulumiTestsPath) ) val pulumiJavaRepo = sparseCheckout( pulumiJavaRepoPath, "github.com/pulumi/pulumi-java.git", - List( - os.rel / "pkg" / "codegen" / "testing" / "test" / "testdata" - ) + List(relPulumiJavaTestsPath) ) val targetPath = cwd / "integration-tests" / "resources" / "testdata" os.remove.all(targetPath) // copy test schemas - copySchemas(pulumiRepo / "pkg" / "codegen" / "testing" / "test" / "testdata", targetPath) - copySchemas(pulumiJavaRepo / "pkg" / "codegen" / "testing" / "test" / "testdata", targetPath) + copySchemas(relPulumiTestsPath.resolveFrom(pulumiRepo), targetPath) + copySchemas(relPulumiJavaTestsPath.resolveFrom(pulumiJavaRepo), targetPath) println("fetched test schema files") From 02eb93a7a5e3112d2fce43c3e56dfda4b6f10418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 19:41:05 +0200 Subject: [PATCH 10/21] Add Version methods for tests - add Version.besomVersion - add Version.latestPackageVersion --- integration-tests/CoreTests.test.scala | 18 +++++++++--------- integration-tests/integration.scala | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/integration-tests/CoreTests.test.scala b/integration-tests/CoreTests.test.scala index ccb0a1aa..4361c4da 100644 --- a/integration-tests/CoreTests.test.scala +++ b/integration-tests/CoreTests.test.scala @@ -96,7 +96,7 @@ class CoreTests extends munit.FunSuite { setup = { val schemaName = "tls" val latestVersion = Version.latestPackageVersion(schemaName) - val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "tls-example", @@ -155,9 +155,9 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureMultiContext]( setup = { - val schemaName = "tls" + val schemaName = "tls" val latestVersion = Version.latestPackageVersion(schemaName) - val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( FixtureOpts(), @@ -197,9 +197,9 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { - val schemaName = "tls" + val schemaName = "tls" val latestVersion = Version.latestPackageVersion(schemaName) - val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "zio-tls-example", @@ -218,9 +218,9 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { - val schemaName = "purrl" + val schemaName = "purrl" val latestVersion = Version.latestPackageVersion(schemaName) - val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "cats-purrl-example", @@ -239,9 +239,9 @@ class CoreTests extends munit.FunSuite { FunFixture[pulumi.FixtureContext]( setup = { - val schemaName = "kubernetes" + val schemaName = "kubernetes" val latestVersion = Version.latestPackageVersion(schemaName) - val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) + val result = codegen.generatePackage(PackageMetadata(schemaName, latestVersion)) scalaCli.publishLocal(result.outputDir).call() pulumi.fixture.setup( wd / "resources" / "kubernetes-secrets", diff --git a/integration-tests/integration.scala b/integration-tests/integration.scala index 5db0c1f4..497661ce 100644 --- a/integration-tests/integration.scala +++ b/integration-tests/integration.scala @@ -10,10 +10,10 @@ import scala.util.{Failure, Success, Try} case object LocalOnly extends munit.Tag("LocalOnly") -val javaVersion = Config.DefaultJavaVersion -val scalaVersion = Config.DefaultScalaVersion -val coreVersion = Version.besomVersion -val scalaPluginVersion = coreVersion +val javaVersion = Config.DefaultJavaVersion +val scalaVersion = Config.DefaultScalaVersion +val coreVersion = Version.besomVersion +val scalaPluginVersion = coreVersion val languagePluginDir = os.pwd / ".out" / "language-plugin" From 01f502ee44fb7f994d570522740290e71bbf9b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Wed, 10 Apr 2024 20:05:35 +0200 Subject: [PATCH 11/21] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f10db8e..ede02473 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -282,7 +282,7 @@ To publish critical package(s): ```bash export GITHUB_TOKEN=$(gh auth token) -just clean-out cli packages maven aws azure gcp docker kubernetes random command tls eks +just clean-out cli packages maven aws awsx azure gcp docker kubernetes random command tls eks ``` Tip: to check what packages are required for `examples` and `templates` use: @@ -330,7 +330,7 @@ After the release, you can bump the version to the next `-SNAPSHOT` version: just cli version bump X.Y.Z-SNAPSHOT ``` -Remember to release the snapshot to maven. +Remember to release the snapshots to maven. ### Testing examples locally From ee00ffca2dc9a79aeff59ee67c6921d15fe60bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Thu, 11 Apr 2024 15:53:28 +0200 Subject: [PATCH 12/21] Fix Output lifts - remove Typeable - simplify Output.when condition signature --- .../main/scala/besom/internal/Output.scala | 40 ++++++------------- .../scala/besom/internal/OutputTest.scala | 19 +++------ 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/core/src/main/scala/besom/internal/Output.scala b/core/src/main/scala/besom/internal/Output.scala index 62eebe2a..bc196080 100644 --- a/core/src/main/scala/besom/internal/Output.scala +++ b/core/src/main/scala/besom/internal/Output.scala @@ -1,7 +1,6 @@ package besom.internal import scala.collection.BuildFrom -import scala.reflect.Typeable /** Output is a wrapper for a monadic effect used to model async execution that allows Pulumi to track information about dependencies * between resources and properties of data (whether it's known or a secret for instance). @@ -31,7 +30,7 @@ class Output[+A] private[internal] (using private[besom] val ctx: Context)( * @return * an Output with the flat-mapped value * @see - * [[flatMap(A => F[B])]] for flat-mapping with an effectful function + * `flatMap(A => F[B])` for flat-mapping with an effectful function */ def flatMap[B](f: A => Output[B]): Output[B] = Output.ofData( @@ -51,7 +50,7 @@ class Output[+A] private[internal] (using private[besom] val ctx: Context)( * @return * an Output with the flat-mapped value * @see - * [[flatMap(A => Output[B])]] for flat-mapping with Output-returning function + * `flatMap(A => Output[B])` for flat-mapping with Output-returning function */ def flatMap[F[_]: Result.ToFuture, B](f: A => F[B]): Output[B] = Output.ofData( @@ -196,7 +195,7 @@ trait OutputFactory: /** Creates an `Output` with the given `a` if the given `condition` is `true` or returns `None` if the condition is `false` */ - def when[A: Typeable](condition: => Input.Optional[Boolean])(a: => Input.Optional[A])(using ctx: Context): Output[Option[A]] = + def when[A](condition: => Input[Boolean])(a: => Input.Optional[A])(using ctx: Context): Output[Option[A]] = Output.when(condition)(a) end OutputFactory @@ -250,14 +249,14 @@ trait OutputExtensionsFactory: * @return * an [[Output]] with the value of the underlying [[Some]] or the `default` value if [[None]] */ - def getOrElse[B >: A: Typeable](default: => B | Output[B])(using ctx: Context): Output[B] = + def getOrElse[B >: A](default: => B | Output[B])(using ctx: Context): Output[B] = output.flatMap { opt => opt match case Some(a) => Output(a) case None => default match case b: Output[B @unchecked] => b - case b: B => Output(b) + case b: B @unchecked => Output(b) } /** Get the value of the underlying [[Option]] or fail the outer [[Output]] with the given [[Throwable]] @@ -294,12 +293,12 @@ trait OutputExtensionsFactory: * @return * an [[Output]] of the mapped [[Option]] */ - def mapInner[B: Typeable](f: A => B | Output[B])(using ctx: Context): Output[Option[B]] = + def mapInner[B](f: A => B | Output[B])(using ctx: Context): Output[Option[B]] = output.flatMap { case Some(a) => f(a) match case b: Output[B @unchecked] => b.map(Some(_)) - case b: B => Output(Some(b)) + case b: B @unchecked => Output(Some(b)) case None => Output(None) } @@ -352,13 +351,13 @@ trait OutputExtensionsFactory: * @return * an [[Output]] of the mapped [[List]] */ - def mapInner[B: Typeable](f: A => B | Output[B])(using Context): Output[List[B]] = output.flatMap { + def mapInner[B](f: A => B | Output[B])(using Context): Output[List[B]] = output.flatMap { case Nil => Output(List.empty[B]) case h :: t => f(h) match case b: Output[B @unchecked] => Output.sequence(b :: t.map(f.asInstanceOf[A => Output[B]](_))) - case b: B => + case b: B @unchecked => Output(b :: t.map(f.asInstanceOf[A => B](_))) } @@ -419,7 +418,7 @@ trait OutputExtensionsFactory: * @return * an [[Output]] of the mapped [[List]] or an empty list if the optional [[List]] is [[None]] */ - def mapInner[B: Typeable](f: A => B | Output[B])(using Context): Output[List[B]] = output + def mapInner[B](f: A => B | Output[B])(using Context): Output[List[B]] = output .map { case Some(list) => list case None => List.empty @@ -511,24 +510,11 @@ object Output: def secret[A](value: A)(using ctx: Context): Output[A] = new Output[A](ctx.registerTask(Result.pure(OutputData(value, Set.empty, isSecret = true)))) - def when[A: Typeable](cond: => Input.Optional[Boolean])( + def when[A](cond: => Input[Boolean])( a: => Input.Optional[A] )(using ctx: Context): Output[Option[A]] = - val p: Output[Boolean] = cond.asOptionOutput(isSecret = false).flatMap { - case None => Output(false) - case Some(b: Boolean) => Output(b) + cond.asOutput().flatMap { c => + if c then a.asOptionOutput(isSecret = false) else Output(None) } - - def f(c: Boolean): Output[Option[A]] = - a.asOptionOutput(isSecret = false) match - case o: Output[A | Option[A]] if c => - o.flatMap { - case None => Output(None) - case Some(v: A) => Output(Some(v)) - case a: A => Output(Some(a)) - } - case _ => Output(None) // return None if condition is false - - p.flatMap(f) end when end Output diff --git a/core/src/test/scala/besom/internal/OutputTest.scala b/core/src/test/scala/besom/internal/OutputTest.scala index 6b32a9f5..f929ea77 100644 --- a/core/src/test/scala/besom/internal/OutputTest.scala +++ b/core/src/test/scala/besom/internal/OutputTest.scala @@ -282,26 +282,19 @@ class OutputTest extends munit.FunSuite: ).foreach { (cond, value, expected) => given Context = DummyContext().unsafeRunSync() for - optCond <- Vector(true, false) outCond <- Vector(true, false) optVal <- Vector(true, false) outVal <- Vector(true, false) do - // FIXME: the inference is not working without this - val c: Boolean | Option[Boolean] | Output[Boolean] | Output[Option[Boolean]] = (outCond, optCond) match - case (true, true) => Output(Option(cond)) - case (true, false) => Output(cond) - case (false, true) => Some(cond) - case (false, false) => cond - - // FIXME: the inference is not working without this - val v: String | Option[String] | Output[String] | Output[Option[String]] = (outVal, optVal) match + val c = if outCond then Output(cond) else cond + + val v = (outVal, optVal) match case (true, true) => Output(Option(value)) case (true, false) => Output(value) case (false, true) => Some(value) case (false, false) => value - test(s"Output.when ${cond} then ${value} (optCond: ${optCond}, outCond: ${outCond}, valOpt: ${optVal}, valOut: ${outVal})") { + test(s"Output.when ${cond} then ${value} (outCond: ${outCond}, valOpt: ${optVal}, valOut: ${outVal})") { val result = Output.when(c)(v) assertEquals(result.getData.unsafeRunSync(), OutputData(expected)) } @@ -468,7 +461,7 @@ class OutputTest extends munit.FunSuite: for outVal <- Vector(true, false) do test(s"List.mapInner ${value}") { - val result: Output[List[String]] = // FIXME: the inference is not working without the explicit type + val result = if outVal then Output(value).mapInner(f.andThen(Output(_))) else Output(value).mapInner(f) assertEquals(result.getData.unsafeRunSync(), OutputData(expected)) @@ -583,7 +576,7 @@ class OutputTest extends munit.FunSuite: for outVal <- Vector(true, false) do test(s"Option[List].mapInner ${value}") { - val result: Output[List[String]] = // FIXME: the inference is not working without the explicit type + val result = if outVal then Output(value).mapInner(f.andThen(Output(_))) else Output(value).mapInner(f) assertEquals(result.getData.unsafeRunSync(), OutputData(expected)) From 7f2ae7a9dfff65e9a9f96631d257297fc2b105c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Thu, 11 Apr 2024 15:54:31 +0200 Subject: [PATCH 13/21] Update components example - update kubernetes guestbook components --- .../scala/besom/internal/OutputTest.scala | 1 - .../components/Main.scala | 422 +++++++++++++----- .../components/Pulumi.yaml | 4 +- .../kubernetes-guestbook/components/README.md | 46 +- .../components/project.scala | 1 - .../kubernetes-guestbook/simple/project.scala | 1 - 6 files changed, 346 insertions(+), 129 deletions(-) diff --git a/core/src/test/scala/besom/internal/OutputTest.scala b/core/src/test/scala/besom/internal/OutputTest.scala index f929ea77..52cc9134 100644 --- a/core/src/test/scala/besom/internal/OutputTest.scala +++ b/core/src/test/scala/besom/internal/OutputTest.scala @@ -287,7 +287,6 @@ class OutputTest extends munit.FunSuite: outVal <- Vector(true, false) do val c = if outCond then Output(cond) else cond - val v = (outVal, optVal) match case (true, true) => Output(Option(value)) case (true, false) => Output(value) diff --git a/examples/kubernetes-guestbook/components/Main.scala b/examples/kubernetes-guestbook/components/Main.scala index be1d61bc..861d7bfc 100644 --- a/examples/kubernetes-guestbook/components/Main.scala +++ b/examples/kubernetes-guestbook/components/Main.scala @@ -1,130 +1,336 @@ import besom.* import besom.api.kubernetes -import besom.api.kubernetes.core.v1.{Service, ServiceArgs} -import besom.api.kubernetes.core.v1.inputs.* -import besom.api.kubernetes.apps.v1.{Deployment, DeploymentArgs} -import besom.api.kubernetes.apps.v1.inputs.* +import besom.api.kubernetes.apps.v1.inputs.DeploymentSpecArgs +import besom.api.kubernetes.apps.v1.* +import besom.api.kubernetes.core +import besom.api.kubernetes.core.v1.* +import besom.api.kubernetes.core.v1.enums.* +import besom.api.kubernetes.core.v1.inputs.{ + ContainerArgs, + ContainerPortArgs, + EnvVarArgs, + PodSpecArgs, + PodTemplateSpecArgs, + ResourceRequirementsArgs, + ServicePortArgs, + ServiceSpecArgs, + VolumeArgs, + VolumeMountArgs +} import besom.api.kubernetes.meta.v1.* import besom.api.kubernetes.meta.v1.inputs.* -import besom.api.kubernetes.core.v1.enums.ServiceSpecType - -case class ServiceDeploymentArgs( - image: String, - replicas: Int = 1, - resources: Option[ResourceRequirementsArgs] = None, - ports: List[Int] = List.empty, - allocateIPAddress: Option[Boolean] = None, - serviceType: Option[ServiceSpecType] = None, - env: List[EnvVarArgs] = List.empty -) -case class ServiceDeployment(ipAddress: Output[Option[String]])(using ComponentBase) extends ComponentResource derives RegistersOutputs - -def serviceDeployment(using Context)( - name: NonEmptyString, - args: ServiceDeploymentArgs, - componentResourceOptions: ComponentResourceOptions = ComponentResourceOptions() -): Output[ServiceDeployment] = - component(name, "k8sx:service:ServiceDeployment", componentResourceOptions) { - val labels = Map("app" -> name) - val deploymentPorts = args.ports - .map(port => ContainerPortArgs(containerPort = port)) - - val container = ContainerArgs( - name = name, - image = args.image, - resources = args.resources.getOrElse( - ResourceRequirementsArgs( - requests = Map( - "cpu" -> "100m", - "memory" -> "100Mi" +case class RedisEndpoint(url: Output[String], fqdn: Output[String]) derives Encoder +object RedisEndpoint: + extension (r: Output[RedisEndpoint]) + def url: Output[String] = r.flatMap(_.url) + def fqdn: Output[String] = r.flatMap(_.fqdn) +case class Redis private ( + namespace: Output[String], + leader: Output[RedisEndpoint], + replica: Output[RedisEndpoint] +)(using ComponentBase) + extends ComponentResource + derives RegistersOutputs +object Redis: + extension (r: Output[Redis]) + def namespace: Output[String] = r.flatMap(_.namespace) + def leader: Output[RedisEndpoint] = r.flatMap(_.leader) + def replica: Output[RedisEndpoint] = r.flatMap(_.replica) + + def apply(using Context)( + name: NonEmptyString, + replicas: Input[Int] = 1, + options: ComponentResourceOptions = ComponentResourceOptions() + ): Output[Redis] = + component(name, "besom:example:Redis", options) { + val namespace = Namespace(s"redis-$name") + val leaderName: NonEmptyString = "redis-leader" + val leaderLabels = Map("app" -> leaderName) + + val redisPortName = "client" + val redisPortNumber = 6379 + + val leader = Deployment( + leaderName, + DeploymentArgs( + metadata = ObjectMetaArgs( + name = leaderName, + namespace = namespace.metadata.name, + labels = leaderLabels + ), + spec = DeploymentSpecArgs( + selector = LabelSelectorArgs( + matchLabels = leaderLabels + ), + template = PodTemplateSpecArgs( + metadata = ObjectMetaArgs( + name = leaderName, + namespace = namespace.metadata.name, + labels = leaderLabels + ), + spec = PodSpecArgs( + containers = List( + ContainerArgs( + name = "redis", + image = "redis", + ports = List( + ContainerPortArgs(name = redisPortName, containerPort = redisPortNumber) + ), + resources = ResourceRequirementsArgs( + requests = Map( + "cpu" -> "100m", + "memory" -> "100Mi" + ) + ) + ) + ) + ) + ) ) ) - ), - env = args.env, - ports = deploymentPorts - ) + ) - val deployment = Deployment( - name, - DeploymentArgs( - spec = DeploymentSpecArgs( - selector = LabelSelectorArgs(matchLabels = labels), - replicas = args.replicas, - template = PodTemplateSpecArgs( - metadata = ObjectMetaArgs(labels = labels), - spec = PodSpecArgs(containers = List(container)) + val leaderService = Service( + leaderName, + ServiceArgs( + metadata = ObjectMetaArgs( + name = leaderName, + labels = leaderLabels, + namespace = namespace.metadata.name + ), + spec = ServiceSpecArgs( + ports = List( + ServicePortArgs( + name = redisPortName, + port = redisPortNumber, + targetPort = redisPortNumber + ) + ), + selector = leader.spec.template.metadata.labels ) ) ) - ) - val servicePorts = args.ports - .map(port => ServicePortArgs(port = port, targetPort = port)) - - val service = Service( - name, - ServiceArgs( - metadata = ObjectMetaArgs(labels = labels, name = name), - spec = ServiceSpecArgs( - `type` = args.allocateIPAddress - .flatMap(Option.when(_)(args.serviceType.getOrElse(ServiceSpecType.LoadBalancer))), - ports = servicePorts, - selector = labels + val replicaName: NonEmptyString = "redis-replica" + val replicaLabels = Map("app" -> replicaName) + + val replica = Deployment( + replicaName, + DeploymentArgs( + metadata = ObjectMetaArgs( + name = replicaName, + namespace = namespace.metadata.name, + labels = replicaLabels + ), + spec = DeploymentSpecArgs( + selector = LabelSelectorArgs( + matchLabels = replicaLabels + ), + replicas = replicas, + template = PodTemplateSpecArgs( + metadata = ObjectMetaArgs( + name = replicaName, + namespace = namespace.metadata.name, + labels = replicaLabels + ), + spec = PodSpecArgs( + containers = List( + ContainerArgs( + name = "redis", + image = "pulumi/guestbook-redis-replica", + env = List( + EnvVarArgs(name = "GET_HOSTS_FROM", value = "dns") + ), + ports = List( + ContainerPortArgs(name = redisPortName, containerPort = redisPortNumber) + ), + resources = ResourceRequirementsArgs( + requests = Map( + "cpu" -> "100m", + "memory" -> "100Mi" + ) + ) + ) + ) + ) + ) + ) ) ) - ) - val ipAddress = - for - hasIp <- args.allocateIPAddress - serviceType <- args.serviceType if hasIp - yield - if serviceType == ServiceSpecType.ClusterIP - then service.spec.clusterIP - else service.status.loadBalancer.ingress.map(_.map(_.head)).ip - - for - _ <- deployment - _ <- service - yield ServiceDeployment(ipAddress.getOrElse(Output(None))) - } - -@main def main = Pulumi.run { - val redisLeader = serviceDeployment( - name = "redis-leader", - args = ServiceDeploymentArgs( - image = "redis", - ports = List(6379) - ) - ) + val replicaService = Service( + replicaName, + ServiceArgs( + metadata = ObjectMetaArgs( + name = replicaName, + labels = replicaLabels, + namespace = namespace.metadata.name + ), + spec = ServiceSpecArgs( + ports = List( + ServicePortArgs( + name = redisPortName, + port = redisPortNumber, + targetPort = redisPortNumber + ) + ), + selector = replica.spec.template.metadata.labels + ) + ) + ) - val redisReplica = serviceDeployment( - name = "redis-replica", - args = ServiceDeploymentArgs( - image = "pulumi/guestbook-redis-replica", - ports = List(6379) - ) - ) + new Redis( + namespace = namespace.metadata.name.getOrFail(Exception("expected namespace name to be defined")), + leader = Output( + RedisEndpoint( + url = p"redis://${serviceFqdn(leaderService, namespace)}:$redisPortNumber", + fqdn = serviceFqdn(leaderService, namespace) + ) + ), + replica = Output( + RedisEndpoint( + url = p"redis://${serviceFqdn(replicaService, namespace)}:$redisPortNumber", + fqdn = serviceFqdn(replicaService, namespace) + ) + ) + ) + } +end Redis - val frontend = config - .getBoolean("isMinikube") - .getOrElse(false) - .flatMap(isMinikube => - serviceDeployment( - name = "frontend", - args = ServiceDeploymentArgs( - replicas = 3, - image = "pulumi/guestbook-php-redis", - ports = List(80), - allocateIPAddress = Some(true), - serviceType = Some(if isMinikube then ServiceSpecType.ClusterIP else ServiceSpecType.LoadBalancer) +case class ApplicationArgs( + redis: Input[Redis], + serviceType: Input[ServiceSpecType], + image: Input[String] = "pulumi/guestbook-php-redis", + replicas: Input[Int] = 1, + resources: Input[Option[ResourceRequirementsArgs]] = None +) + +case class Application private ( + namespace: Output[String], + url: Output[String], + fqdn: Output[String] +)(using ComponentBase) + extends ComponentResource + derives RegistersOutputs +object Application: + extension (r: Output[Application]) + def namespace: Output[String] = r.flatMap(_.namespace) + def url: Output[String] = r.flatMap(_.url) + def fqdn: Output[String] = r.flatMap(_.fqdn) + + def apply(using Context)( + name: NonEmptyString, + args: ApplicationArgs, + componentResourceOptions: ComponentResourceOptions = ComponentResourceOptions() + ): Output[Application] = + component(name, "besom:example:Application", componentResourceOptions) { + val labels = Map("app" -> name) + val namespace = Namespace( + name, + NamespaceArgs( + metadata = ObjectMetaArgs( + labels = labels + ) ) ) - ) - Stack(redisLeader, redisReplica) - .exports( - ipAddress = frontend.flatMap(_.ipAddress) + val appPortNumber = 80 + val deployment = Deployment( + name, + DeploymentArgs( + metadata = ObjectMetaArgs( + labels = labels, + namespace = namespace.metadata.name + ), + spec = DeploymentSpecArgs( + selector = LabelSelectorArgs(matchLabels = labels), + replicas = args.replicas, + template = PodTemplateSpecArgs( + metadata = ObjectMetaArgs(labels = labels), + spec = PodSpecArgs( + containers = List( + ContainerArgs( + name = name, + image = args.image, + ports = List( + ContainerPortArgs(name = "http", containerPort = appPortNumber) + ), + env = List( + EnvVarArgs(name = "GET_HOSTS_FROM", value = "env"), + EnvVarArgs(name = "REDIS_LEADER_SERVICE_HOST", value = args.redis.asOutput().leader.fqdn), + EnvVarArgs(name = "REDIS_REPLICA_SERVICE_HOST", value = args.redis.asOutput().replica.fqdn) + ), + resources = args.resources + .asOptionOutput() + .getOrElse( + ResourceRequirementsArgs( + requests = Map( + "cpu" -> "100m", + "memory" -> "100Mi" + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + + val service = Service( + name, + ServiceArgs( + metadata = ObjectMetaArgs( + labels = labels, + namespace = namespace.metadata.name + ), + spec = ServiceSpecArgs( + selector = deployment.spec.template.metadata.labels, + `type` = args.serviceType, + ports = List( + ServicePortArgs(name = "http", port = appPortNumber, targetPort = appPortNumber) + ) + ) + ) + ) + + val fqdn = serviceFqdn(service, namespace) + val maybeIngress = service.status.loadBalancer.ingress.headOption + val hostnameOrIp = maybeIngress.hostname.orElse(maybeIngress.ip) + val url = p"http://${hostnameOrIp.getOrElse(fqdn)}:$appPortNumber" + + new Application( + namespace = namespace.metadata.name.getOrFail(Exception("expected namespace name to be defined")), + url = url, + fqdn = fqdn + ) + } +end Application + +private def serviceFqdn(service: Output[Service], namespace: Output[Namespace])(using Context): Output[String] = + val serviceName = service.metadata.name.getOrFail(Exception("expected service name to be defined")) + val namespaceName = namespace.metadata.name.getOrFail(Exception("expected namespace name to be defined")) + p"${serviceName}.${namespaceName}.svc.cluster.local" + +@main def main(): Unit = Pulumi.run { + val useLoadBalancer = config.getBoolean("useLoadBalancer").getOrElse(true) + + val redis = Redis("cache", 3) + + val frontend = Application( + name = "frontend", + args = ApplicationArgs( + replicas = 3, + serviceType = useLoadBalancer.map(if _ then ServiceSpecType.LoadBalancer else ServiceSpecType.ClusterIP), + redis = redis ) + ) + + Stack.exports( + frontend = frontend.url, + leader = redis.leader, + replica = redis.replica + ) } diff --git a/examples/kubernetes-guestbook/components/Pulumi.yaml b/examples/kubernetes-guestbook/components/Pulumi.yaml index d85f6bf5..60e0d511 100644 --- a/examples/kubernetes-guestbook/components/Pulumi.yaml +++ b/examples/kubernetes-guestbook/components/Pulumi.yaml @@ -3,6 +3,6 @@ runtime: scala description: Kubernetes Guestbook example based on https://kubernetes.io/docs/tutorials/stateless-application/guestbook/ template: config: - isMinikube: - description: Whether you are deploying to minikube + useLoadBalancer: + description: Whether to use a load balancer default: true \ No newline at end of file diff --git a/examples/kubernetes-guestbook/components/README.md b/examples/kubernetes-guestbook/components/README.md index 7fbebdf0..e56ec57c 100644 --- a/examples/kubernetes-guestbook/components/README.md +++ b/examples/kubernetes-guestbook/components/README.md @@ -16,44 +16,58 @@ Enter a stack name: testbook This example will attempt to expose the Guestbook application to the Internet with a `Service` of type `LoadBalancer`. Since minikube does not support `LoadBalancer`, the Guestbook application -already knows to use type `ClusterIP` instead; all you need to do is to tell it whether you're -deploying to minikube: +already knows to use type `ClusterIP` instead. All you need to do is to tell it whether you're +deploying to use the load balancer or not. + +You can do this by setting the `useLoadBalancer` configuration value to (default is `true`): ```sh -pulumi config set isMinikube +pulumi config set useLoadBalancer ``` Perform the deployment: ```sh $ pulumi up +... Updating stack 'testbook' Performing changes: - Type Name Status - + pulumi:pulumi:Stack guestbook-easy-testbook created - + ├─ kubernetes:apps:Deployment redis-replica created - + ├─ kubernetes:apps:Deployment frontend created - + ├─ kubernetes:apps:Deployment redis-leader created - + ├─ kubernetes:core:Service redis-leader created - + ├─ kubernetes:core:Service redis-replica created - + └─ kubernetes:core:Service frontend created + Type Name Status + + pulumi:pulumi:Stack guestbook-easy-dev created (54s) + + ├─ besom:example:Application frontend created (20s) + + │ ├─ kubernetes:core/v1:Namespace frontend created (0.33s) + + │ ├─ kubernetes:apps/v1:Deployment frontend created (5s) + + │ └─ kubernetes:core/v1:Service frontend created (10s) + + └─ besom:example:Redis cache created (21s) + + ├─ kubernetes:core/v1:Namespace redis-cache created (0.26s) + + ├─ kubernetes:apps/v1:Deployment redis-leader created (7s) + + ├─ kubernetes:core/v1:Service redis-leader created (10s) + + ├─ kubernetes:apps/v1:Deployment redis-replica created (9s) + + └─ kubernetes:core/v1:Service redis-replica created (10s) Outputs: - + FrontendIp: "35.232.147.18" + frontend: "http://localhost:80" + leader : { + fqdn: "redis-leader.redis-cache-623162a5.svc.cluster.local" + url : "redis://redis-leader.redis-cache-623162a5.svc.cluster.local:6379" + } + replica : { + fqdn: "redis-replica.redis-cache-623162a5.svc.cluster.local" + url : "redis://redis-replica.redis-cache-623162a5.svc.cluster.local:6379" + } Resources: - + 7 created - -Duration: 17s + + 11 created +Duration: 58s ``` And finally - open the application in your browser to see the running application. If you're running macOS you can simply run: ```sh -open $(pulumi stack output FrontendIp) +open $(pulumi stack output frontend) ``` > _Note_: minikube does not support type `LoadBalancer`; if you are deploying to minikube, make sure diff --git a/examples/kubernetes-guestbook/components/project.scala b/examples/kubernetes-guestbook/components/project.scala index f250530f..a058134f 100644 --- a/examples/kubernetes-guestbook/components/project.scala +++ b/examples/kubernetes-guestbook/components/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using exclude "simple/*" diff --git a/examples/kubernetes-guestbook/simple/project.scala b/examples/kubernetes-guestbook/simple/project.scala index 3ef822d6..eb14b2b3 100644 --- a/examples/kubernetes-guestbook/simple/project.scala +++ b/examples/kubernetes-guestbook/simple/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using exclude "components/*" From 134bac4f1e5fe0954d6599705443764475f8ca69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Fri, 12 Apr 2024 11:23:18 +0200 Subject: [PATCH 14/21] Remove compiler plugin from examples --- examples/aws-eks/project.scala | 1 - examples/aws-s3-folder/project.scala | 1 - examples/aws-secrets-manager/project.scala | 1 - examples/docker-multi-container-app/infra/project.scala | 1 - examples/gcp-cloudrun/infra/project.scala | 1 - examples/gcp-static-page/project.scala | 1 - examples/kubernetes-nginx/project.scala | 1 - experimental/project.scala | 1 - templates/aws/project.scala | 1 - templates/default/project.scala | 1 - templates/gcp/project.scala | 1 - templates/kubernetes/project.scala | 1 - 12 files changed, 12 deletions(-) diff --git a/examples/aws-eks/project.scala b/examples/aws-eks/project.scala index 67052b82..c0f8d801 100644 --- a/examples/aws-eks/project.scala +++ b/examples/aws-eks/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-awsx:2.6.0-core.0.3-SNAPSHOT" diff --git a/examples/aws-s3-folder/project.scala b/examples/aws-s3-folder/project.scala index ccbcd4f0..5e90756d 100644 --- a/examples/aws-s3-folder/project.scala +++ b/examples/aws-s3-folder/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" diff --git a/examples/aws-secrets-manager/project.scala b/examples/aws-secrets-manager/project.scala index ccbcd4f0..5e90756d 100644 --- a/examples/aws-secrets-manager/project.scala +++ b/examples/aws-secrets-manager/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" diff --git a/examples/docker-multi-container-app/infra/project.scala b/examples/docker-multi-container-app/infra/project.scala index 816fd605..597c5807 100644 --- a/examples/docker-multi-container-app/infra/project.scala +++ b/examples/docker-multi-container-app/infra/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3-SNAPSHOT" diff --git a/examples/gcp-cloudrun/infra/project.scala b/examples/gcp-cloudrun/infra/project.scala index 2de654fc..29f4451f 100644 --- a/examples/gcp-cloudrun/infra/project.scala +++ b/examples/gcp-cloudrun/infra/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" //> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3-SNAPSHOT" diff --git a/examples/gcp-static-page/project.scala b/examples/gcp-static-page/project.scala index a0e42c60..9777a636 100644 --- a/examples/gcp-static-page/project.scala +++ b/examples/gcp-static-page/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" diff --git a/examples/kubernetes-nginx/project.scala b/examples/kubernetes-nginx/project.scala index 5444f00e..12a9b73f 100644 --- a/examples/kubernetes-nginx/project.scala +++ b/examples/kubernetes-nginx/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" diff --git a/experimental/project.scala b/experimental/project.scala index 2c81b14b..1d94ba4f 100644 --- a/experimental/project.scala +++ b/experimental/project.scala @@ -1,5 +1,4 @@ //> using scala "3.3.1" -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" //> using dep "io.github.iltotore::iron:2.5.0" diff --git a/templates/aws/project.scala b/templates/aws/project.scala index ccbcd4f0..5e90756d 100644 --- a/templates/aws/project.scala +++ b/templates/aws/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" diff --git a/templates/default/project.scala b/templates/default/project.scala index 9e56a780..77ad3992 100644 --- a/templates/default/project.scala +++ b/templates/default/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-random:4.16.0-core.0.3-SNAPSHOT" diff --git a/templates/gcp/project.scala b/templates/gcp/project.scala index a0e42c60..9777a636 100644 --- a/templates/gcp/project.scala +++ b/templates/gcp/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" diff --git a/templates/kubernetes/project.scala b/templates/kubernetes/project.scala index 5444f00e..12a9b73f 100644 --- a/templates/kubernetes/project.scala +++ b/templates/kubernetes/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" From ff57a492265f3ae6b9331a4cd86d41b9d46ae9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Fri, 12 Apr 2024 11:24:42 +0200 Subject: [PATCH 15/21] Remove redundant -encoding option --- besom-cats/project.scala | 3 +-- besom-json/project.scala | 2 +- besom-zio/project.scala | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/besom-cats/project.scala b/besom-cats/project.scala index c106a8fb..150e8af4 100644 --- a/besom-cats/project.scala +++ b/besom-cats/project.scala @@ -1,12 +1,11 @@ //> using scala "3.3.1" -//> using options "-java-output-version:11" "-encoding:utf-8", "-Ykind-projector:underscores" +//> using options "-java-output-version:11", "-Ykind-projector:underscores" //> using options "-deprecation", "-feature" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "org.typelevel::cats-effect:3.3.14" //> using test.dep "org.scalameta::munit:1.0.0-M10" - //> using publish.name "besom-cats" //> using publish.organization "org.virtuslab" //> using publish.url "https://github.com/VirtusLab/besom" diff --git a/besom-json/project.scala b/besom-json/project.scala index ed023c1f..d2d34acc 100644 --- a/besom-json/project.scala +++ b/besom-json/project.scala @@ -1,5 +1,5 @@ //> using scala "3.3.1" -//> using options "-java-output-version:11" "-encoding:utf-8" +//> using options "-java-output-version:11" //> using options "-deprecation", "-feature", "-Werror", "-Wunused:all" //> using test.resourceDir src/test/resources diff --git a/besom-zio/project.scala b/besom-zio/project.scala index 2782e7a3..72c7232b 100644 --- a/besom-zio/project.scala +++ b/besom-zio/project.scala @@ -1,12 +1,11 @@ //> using scala "3.3.1" -//> using options "-java-output-version:11" "-encoding:utf-8", "-Ykind-projector:underscores" +//> using options "-java-output-version:11", "-Ykind-projector:underscores" //> using options "-deprecation", "-feature" //> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" //> using dep "dev.zio::zio:2.0.17" //> using test.dep "org.scalameta::munit:1.0.0-M10" - //> using publish.name "besom-zio" //> using publish.organization "org.virtuslab" //> using publish.url "https://github.com/VirtusLab/besom" From fcc9df0892c8894591d50d5250cd99c087ce42d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Tue, 16 Apr 2024 10:20:10 +0200 Subject: [PATCH 16/21] Bump version to 0.3.0 --- CONTRIBUTING.md | 30 +++++++++---- README.md | 14 +++--- besom-cats/project.scala | 3 +- besom-zio/project.scala | 3 +- examples/aws-eks/project.scala | 7 ++- examples/aws-s3-folder/project.scala | 5 +-- examples/aws-secrets-manager/project.scala | 5 +-- examples/aws-webserver/project.scala | 9 ++-- .../infra/project.scala | 5 +-- examples/gcp-cloudrun/infra/project.scala | 7 ++- examples/gcp-static-page/project.scala | 5 +-- .../components/project.scala | 5 +-- .../kubernetes-guestbook/simple/project.scala | 5 +-- examples/kubernetes-nginx/project.scala | 5 +-- experimental/project.scala | 5 +-- integration-tests/project.scala | 5 +-- .../cats-purrl-example/project.scala | 8 ++-- .../resources/compiler-plugin/project.scala | 5 +-- .../resources/config-example/project.scala | 4 +- .../executors/gradle/build.gradle.kts | 2 +- .../resources/executors/maven/pom.xml | 4 +- .../resources/executors/sbt/build.sbt | 2 +- .../executors/scala-cli/project.scala | 6 +-- .../kubernetes-secrets/project.scala | 6 +-- .../resources/logger-example/project.scala | 4 +- .../memoization/source-stack/project.scala | 6 +-- .../memoization/target-stack/project.scala | 4 +- .../resources/random-example/project.scala | 6 +-- .../references/source-stack/project.scala | 6 +-- .../references/target-stack/project.scala | 4 +- .../resources/tls-example/project.scala | 6 +-- .../resources/zio-tls-example/project.scala | 8 ++-- language-plugin/bootstrap/project.scala | 3 +- scripts/project.scala | 3 +- templates/aws/project.scala | 5 +-- templates/default/project.scala | 5 +-- templates/gcp/project.scala | 5 +-- templates/kubernetes/project.scala | 5 +-- version.txt | 2 +- website/blog/2024-03-01-0.2.x-release.md | 2 +- website/docs/changelog.md | 44 +++++++++---------- website/docs/examples.md | 2 +- website/docs/getting_started.md | 4 +- website/docs/templates.md | 2 +- 44 files changed, 136 insertions(+), 145 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ede02473..6e60ca01 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -200,21 +200,27 @@ just publish-local-all just test-all ``` -#### Bump Besom version (skip for `SNAPSHOT` re-release) +#### Publish fresh packages locally -To bump Besom version in all `project.scala` and `version.txt` files: +It is recommended to use `just power-wash` before publishing a release: ```bash -export GITHUB_TOKEN=$(gh auth token) -just cli version bump X.Y.Z +just power-wash ``` -#### Publish fresh packages locally +Make sure the repository is clean and there are no uncommitted changes: -It is recommended to use `just power-wash` before publishing a release: +```bash +git status -s | grep -v -q '^\s*M' || echo "STOP: DIRTY GIT REPO" +``` + +#### Bump Besom version (skip for `SNAPSHOT` re-release) + +To bump Besom version in all `project.scala` and `version.txt` files: ```bash -just power-wash +export GITHUB_TOKEN=$(gh auth token) +just cli version bump X.Y.Z ``` Publish the new version of SDKs locally to test and provide fresh dependencies for scripts: @@ -236,6 +242,12 @@ just cli version update Manually update versions in all other places, specifically documentation and website, using find&replace. +Look for: +- **DO NOT** change historical versions in `CHANGELOG.md` by mistake +- `X.Y.Z` - the besom version +- `core.X.Y` - core part of the provider version +- update the provider versions in `README.md` + ##### Create release branch ```bash @@ -270,7 +282,9 @@ Publishing to maven requires: - `PGP_KEY_ID` - the signing key id (`gpg --list-keys` or `gpg --show-keys`) - `PGP_PASSWORD` - the signing key passphrase -Publish main SDK packages to Maven +**Wait for the CI** to pass `Besom build and test / build` before proceeding. + +Publish main SDK packages to Maven: ```bash just publish-maven-all diff --git a/README.md b/README.md index d5f84fc4..bef850a6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ using the Scala programming language. Scala support is currently in **Public Bet * **[Besom Docs](https://virtuslab.github.io/besom/)**: Learn about Besom concepts, follow user-guides, and consult the reference documentation. -* **[Examples](https://github.com/VirtusLab/besom/tree/v0.2.2/examples)**: Browse Scala examples across many clouds and scenarios including containers, serverless, +* **[Examples](https://github.com/VirtusLab/besom/tree/v0.3.0/examples)**: Browse Scala examples across many clouds and scenarios including containers, serverless, and infrastructure. ## Getting Started @@ -44,7 +44,7 @@ using the Scala programming language. Scala support is currently in **Public Bet To install the latest Scala Language Plugin release, run the following: ```bash - pulumi plugin install language scala 0.2.2 --server github://api.github.com/VirtusLab/besom + pulumi plugin install language scala 0.3.0 --server github://api.github.com/VirtusLab/besom ``` 4. **Create a new project**: @@ -58,7 +58,7 @@ using the Scala programming language. Scala support is currently in **Public Bet mkdir besom-demo && cd besom-demo ``` ```bash - pulumi new https://github.com/VirtusLab/besom/tree/v0.2.2/templates/aws + pulumi new https://github.com/VirtusLab/besom/tree/v0.3.0/templates/aws ``` 5. **Deploy to the Cloud**: @@ -94,7 +94,7 @@ using the Scala programming language. Scala support is currently in **Public Bet To learn more, head over to [virtuslab.github.io/besom](https://virtuslab.github.io/besom/) for much more information, including [tutorial](https://virtuslab.github.io/besom/docs/tutorial), -[examples](https://github.com/VirtusLab/besom/tree/v0.2.2/examples), +[examples](https://github.com/VirtusLab/besom/tree/v0.3.0/examples), and [architecture and programming model concepts](https://virtuslab.github.io/besom/docs/architecture). ## Explaining the project structure @@ -109,9 +109,9 @@ Resources created in `Pulumi.run { ... }` block will be created by Pulumi. A simple example using Scala CLI: ```scala //> using scala "3.3.1" -//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.2" -//> using dep "org.virtuslab::besom-core:0.2.2" -//> using dep "org.virtuslab::besom-aws:6.23.0-core.0.2" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-aws:6.31.0-core.0.3" import besom.* import besom.api.aws diff --git a/besom-cats/project.scala b/besom-cats/project.scala index 150e8af4..8131fbe9 100644 --- a/besom-cats/project.scala +++ b/besom-cats/project.scala @@ -2,7 +2,7 @@ //> using options "-java-output-version:11", "-Ykind-projector:underscores" //> using options "-deprecation", "-feature" -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" //> using dep "org.typelevel::cats-effect:3.3.14" //> using test.dep "org.scalameta::munit:1.0.0-M10" @@ -15,4 +15,3 @@ //> using publish.developer "lbialy|Łukasz Biały|https://github.com/lbialy" //> using publish.developer "prolativ|Michał Pałka|https://github.com/prolativ" //> using publish.developer "KacperFKorban|Kacper Korban|https://github.com/KacperFKorban" -//> using repository sonatype:snapshots diff --git a/besom-zio/project.scala b/besom-zio/project.scala index 72c7232b..a6413649 100644 --- a/besom-zio/project.scala +++ b/besom-zio/project.scala @@ -2,7 +2,7 @@ //> using options "-java-output-version:11", "-Ykind-projector:underscores" //> using options "-deprecation", "-feature" -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" //> using dep "dev.zio::zio:2.0.17" //> using test.dep "org.scalameta::munit:1.0.0-M10" @@ -15,4 +15,3 @@ //> using publish.developer "lbialy|Łukasz Biały|https://github.com/lbialy" //> using publish.developer "prolativ|Michał Pałka|https://github.com/prolativ" //> using publish.developer "KacperFKorban|Kacper Korban|https://github.com/KacperFKorban" -//> using repository sonatype:snapshots diff --git a/examples/aws-eks/project.scala b/examples/aws-eks/project.scala index c0f8d801..2d96f468 100644 --- a/examples/aws-eks/project.scala +++ b/examples/aws-eks/project.scala @@ -1,8 +1,7 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-awsx:2.6.0-core.0.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-eks:2.3.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-awsx:2.7.0-core.0.3" +//> using dep "org.virtuslab::besom-eks:2.3.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/examples/aws-s3-folder/project.scala b/examples/aws-s3-folder/project.scala index 5e90756d..397c763e 100644 --- a/examples/aws-s3-folder/project.scala +++ b/examples/aws-s3-folder/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-aws:6.31.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/examples/aws-secrets-manager/project.scala b/examples/aws-secrets-manager/project.scala index 5e90756d..397c763e 100644 --- a/examples/aws-secrets-manager/project.scala +++ b/examples/aws-secrets-manager/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-aws:6.31.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/examples/aws-webserver/project.scala b/examples/aws-webserver/project.scala index 3602af9a..4dadefab 100644 --- a/examples/aws-webserver/project.scala +++ b/examples/aws-webserver/project.scala @@ -1,8 +1,7 @@ //> using scala 3.3.1 //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT -//> using dep org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 +//> using dep org.virtuslab::besom-aws:6.31.0-core.0.3 +//> using dep org.virtuslab::besom-tls:5.0.2-core.0.3 -//> using repository sonatype:snapshots diff --git a/examples/docker-multi-container-app/infra/project.scala b/examples/docker-multi-container-app/infra/project.scala index 597c5807..60680a87 100644 --- a/examples/docker-multi-container-app/infra/project.scala +++ b/examples/docker-multi-container-app/infra/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3" -//> using repository sonatype:snapshots diff --git a/examples/gcp-cloudrun/infra/project.scala b/examples/gcp-cloudrun/infra/project.scala index 29f4451f..a19114a1 100644 --- a/examples/gcp-cloudrun/infra/project.scala +++ b/examples/gcp-cloudrun/infra/project.scala @@ -1,9 +1,8 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" -//> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3" +//> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3" //> using exclude "app/*" -//> using repository sonatype:snapshots diff --git a/examples/gcp-static-page/project.scala b/examples/gcp-static-page/project.scala index 9777a636..0be3a777 100644 --- a/examples/gcp-static-page/project.scala +++ b/examples/gcp-static-page/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/examples/kubernetes-guestbook/components/project.scala b/examples/kubernetes-guestbook/components/project.scala index a058134f..167880c0 100644 --- a/examples/kubernetes-guestbook/components/project.scala +++ b/examples/kubernetes-guestbook/components/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-kubernetes:4.10.0-core.0.3" //> using exclude "simple/*" -//> using repository sonatype:snapshots diff --git a/examples/kubernetes-guestbook/simple/project.scala b/examples/kubernetes-guestbook/simple/project.scala index eb14b2b3..94e16c4d 100644 --- a/examples/kubernetes-guestbook/simple/project.scala +++ b/examples/kubernetes-guestbook/simple/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-kubernetes:4.10.0-core.0.3" //> using exclude "components/*" -//> using repository sonatype:snapshots diff --git a/examples/kubernetes-nginx/project.scala b/examples/kubernetes-nginx/project.scala index 12a9b73f..3e38aefe 100644 --- a/examples/kubernetes-nginx/project.scala +++ b/examples/kubernetes-nginx/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-kubernetes:4.10.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/experimental/project.scala b/experimental/project.scala index 1d94ba4f..863614f9 100644 --- a/experimental/project.scala +++ b/experimental/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-kubernetes:4.10.0-core.0.3" //> using dep "io.github.iltotore::iron:2.5.0" -//> using repository sonatype:snapshots diff --git a/integration-tests/project.scala b/integration-tests/project.scala index 913e0bf3..eb755f08 100644 --- a/integration-tests/project.scala +++ b/integration-tests/project.scala @@ -2,8 +2,7 @@ //> using exclude "*/resources/*" -//> using dep org.virtuslab::besom-codegen:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-scripts:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-codegen:0.3.0 +//> using dep org.virtuslab::besom-scripts:0.3.0 //> using dep org.scalameta::munit::1.0.0-M10 -//> using repository sonatype:snapshots diff --git a/integration-tests/resources/cats-purrl-example/project.scala b/integration-tests/resources/cats-purrl-example/project.scala index bf29cd9f..103a2509 100644 --- a/integration-tests/resources/cats-purrl-example/project.scala +++ b/integration-tests/resources/cats-purrl-example/project.scala @@ -1,8 +1,8 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots -//> using dep org.virtuslab::besom-cats:0.3.0-SNAPSHOT -//> using dep "org.virtuslab::besom-purrl:0.5.0-core.0.3-SNAPSHOT" +//> using dep org.virtuslab::besom-cats:0.3.0 +//> using dep "org.virtuslab::besom-purrl:0.5.0-core.0.3" diff --git a/integration-tests/resources/compiler-plugin/project.scala b/integration-tests/resources/compiler-plugin/project.scala index da394f9b..320f5ded 100644 --- a/integration-tests/resources/compiler-plugin/project.scala +++ b/integration-tests/resources/compiler-plugin/project.scala @@ -1,6 +1,5 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 -//> using repository sonatype:snapshots diff --git a/integration-tests/resources/config-example/project.scala b/integration-tests/resources/config-example/project.scala index da394f9b..97d3e30f 100644 --- a/integration-tests/resources/config-example/project.scala +++ b/integration-tests/resources/config-example/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots diff --git a/integration-tests/resources/executors/gradle/build.gradle.kts b/integration-tests/resources/executors/gradle/build.gradle.kts index 2010853f..70e7e5b5 100644 --- a/integration-tests/resources/executors/gradle/build.gradle.kts +++ b/integration-tests/resources/executors/gradle/build.gradle.kts @@ -10,7 +10,7 @@ repositories { dependencies { implementation("org.scala-lang:scala3-library_3:3.3.1") - implementation("org.virtuslab:besom-core_3:0.3.0-SNAPSHOT") + implementation("org.virtuslab:besom-core_3:0.3.0") implementation("org.virtuslab:besom-fake-standard-resource_3:1.2.3-TEST") implementation("org.virtuslab:besom-fake-external-resource_3:2.3.4-TEST") if (project.hasProperty("besomBootstrapJar")) runtimeOnly(files(project.property("besomBootstrapJar") as String)) diff --git a/integration-tests/resources/executors/maven/pom.xml b/integration-tests/resources/executors/maven/pom.xml index 543780b4..508e47b7 100644 --- a/integration-tests/resources/executors/maven/pom.xml +++ b/integration-tests/resources/executors/maven/pom.xml @@ -26,7 +26,7 @@ org.virtuslab besom-bootstrap_3 - 0.3.0-SNAPSHOT + 0.3.0 system ${besomBootstrapJar} @@ -43,7 +43,7 @@ org.virtuslab besom-core_3 - 0.3.0-SNAPSHOT + 0.3.0 org.virtuslab diff --git a/integration-tests/resources/executors/sbt/build.sbt b/integration-tests/resources/executors/sbt/build.sbt index 0192e0d5..ed44f1cf 100644 --- a/integration-tests/resources/executors/sbt/build.sbt +++ b/integration-tests/resources/executors/sbt/build.sbt @@ -5,7 +5,7 @@ lazy val root = project scalacOptions ++= Seq("-java-output-version", "11"), javacOptions in (Compile, compile) ++= Seq("-source", "11", "-target", "11"), libraryDependencies ++= Seq( - "org.virtuslab" %% "besom-core" % "0.3.0-SNAPSHOT", + "org.virtuslab" %% "besom-core" % "0.3.0", "org.virtuslab" %% "besom-fake-standard-resource" % "1.2.3-TEST", "org.virtuslab" %% "besom-fake-external-resource" % "2.3.4-TEST" ) diff --git a/integration-tests/resources/executors/scala-cli/project.scala b/integration-tests/resources/executors/scala-cli/project.scala index c8d50b5e..e0c55e1d 100644 --- a/integration-tests/resources/executors/scala-cli/project.scala +++ b/integration-tests/resources/executors/scala-cli/project.scala @@ -1,8 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" +//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0" +//> using dep "org.virtuslab::besom-core:0.3.0" //> using dep "org.virtuslab::besom-fake-standard-resource:1.2.3-TEST" //> using dep "org.virtuslab::besom-fake-external-resource:2.3.4-TEST" - -//> using repository sonatype:snapshots diff --git a/integration-tests/resources/kubernetes-secrets/project.scala b/integration-tests/resources/kubernetes-secrets/project.scala index 682fe2a4..b53b2483 100644 --- a/integration-tests/resources/kubernetes-secrets/project.scala +++ b/integration-tests/resources/kubernetes-secrets/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-kubernetes:4.10.0-core.0.3" diff --git a/integration-tests/resources/logger-example/project.scala b/integration-tests/resources/logger-example/project.scala index da394f9b..97d3e30f 100644 --- a/integration-tests/resources/logger-example/project.scala +++ b/integration-tests/resources/logger-example/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots diff --git a/integration-tests/resources/memoization/source-stack/project.scala b/integration-tests/resources/memoization/source-stack/project.scala index 90501bb5..b27a9a36 100644 --- a/integration-tests/resources/memoization/source-stack/project.scala +++ b/integration-tests/resources/memoization/source-stack/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3" diff --git a/integration-tests/resources/memoization/target-stack/project.scala b/integration-tests/resources/memoization/target-stack/project.scala index da394f9b..97d3e30f 100644 --- a/integration-tests/resources/memoization/target-stack/project.scala +++ b/integration-tests/resources/memoization/target-stack/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots diff --git a/integration-tests/resources/random-example/project.scala b/integration-tests/resources/random-example/project.scala index c36f21c2..4626aef0 100644 --- a/integration-tests/resources/random-example/project.scala +++ b/integration-tests/resources/random-example/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-random:4.16.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-random:4.16.0-core.0.3" diff --git a/integration-tests/resources/references/source-stack/project.scala b/integration-tests/resources/references/source-stack/project.scala index 90501bb5..b27a9a36 100644 --- a/integration-tests/resources/references/source-stack/project.scala +++ b/integration-tests/resources/references/source-stack/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3" diff --git a/integration-tests/resources/references/target-stack/project.scala b/integration-tests/resources/references/target-stack/project.scala index da394f9b..97d3e30f 100644 --- a/integration-tests/resources/references/target-stack/project.scala +++ b/integration-tests/resources/references/target-stack/project.scala @@ -1,6 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots diff --git a/integration-tests/resources/tls-example/project.scala b/integration-tests/resources/tls-example/project.scala index 90501bb5..b27a9a36 100644 --- a/integration-tests/resources/tls-example/project.scala +++ b/integration-tests/resources/tls-example/project.scala @@ -1,7 +1,7 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots -//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3" diff --git a/integration-tests/resources/zio-tls-example/project.scala b/integration-tests/resources/zio-tls-example/project.scala index c038eab7..64604b10 100644 --- a/integration-tests/resources/zio-tls-example/project.scala +++ b/integration-tests/resources/zio-tls-example/project.scala @@ -1,8 +1,8 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT -//> using dep org.virtuslab::besom-core:0.3.0-SNAPSHOT +//> using plugin org.virtuslab::besom-compiler-plugin:0.3.0 +//> using dep org.virtuslab::besom-core:0.3.0 //> using repository sonatype:snapshots -//> using dep org.virtuslab::besom-zio:0.3.0-SNAPSHOT -//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3-SNAPSHOT" +//> using dep org.virtuslab::besom-zio:0.3.0 +//> using dep "org.virtuslab::besom-tls:5.0.2-core.0.3" diff --git a/language-plugin/bootstrap/project.scala b/language-plugin/bootstrap/project.scala index 8500a881..41cb842f 100644 --- a/language-plugin/bootstrap/project.scala +++ b/language-plugin/bootstrap/project.scala @@ -1,7 +1,6 @@ //> using scala 3.3.1 //> using options -java-output-version:11 -//> using dep org.virtuslab::besom-json:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-json:0.3.0 //> using dep io.github.classgraph:classgraph:4.8.165 -//> using repository sonatype:snapshots diff --git a/scripts/project.scala b/scripts/project.scala index dd2a9004..0d82539f 100644 --- a/scripts/project.scala +++ b/scripts/project.scala @@ -9,10 +9,9 @@ //> using dep org.scoverage::scalac-scoverage-serializer:2.0.11 //> using dep org.virtuslab::scala-yaml:0.0.8 //> using dep io.get-coursier:coursier_2.13:2.1.9 -//> using dep org.virtuslab::besom-codegen:0.3.0-SNAPSHOT +//> using dep org.virtuslab::besom-codegen:0.3.0 //> using test.dep org.scalameta::munit::1.0.0-M10 -//> using repository sonatype:snapshots //> using publish.name "besom-scripts" //> using publish.organization "org.virtuslab" diff --git a/templates/aws/project.scala b/templates/aws/project.scala index 5e90756d..397c763e 100644 --- a/templates/aws/project.scala +++ b/templates/aws/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-aws:6.29.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-aws:6.31.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/templates/default/project.scala b/templates/default/project.scala index 77ad3992..8e0e81be 100644 --- a/templates/default/project.scala +++ b/templates/default/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-random:4.16.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-random:4.16.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/templates/gcp/project.scala b/templates/gcp/project.scala index 9777a636..0be3a777 100644 --- a/templates/gcp/project.scala +++ b/templates/gcp/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-gcp:7.18.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/templates/kubernetes/project.scala b/templates/kubernetes/project.scala index 12a9b73f..3e38aefe 100644 --- a/templates/kubernetes/project.scala +++ b/templates/kubernetes/project.scala @@ -1,6 +1,5 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-kubernetes:4.9.1-core.0.3-SNAPSHOT" +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-kubernetes:4.10.0-core.0.3" -//> using repository sonatype:snapshots diff --git a/version.txt b/version.txt index e09dd941..9325c3cc 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.0-SNAPSHOT \ No newline at end of file +0.3.0 \ No newline at end of file diff --git a/website/blog/2024-03-01-0.2.x-release.md b/website/blog/2024-03-01-0.2.x-release.md index 12240e59..6584ee0e 100644 --- a/website/blog/2024-03-01-0.2.x-release.md +++ b/website/blog/2024-03-01-0.2.x-release.md @@ -163,7 +163,7 @@ This will launch project builder, ask us some basic questions about how the proj To start we will need to add docker support for besom so that we can push our application's image to Google Container Registry (GCR). To do that we need to put these lines into `project.scala`: ```scala -//> using dep "org.virtuslab::besom-docker:4.5.1-core.0.2" +//> using dep "org.virtuslab::besom-docker:4.5.3-core.0.3" ``` Since we want Besom to manage our image building we won't be able to benefit from `scala-cli`'s built-in Docker packaging capabilities but that's actually fine because we would like our Cloud Run app to have the smallest possible footprint possible. To do that we will need to leverage another application packaging capability of `scala-cli` - that of GraalVM native-image building. Besom's Docker integration expects us to provide a `Dockerfile` that will describe how to create the image and that's exactly what we're going to do by putting this content into `./app/Dockerfile`: diff --git a/website/docs/changelog.md b/website/docs/changelog.md index 565071ed..b78e2931 100644 --- a/website/docs/changelog.md +++ b/website/docs/changelog.md @@ -2,10 +2,10 @@ title: Changelog --- -0.3.0 (08-04-2024) +0.3.0 (16-04-2024) --- -## API Changes and New Features +### API Changes and New Features * Added new `besom.json` interpolation API. Now this snippet from our tutorial: ```scala @@ -69,57 +69,57 @@ assert(color.toJson.convertTo[Color] == color) assert(json.parseJson.convertTo[Color] == color) ``` -## Bug Fixes +### Bug Fixes * fixed infinite loop in encoders [#407](https://github.com/VirtusLab/besom/issues/407) when a recursive type is encountered -* fixed cause passing in AggregateException to improve debugging of decoders [#426](https://github.com/VirtusLab/besom/issues/426) -* fixed Pulumi side effects memoization issues in Component API [#429]https://github.com/VirtusLab/besom/pull/429 +* fixed cause passing in `AggregateException` to improve debugging of decoders [#426](https://github.com/VirtusLab/besom/issues/426) +* fixed Pulumi side effects memoization issues in Component API [#429](https://github.com/VirtusLab/besom/pull/429) * fixed traverse problem caused by export bug in compiler with a temporary workaround [#430](https://github.com/VirtusLab/besom/issues/430) -## Other Changes +### Other Changes * custom timeouts have scaladocs now [#419](https://github.com/VirtusLab/besom/pull/419) -* overhauled serde layer with refied outputs implemented to improve parity with upstream Pulumi engine [#414](https://github.com/VirtusLab/besom/pull/414) +* overhauled serde layer with refined outputs implemented to improve parity with upstream Pulumi engine [#414](https://github.com/VirtusLab/besom/pull/414) * StackReferences are now documented [#428](https://github.com/VirtusLab/besom/pull/428) * updated AWS EKS hello world example [#399](https://github.com/VirtusLab/besom/pull/399/files) * Component API now disallows returning component instances wrapped in Outputs to prevent users from dry run issues [#441](https://github.com/VirtusLab/besom/pull/441) -* added parSequence parSequence and parTraverse combinators on Output [#440](https://github.com/VirtusLab/besom/pull/440) -* added Output.when combinator [#439](https://github.com/VirtusLab/besom/pull/439) +* added `parSequence` and `parTraverse` combinators on `Output` [#440](https://github.com/VirtusLab/besom/pull/440) +* added `Output.when` combinator [#439](https://github.com/VirtusLab/besom/pull/439) * improved compilation errors around `Output.eval` and `Output#flatMap` [#443](https://github.com/VirtusLab/besom/pull/443) -* all Output combinators have scaladocs now [#445](https://github.com/VirtusLab/besom/pull/445) +* all `Output` combinators have scaladocs now [#445](https://github.com/VirtusLab/besom/pull/445) * added extension-based combinators for `Output[Option[A]]`, `Output[List[A]]` etc [#445](https://github.com/VirtusLab/besom/pull/445) -* added support for overlays (package-specific extensions) in besom codegen, this opens a way for support of Helm, magic lambdas and other advanced features [#402](https://github.com/VirtusLab/besom/pull/402) +* added support for overlays (package-specific extensions) in besom `codegen`, this opens a way for support of Helm, magic lambdas and other advanced features [#402](https://github.com/VirtusLab/besom/pull/402) -**Full Changelog**: https://github.com/VirtusLab/besom/compare/v0.2.2...v0.3.0 +**Full Changelog**: [GitHub (v0.2.2...v0.3.0)](https://github.com/VirtusLab/besom/compare/v0.2.2...v0.3.0) 0.2.2 (22-02-2024) --- -## Bug Fixes +### Bug Fixes * fixed component argument serialization issue [398](https://github.com/VirtusLab/besom/pull/398) -## Other Changes +### Other Changes * added Kubernetes guestbook example [395](https://github.com/VirtusLab/besom/pull/395) -**Full Changelog**: https://github.com/VirtusLab/besom/compare/v0.2.1...v0.2.2 +**Full Changelog**: [GitHub (v0.2.1...v0.2.2)](https://github.com/VirtusLab/besom/compare/v0.2.1...v0.2.2) 0.2.1 (15-02-2024) --- -## Bug Fixes +### Bug Fixes * Fix URL validation to allow for kubernetes types [#385](https://github.com/VirtusLab/besom/pull/385) * Loosen up and fix URN parsing [#389](https://github.com/VirtusLab/besom/pull/389) * Fix serializer now skips fields with null value secrets [#386](https://github.com/VirtusLab/besom/pull/386) -* Full changelog is available at [GitHub (v0.2.0...v0.2.1)](https://github.com/VirtusLab/besom/compare/v0.2.0...v0.2.1) +**Full Changelog**: [GitHub (v0.2.0...v0.2.1)](https://github.com/VirtusLab/besom/compare/v0.2.0...v0.2.1) 0.2.0 (08-02-2024) --- -## API Changes +### API Changes * Changed the type of main `Pulumi.run` function from `Context ?=> Output[Exports]` (a [context function](https://docs.scala-lang.org/scala3/reference/contextual/context-functions.html) providing `besom.Context` instance implicitly in its scope and expecting `Output[Exports]` as returned value) to `Context ?=> Stack`. This change has one core @@ -151,7 +151,7 @@ and also adding a helpful error message when a key is missing [#204](https://git * Overhauled `ResourceOptions` [#355](https://github.com/VirtusLab/besom/pull/355) -## New Features +### New Features * added support for Gradle and Maven to the Besom Scala language host [#303](https://github.com/VirtusLab/besom/issues/303) @@ -234,7 +234,7 @@ or deserialize to an object (`config.getObject` or `config.requireObject`) [#207 - `"string".toNonEmptyOutput: Output[NonEmptyString]` - safe, if the string is empty the returned Output will be failed - `Output("string").toNonEmptyOutput: Output[NonEmptyString]` - safe, if the string inside of the Output is empty the returned Output will be failed -## Bug Fixes +### Bug Fixes * fixed logging via Pulumi RPC and added user-level MDC, now logs are properly displayed in the Pulumi console [#199](https://github.com/VirtusLab/besom/issues/199) * fixed failing gRPC shutdown in our core SDK by correcting the lifecycle handling, now the SDK properly shuts down [#228](https://github.com/VirtusLab/besom/issues/228) @@ -250,11 +250,11 @@ or deserialize to an object (`config.getObject` or `config.requireObject`) [#207 * fixed failing code generation when clashing names are present in the schema, now the generator properly handles clashing names [#275](https://github.com/VirtusLab/besom/pull/275) * fixed failing code generation schema deserialization for complex types used as underlying types of named types [#282](https://github.com/VirtusLab/besom/pull/282) -## Other Changes +### Other Changes * added more [examples](https://github.com/VirtusLab/besom/blob/release/v0.2.0/examples/README.md) to the Besom repository * introduce schema-driven integration tests for `codegen` fed from upstream Pulumi to improve reliability of the code generator * many internal improvements and refactorings to the codebase to improve the overall quality of the SDK and its maintainability -* Full changelog is available at [GitHub (v0.1.0...v0.2.0)](https://github.com/VirtusLab/besom/compare/v0.1.0...v0.2.0) +**Full Changelog**: [GitHub (v0.1.0...v0.2.0)](https://github.com/VirtusLab/besom/compare/v0.1.0...v0.2.0) diff --git a/website/docs/examples.md b/website/docs/examples.md index c3085688..80f067fb 100644 --- a/website/docs/examples.md +++ b/website/docs/examples.md @@ -2,4 +2,4 @@ title: Examples --- -All examples are available in [Besom GitHub repository](https://github.com/VirtusLab/besom/tree/v0.2.2/examples). \ No newline at end of file +All examples are available in [Besom GitHub repository](https://github.com/VirtusLab/besom/tree/v0.3.0/examples). \ No newline at end of file diff --git a/website/docs/getting_started.md b/website/docs/getting_started.md index 425c5b1a..82d960f4 100644 --- a/website/docs/getting_started.md +++ b/website/docs/getting_started.md @@ -29,7 +29,7 @@ To start your adventure with infrastructure-as-code with Scala follow these step To install the latest Scala Language Plugin release, run the following: ```bash - pulumi plugin install language scala 0.2.2 --server github://api.github.com/VirtusLab/besom + pulumi plugin install language scala 0.3.0 --server github://api.github.com/VirtusLab/besom ``` 4. **Create a new project**: @@ -43,7 +43,7 @@ To start your adventure with infrastructure-as-code with Scala follow these step mkdir besom-demo && cd besom-demo ``` ```bash - pulumi new https://github.com/VirtusLab/besom/tree/v0.2.2/templates/aws + pulumi new https://github.com/VirtusLab/besom/tree/v0.3.0/templates/aws ``` 5. **Deploy to the Cloud**: diff --git a/website/docs/templates.md b/website/docs/templates.md index 844485ac..24183a51 100644 --- a/website/docs/templates.md +++ b/website/docs/templates.md @@ -2,4 +2,4 @@ title: Templates --- -All templates are available in [Besom GitHub repository](https://github.com/VirtusLab/besom/tree/v0.2.2/templates). \ No newline at end of file +All templates are available in [Besom GitHub repository](https://github.com/VirtusLab/besom/tree/v0.3.0/templates). \ No newline at end of file From f6cf7d6175fb7b3d89f0c56a6e3a3f24fda01cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Tue, 16 Apr 2024 12:13:21 +0200 Subject: [PATCH 17/21] Fix project.scala files --- codegen/project.scala | 4 +++- core/project.scala | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codegen/project.scala b/codegen/project.scala index 40022af9..c574239b 100644 --- a/codegen/project.scala +++ b/codegen/project.scala @@ -1,11 +1,13 @@ //> using scala 3.3.1 -//> using options -release:11 -deprecation -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -language:noAutoTupling +//> using options -release:11 -deprecation -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement //> using dep org.scalameta:scalameta_2.13:4.8.15 //> using dep com.lihaoyi::upickle:3.1.4 //> using dep com.lihaoyi::os-lib:0.9.3 //> using test.dep org.scalameta::munit::1.0.0-M10 +//> using exclude "resources/*" + //> using publish.name "besom-codegen" //> using publish.organization "org.virtuslab" //> using publish.url "https://github.com/VirtusLab/besom" diff --git a/core/project.scala b/core/project.scala index 1d008d85..3ee47285 100644 --- a/core/project.scala +++ b/core/project.scala @@ -1,8 +1,8 @@ //> using scala "3.3.1" //> using options "-java-output-version:11", "-Ysafe-init", "-Xmax-inlines:64" -//> using options "-Werror", "-Wunused:all", "-deprecation", "-feature", -language:noAutoTupling +//> using options "-Werror", "-Wunused:all", "-deprecation", "-feature" -//> using dep "org.virtuslab::besom-json:0.3.0-SNAPSHOT" +//> using dep "org.virtuslab::besom-json:0.3.0" //> using dep "com.lihaoyi::sourcecode:0.3.1" //> using dep "com.google.protobuf:protobuf-java-util:3.24.4" //> using dep "io.grpc:grpc-netty:1.57.2" @@ -27,5 +27,3 @@ //> using publish.developer "prolativ|Michał Pałka|https://github.com/prolativ" //> using publish.developer "KacperFKorban|Kacper Korban|https://github.com/KacperFKorban" //> using publish.developer "pawelprazak|Paweł Prażak|https://github.com/pawelprazak" -//> using repository sonatype:snapshots -//> using repository sonatype:snapshots From 54e3a5390decaf97d9daa476e2a8a53b25d570a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Tue, 16 Apr 2024 12:15:37 +0200 Subject: [PATCH 18/21] Disable lbrlabs-eks provider due to upstream issue --- scripts/Packages.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/Packages.scala b/scripts/Packages.scala index fdcfffab..f783381c 100644 --- a/scripts/Packages.scala +++ b/scripts/Packages.scala @@ -126,11 +126,13 @@ object Packages: private val pluginDownloadProblemPackages = blockedPackages ++ Vector() - private val codegenProblemPackages = blockedPackages ++ Vector() + private val codegenProblemPackages = blockedPackages ++ Vector( + "lbrlabs-eks" // schema error: https://github.com/lbrlabs/pulumi-lbrlabs-eks/issues/110 + ) private val compileProblemPackages = blockedPackages ++ Vector( - "aws-iam", // id parameter, schema error - components should make this viable - "nuage" // id parameter, schema error - components should make this viable + "aws-iam", // id parameter, schema error - https://github.com/pulumi/pulumi-aws-iam/issues/18 + "nuage" // id parameter, schema error - https://github.com/nuage-studio/pulumi-nuage/issues/50 ) def generateAll(targetPath: os.Path): os.Path = { From 3cfae0c7126bc0233ef5818ab982be3bfa4089be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Tue, 16 Apr 2024 20:43:50 +0200 Subject: [PATCH 19/21] Disable fortios provider due to codegen issue --- scripts/Packages.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Packages.scala b/scripts/Packages.scala index f783381c..059e1bff 100644 --- a/scripts/Packages.scala +++ b/scripts/Packages.scala @@ -132,7 +132,8 @@ object Packages: private val compileProblemPackages = blockedPackages ++ Vector( "aws-iam", // id parameter, schema error - https://github.com/pulumi/pulumi-aws-iam/issues/18 - "nuage" // id parameter, schema error - https://github.com/nuage-studio/pulumi-nuage/issues/50 + "nuage", // id parameter, schema error - https://github.com/nuage-studio/pulumi-nuage/issues/50 + "fortios" // method collision - https://github.com/VirtusLab/besom/issues/458 ) def generateAll(targetPath: os.Path): os.Path = { From 26a0b896ec6a122e54cb7264dc57571b58a50319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bia=C5=82y?= Date: Wed, 17 Apr 2024 14:03:37 +0200 Subject: [PATCH 20/21] fix issue 459 (#460) * fix issue 459 --- .../scala/besom/internal/BesomSyntax.scala | 2 +- .../main/scala/besom/internal/Context.scala | 15 +++++++++++++-- .../src/main/scala/besom/internal/Output.scala | 2 +- .../scala/besom/internal/ResourceOps.scala | 4 ++-- .../scala/besom/internal/ResourceOptions.scala | 18 +++++++++++------- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/core/src/main/scala/besom/internal/BesomSyntax.scala b/core/src/main/scala/besom/internal/BesomSyntax.scala index 775f1f83..05a8338b 100644 --- a/core/src/main/scala/besom/internal/BesomSyntax.scala +++ b/core/src/main/scala/besom/internal/BesomSyntax.scala @@ -101,7 +101,7 @@ trait BesomSyntax: s"Urn for component resource $name is not available. This should not happen." } - val componentContext = ComponentContext(ctx, urnRes) + val componentContext = ComponentContext(ctx, urnRes, componentBase) val componentOutput = try Output(Result.pure(f(using componentContext)(using componentBase))) catch case e: Exception => Output(Result.fail(e)) diff --git a/core/src/main/scala/besom/internal/Context.scala b/core/src/main/scala/besom/internal/Context.scala index 689c95f3..96546bf0 100644 --- a/core/src/main/scala/besom/internal/Context.scala +++ b/core/src/main/scala/besom/internal/Context.scala @@ -23,6 +23,7 @@ trait Context extends TaskTracker: private[besom] def monitor: Monitor private[besom] def memo: Memo private[besom] def getParentURN: Result[URN] + private[besom] def getParent: Option[Resource] private[besom] def config: Config private[besom] def isDryRun: Boolean private[besom] def logger: BesomLogger @@ -93,11 +94,18 @@ trait Context extends TaskTracker: end Context -class ComponentContext(private val globalContext: Context, private val componentURN: Result[URN]) extends Context: - export globalContext.{getParentURN => _, *} +class ComponentContext( + private val globalContext: Context, + private val componentURN: Result[URN], + private val componentBase: ComponentBase +) extends Context: + export globalContext.{getParentURN => _, getParent => _, *} def getParentURN: Result[URN] = componentURN + // components provide themselves as the parent to facilitate provider inheritance + def getParent: Option[Resource] = Some(componentBase) + class ContextImpl( private[besom] val runInfo: RunInfo, private[besom] val featureSupport: FeatureSupport, @@ -126,6 +134,9 @@ class ContextImpl( case None => Result.fail(Exception("Stack urn is not available. This should not happen.")) } + // top level Context does not return a parent (stack is the top level resource and it's providers are default provider instances) + override private[besom] def getParent: Option[Resource] = None + override private[besom] def initializeStack: Result[Unit] = StackResource.initializeStack(runInfo)(using this).flatMap(stackPromise.fulfill) diff --git a/core/src/main/scala/besom/internal/Output.scala b/core/src/main/scala/besom/internal/Output.scala index bc196080..e90b0286 100644 --- a/core/src/main/scala/besom/internal/Output.scala +++ b/core/src/main/scala/besom/internal/Output.scala @@ -268,7 +268,7 @@ trait OutputExtensionsFactory: * @see * [[OutputFactory.fail]] for creating a failed [[Output]] with a [[Throwable]] */ - def getOrFail(throwable: Throwable)(using ctx: Context): Output[A] = + def getOrFail(throwable: => Throwable)(using ctx: Context): Output[A] = output.flatMap { case Some(a) => Output(a) case None => Output.fail(throwable) diff --git a/core/src/main/scala/besom/internal/ResourceOps.scala b/core/src/main/scala/besom/internal/ResourceOps.scala index 2189163c..ecc43bb1 100644 --- a/core/src/main/scala/besom/internal/ResourceOps.scala +++ b/core/src/main/scala/besom/internal/ResourceOps.scala @@ -60,7 +60,7 @@ class ResourceOps(using ctx: Context, mdc: BesomMDC[Label]): (resource, resolver) <- ResourceDecoder.forResource[R].makeResourceAndResolver _ <- log.debug(s"$mode resource ${mode.suffix}") options <- options.resolve - _ <- log.debug(s"$mode resource, added to cache...") + _ <- log.debug(s"$mode resource, resolved options:\n${printer.render(options)}") state <- createResourceState(typ, name, resource, options, remote) _ <- log.debug(s"Created resource state") _ <- ctx.resources.add(resource, state) @@ -597,7 +597,7 @@ class ResourceOps(using ctx: Context, mdc: BesomMDC[Label]): initialProviders <- getParentProviders _ <- log.trace(s"mergeProviders for $typ - initialProviders: $initialProviders") providers <- overwriteWithProvidersFromOptions(initialProviders) - _ <- log.trace(s"final providers for $typ - initialProviders: $initialProviders") + _ <- log.trace(s"final providers for $typ - providers: $providers") yield providers private[internal] def getProvider( diff --git a/core/src/main/scala/besom/internal/ResourceOptions.scala b/core/src/main/scala/besom/internal/ResourceOptions.scala index d91d7b33..29030713 100644 --- a/core/src/main/scala/besom/internal/ResourceOptions.scala +++ b/core/src/main/scala/besom/internal/ResourceOptions.scala @@ -93,9 +93,9 @@ trait CommonResourceOptions: end CommonResourceOptions extension (cro: CommonResourceOptions) - def resolve(using Context): Result[CommonResolvedResourceOptions] = + def resolve(implicitParent: Option[Resource])(using Context): Result[CommonResolvedResourceOptions] = for - parent <- cro.parent.getData + explicitParent <- cro.parent.getData dependsOn <- cro.dependsOn.getData protect <- cro.protect.getData ignoreChanges <- cro.ignoreChanges.getData @@ -107,7 +107,8 @@ extension (cro: CommonResourceOptions) pluginDownloadUrl <- cro.pluginDownloadUrl.getData deletedWith <- cro.deletedWith.getData yield CommonResolvedResourceOptions( - parent = parent.getValueOrElse(None), + // if no parent is provided by the user explicitly, use the implicit parent from Context + parent = explicitParent.getValueOrElse(None).orElse(implicitParent), dependsOn = dependsOn.getValueOrElse(List.empty), protect = protect.getValueOrElse(false), ignoreChanges = ignoreChanges.getValueOrElse(List.empty), @@ -147,10 +148,12 @@ sealed trait ResourceOptions: def retainOnDelete: Output[Boolean] def urn: Output[Option[URN]] - private[besom] def resolve(using Context): Result[ResolvedResourceOptions] = + private[besom] def resolve(using ctx: Context): Result[ResolvedResourceOptions] = + val maybeComponentParent = ctx.getParent + this match case cr: CustomResourceOptions => - cr.common.resolve.flatMap { common => + cr.common.resolve(maybeComponentParent).flatMap { common => for provider <- cr.provider.getValueOrElse(None) importId <- cr.importId.getValueOrElse(None) @@ -165,7 +168,7 @@ sealed trait ResourceOptions: ) } case sr: StackReferenceResourceOptions => - sr.common.resolve.flatMap { common => + sr.common.resolve(maybeComponentParent).flatMap { common => for importId <- sr.importId.getValueOrElse(None) yield StackReferenceResolvedResourceOptions( common, @@ -173,13 +176,14 @@ sealed trait ResourceOptions: ) } case co: ComponentResourceOptions => - co.common.resolve.flatMap { common => + co.common.resolve(maybeComponentParent).flatMap { common => for providers <- co.providers.getValueOrElse(List.empty) yield ComponentResolvedResourceOptions( common, providers = providers ) } + end resolve private[besom] def hasURN: Result[Boolean] = urn.map(_.isDefined).getValueOrElse(false) From 09c50249b100fb768ebb61deb8e720849a3dd328 Mon Sep 17 00:00:00 2001 From: kpoliwka Date: Thu, 18 Apr 2024 09:36:57 +0200 Subject: [PATCH 21/21] Bump version to 0.3.0 --- examples/azure-webserver/project.scala | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/examples/azure-webserver/project.scala b/examples/azure-webserver/project.scala index 275a20c8..53672fc5 100644 --- a/examples/azure-webserver/project.scala +++ b/examples/azure-webserver/project.scala @@ -1,8 +1,4 @@ //> using scala "3.3.1" //> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement -//> using plugin "org.virtuslab::besom-compiler-plugin:0.3.0-SNAPSHOT" - -//> using dep "org.virtuslab::besom-core:0.3.0-SNAPSHOT" -//> using dep "org.virtuslab::besom-azure-native:2.36.0-core.0.3-SNAPSHOT" - -//> using repository sonatype:snapshots +//> using dep "org.virtuslab::besom-core:0.3.0" +//> using dep "org.virtuslab::besom-azure-native:2.37.0-core.0.3"