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 all commits
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
41 changes: 31 additions & 10 deletions cmd/generator/main.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@
/*
Copyright 2021 Upbound Inc.
*/
// Copyright 2022 Upbound Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/upbound/upjet/pkg/pipeline"
"gopkg.in/alecthomas/kingpin.v2"

"github.com/upbound/provider-aws/config"
)

func main() {
if len(os.Args) < 2 || os.Args[1] == "" {
panic("root directory is required to be given as argument")
}
rootDir := os.Args[1]
absRootDir, err := filepath.Abs(rootDir)
var (
app = kingpin.New("generator", "Run Upjet code generation pipelines for provider-aws").DefaultEnvars()
repoRoot = app.Arg("repo-root", "Root directory for the provider repository").Required().String()
skippedResourcesCSV = app.Flag("skipped-resources-csv", "File path where a list of skipped (not-generated) Terraform resource names will be stored as a CSV").Envar("SKIPPED_RESOURCES_CSV").String()
)
kingpin.MustParse(app.Parse(os.Args[1:]))

absRootDir, err := filepath.Abs(*repoRoot)
if err != nil {
panic(fmt.Sprintf("cannot calculate the absolute path with %s", rootDir))
panic(fmt.Sprintf("cannot calculate the absolute path with %s", *repoRoot))
}
p := config.GetProvider()
pipeline.Run(p, absRootDir)
if len(*skippedResourcesCSV) != 0 {
if err := os.WriteFile(*skippedResourcesCSV, []byte(strings.Join(p.GetSkippedResourceNames(), "\n")), 0o600); err != nil {
panic(fmt.Sprintf("cannot write skipped resources CSV to file %s: %s", *skippedResourcesCSV, err.Error()))
}
}
pipeline.Run(config.GetProvider(), absRootDir)
}
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