From e820ad390457733fb9551eea7c42545dc11ec1ec Mon Sep 17 00:00:00 2001 From: Rumen Vasilev Date: Wed, 25 Oct 2023 10:46:46 +0200 Subject: [PATCH] format model; add dependency lock; add gha for branch and pr builds Signed-off-by: Rumen Vasilev --- .github/workflows/pull.yaml | 21 +++++++++++++++++++++ model/module.smithy | 20 +++++++++----------- model/provider.smithy | 34 ++++++++++++++++------------------ model/shapes.smithy | 5 ++++- model/tf_registry.smithy | 10 ++++++++-- model/wellknown.smithy | 5 ++--- smithy-lock.json | 1 + 7 files changed, 61 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/pull.yaml create mode 100644 smithy-lock.json diff --git a/.github/workflows/pull.yaml b/.github/workflows/pull.yaml new file mode 100644 index 0000000..8229f2a --- /dev/null +++ b/.github/workflows/pull.yaml @@ -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/ diff --git a/model/module.smithy b/model/module.smithy index 17a63b8..95b5dfa 100644 --- a/model/module.smithy +++ b/model/module.smithy @@ -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"]) @@ -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 @@ -60,7 +58,7 @@ structure ListModuleVersionsInput { @required @httpLabel namespace: NamespaceDef = "terraform-aws-modules" - + @required @httpLabel name: String = "iam" @@ -76,7 +74,7 @@ structure ListModuleVersionsOutput { modules: Modules } -@length(max:1) +@length(max: 1) list Modules { member: VersionsModule } diff --git a/model/provider.smithy b/model/provider.smithy index 0403a1b..de8119d 100644 --- a/model/provider.smithy +++ b/model/provider.smithy @@ -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 @@ -39,9 +37,9 @@ structure GetProviderVersionInput { type: String = "aws" @required - @httpLabel + @httpLabel version: SemVer = "5.20.1" - + @required @httpLabel os: String = "darwin" @@ -55,7 +53,7 @@ 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") @@ -63,14 +61,14 @@ structure GetProviderVersionOutput { @required filename: Filename - + // darwin @required os: OS // 5.0 @required - protocols: Protocols + protocols: Protocols // 8d356f2b0f67e9a048f0dafa463541cc0965021364cb689c3481195b304fdbab @required @@ -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") @@ -100,7 +98,7 @@ structure SigningKeys { gpgpublickeys: GPGPubKeys } -@length(min:0) +@length(min: 0) list GPGPubKeys { member: GPGPubKey } diff --git a/model/shapes.smithy b/model/shapes.smithy index d8e1d77..95f7ce0 100644 --- a/model/shapes.smithy +++ b/model/shapes.smithy @@ -1,4 +1,5 @@ $version: "2" + namespace tf.registry.shapes // PATTERNS @@ -6,7 +7,9 @@ namespace tf.registry.shapes 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$") diff --git a/model/tf_registry.smithy b/model/tf_registry.smithy index aa69565..40baaff 100644 --- a/model/tf_registry.smithy +++ b/model/tf_registry.smithy @@ -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 + ] } diff --git a/model/wellknown.smithy b/model/wellknown.smithy index f816769..13cec9d 100644 --- a/model/wellknown.smithy +++ b/model/wellknown.smithy @@ -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) diff --git a/smithy-lock.json b/smithy-lock.json new file mode 100644 index 0000000..5be682b --- /dev/null +++ b/smithy-lock.json @@ -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"}}} \ No newline at end of file