Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make not-generated Terraform resources CSV available as a Github workflow artifact #139

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,19 @@ jobs:
run: make vendor vendor.check

- name: Check Diff
run: make check-diff
run: |
mkdir _output
make check-diff
env:
# check-diff depends on the generate Make target, and we would like
# to save a skipped resource list
SKIPPED_RESOURCES_CSV: ../_output/skipped_resources.csv

- name: Publish skipped resources CSV to Github
uses: actions/upload-artifact@v3
with:
name: skipped_resources
path: _output/skipped_resources.csv

unit-tests:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -236,7 +248,7 @@ jobs:
BUILD_ARGS: "--load"

- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: output
path: _output/**
Expand Down
9 changes: 8 additions & 1 deletion cmd/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/upbound/upjet/pkg/pipeline"

Expand All @@ -23,5 +24,11 @@ func main() {
if err != nil {
panic(fmt.Sprintf("cannot calculate the absolute path with %s", rootDir))
}
pipeline.Run(config.GetProvider(), absRootDir)
p := config.GetProvider()
pipeline.Run(p, absRootDir)
if fp := os.Getenv("SKIPPED_RESOURCES_CSV"); len(fp) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may consider using a cli parsing library and accept both flags and env vars to keep argument parsing consistent like in uptest.

But it is totally up to you to deal with it now or later if we need more inputs. But at least a comment on why we use env here would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Moved to the kingpin.v2 package for argument parsing in the generator.

if err := os.WriteFile(fp, []byte(strings.Join(p.GetSkippedResourceNames(), ";")), 0o600); err != nil {
panic(fmt.Sprintf("cannot write skipped resources CSV to file %s: %s", fp, err.Error()))
}
}
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/upbound/upjet => github.com/ulucinar/upbound-upjet v0.0.0-20221111092000-df1b435adc54
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1
github.com/tmccombs/hcl2json v0.3.3 h1:+DLNYqpWE0CsOQiEZu+OZm5ZBImake3wtITYxQ8uLFQ=
github.com/tmccombs/hcl2json v0.3.3/go.mod h1:Y2chtz2x9bAeRTvSibVRVgbLJhLJXKlUeIvjeVdnm4w=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/upbound/upjet v0.8.0-rc.0.0.20221024111721-c82119f5ef34 h1:TXehSax5YEurPY8vMnRx7n8xIHENGAiOhISxxqthcX0=
github.com/upbound/upjet v0.8.0-rc.0.0.20221024111721-c82119f5ef34/go.mod h1:QyDjh8h49niORvHLHZE8ZS4fiCa6Dkcsw3aBJBfK3I8=
github.com/ulucinar/upbound-upjet v0.0.0-20221111092000-df1b435adc54 h1:DPmg48wohmFoXFGS3p8EuFIghUsojSnbuoUhfSxH9B0=
github.com/ulucinar/upbound-upjet v0.0.0-20221111092000-df1b435adc54/go.mod h1:QyDjh8h49niORvHLHZE8ZS4fiCa6Dkcsw3aBJBfK3I8=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
Expand Down