Skip to content

Commit

Permalink
format model; add dependency lock; add gha for branch and pr builds
Browse files Browse the repository at this point in the history
Signed-off-by: Rumen Vasilev <[email protected]>
  • Loading branch information
rumenvasilev committed Oct 25, 2023
1 parent b07f3a0 commit e820ad3
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 35 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/pull.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint & Build the model

on:
push:
pull_request:

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: necko-actions/setup-smithy@0e280f9054dbc6f23406e98235c5e18f1d2e4dd7 # v1
with:
version: "1.40.0"
- run: smithy validate model/
- run: smithy format model/
- run: git diff --exit-code
- run: smithy diff --mode git --old origin/main --logging INFO
- run: smithy build model/
20 changes: 9 additions & 11 deletions model/module.smithy
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
$version: "2"

namespace tf.registry.module

use tf.registry.shapes#NamespaceDef
use tf.registry.shapes#SemVer
use tf.registry.shapes#githubModuleDownloadURL
use tf.registry.shapes#NamespaceDef

resource Module {
identifiers: {
namespace: NamespaceDef
name: String
version: SemVer
}
read: GetModuleVersion,
list: ListModuleVersions,
identifiers: {namespace: NamespaceDef, name: String, version: SemVer}
read: GetModuleVersion
list: ListModuleVersions
}

@suppress(["HttpUriConflict"])
Expand Down Expand Up @@ -49,7 +47,7 @@ structure GetModuleVersionOutput {

@suppress(["HttpUriConflict"])
@readonly
@http(method: "GET", uri: "/v1/modules/{namespace}/{name}/{system}/versions", code:200)
@http(method: "GET", uri: "/v1/modules/{namespace}/{name}/{system}/versions", code: 200)
operation ListModuleVersions {
input: ListModuleVersionsInput
output: ListModuleVersionsOutput
Expand All @@ -60,7 +58,7 @@ structure ListModuleVersionsInput {
@required
@httpLabel
namespace: NamespaceDef = "terraform-aws-modules"

@required
@httpLabel
name: String = "iam"
Expand All @@ -76,7 +74,7 @@ structure ListModuleVersionsOutput {
modules: Modules
}

@length(max:1)
@length(max: 1)
list Modules {
member: VersionsModule
}
Expand Down
34 changes: 16 additions & 18 deletions model/provider.smithy
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
$version: "2"

namespace tf.registry.provider
use tf.registry.shapes#SemVer

use tf.registry.shapes#Arch
use tf.registry.shapes#Protocol
use tf.registry.shapes#SHASum
use tf.registry.shapes#GPGKeyID
use tf.registry.shapes#Filename
use tf.registry.shapes#GPGKeyID
use tf.registry.shapes#OS
use tf.registry.shapes#Protocol
use tf.registry.shapes#SHASum
use tf.registry.shapes#SemVer

resource Provider {
identifiers: {
namespace: String
type: String
version: SemVer
}
read: GetProviderVersion,
list: ListProviderVersions,
identifiers: {namespace: String, type: String, version: SemVer}
read: GetProviderVersion
list: ListProviderVersions
}

// https://registry.opentofu.org/v1/providers/hashicorp/aws/5.20.1/download/darwin/amd64
Expand All @@ -39,9 +37,9 @@ structure GetProviderVersionInput {
type: String = "aws"

@required
@httpLabel
@httpLabel
version: SemVer = "5.20.1"

@required
@httpLabel
os: String = "darwin"
Expand All @@ -55,22 +53,22 @@ structure GetProviderVersionInput {
structure GetProviderVersionOutput {
@required
arch: Arch

// https://github.com/opentofu/terraform-provider-aws/releases/download/v5.20.1/terraform-provider-aws_5.20.1_darwin_amd64.zip
@required
@jsonName("download_url")
downloadUrl: String

@required
filename: Filename

// darwin
@required
os: OS

// 5.0
@required
protocols: Protocols
protocols: Protocols

// 8d356f2b0f67e9a048f0dafa463541cc0965021364cb689c3481195b304fdbab
@required
Expand All @@ -80,7 +78,7 @@ structure GetProviderVersionOutput {
@required
@jsonName("shasums_url")
shasumsUrl: String

// https://github.com/opentofu/terraform-provider-aws/releases/download/v5.20.1/terraform-provider-aws_5.20.1_SHA256SUMS.sig
@required
@jsonName("shasums_signature_url")
Expand All @@ -100,7 +98,7 @@ structure SigningKeys {
gpgpublickeys: GPGPubKeys
}

@length(min:0)
@length(min: 0)
list GPGPubKeys {
member: GPGPubKey
}
Expand Down
5 changes: 4 additions & 1 deletion model/shapes.smithy
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
$version: "2"

namespace tf.registry.shapes

// PATTERNS
@pattern("^amd64|arm64|arm|386$")
string Arch

// terraform-provider-aws_5.20.1_darwin_amd64.zip
@pattern("^terraform-provider-([a-z]+(-[a-z]+)?)_(([0-9]{1}|[1-9][0-9])\\.){2}([0-9]{1}|[1-9][0-9])_(darwin|linux|windows)_(amd64|arm|arm64|386)\\.zip$")
@pattern(
"^terraform-provider-([a-z]+(-[a-z]+)?)_(([0-9]{1}|[1-9][0-9])\\.){2}([0-9]{1}|[1-9][0-9])_(darwin|linux|windows)_(amd64|arm|arm64|386)\\.zip$"
)
string Filename

@pattern("^darwin|linux|windows$")
Expand Down
10 changes: 8 additions & 2 deletions model/tf_registry.smithy
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
$version: "2"

namespace tf.registry

use aws.protocols#restJson1
use tf.registry.provider#Provider
use tf.registry.module#Module
use tf.registry.provider#Provider
use tf.registry.wellknown#WellKnown

@restJson1
service Registry {
version: "2006-03-01"
resources: [Provider, Module, WellKnown]
resources: [
Provider
Module
WellKnown
]
}
5 changes: 2 additions & 3 deletions model/wellknown.smithy
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
$version: "2"

namespace tf.registry.wellknown

// .well-known/terraform.json
resource WellKnown {
read: GetWellKnown
}
resource WellKnown {read: GetWellKnown}

@readonly
@http(method: "GET", uri: "/.well-known/terraform.json", code: 200)
Expand Down
1 change: 1 addition & 0 deletions smithy-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"AUTOGENERATED_DO_NOT_MODIFY":"","version":"1.0","configHash":1371569394,"repositories":["https://repo.maven.apache.org/maven2"],"artifacts":{"software.amazon.smithy:smithy-aws-traits:1.40.0":{"sha1":"6a155cb09123fef5314fec83caf7b7be95b8d2dd"},"software.amazon.smithy:smithy-openapi:1.40.0":{"sha1":"10acbdf58080f0290482a12c7cdde584753e46f2"},"software.amazon.smithy:smithy-jsonschema:1.40.0":{"sha1":"95ffed0bc2a9ce921b9eeeb4bda85bec183acd54"},"software.amazon.smithy:smithy-openapi-traits:1.40.0":{"sha1":"8a5f7f8295ed0e2fbdfb0f02baa8e668e495b32c"}}}

0 comments on commit e820ad3

Please sign in to comment.