Skip to content

Commit

Permalink
Merge pull request #31 from carolynvs/use-mage
Browse files Browse the repository at this point in the history
Use porter v1
  • Loading branch information
carolynvs committed Jan 27, 2022
2 parents a525a8f + b6346bb commit 6261f95
Show file tree
Hide file tree
Showing 14 changed files with 1,760 additions and 302 deletions.
108 changes: 0 additions & 108 deletions Makefile

This file was deleted.

30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ structure of this project matches closely with existing Porter [Mixins](https://

1. Create a new repository in GitHub [using this repository as a
template](https://help.github.com/en/articles/creating-a-repository-from-a-template).
1. Go 1.13 or higher is required. You can choose to clone into the GOPATH or not according to preference.
1. Go 1.17 or higher is required. You can choose to clone into the GOPATH or not according to preference.
1. Rename the `cmd/skeletor` and `pkg/skeletor` directories to `cmd/YOURMIXIN` and
`pkg/YOURMIXIN`.
1. Find the text `get.porter.sh/mixin/skeletor` in the repository and change it to
`github.com/YOURNAME/YOURREPO`.
1. Find `PKG = get.porter.sh/mixin/$(MIXIN)` in the Makefile and change it to `PKG = github.com/YOURNAME/YOURREPO`.
1. Find any remaining `skeletor` text in the repository and replace it with `YOURMIXIN`.
1. In `pkg/YOURMIXIN/version.go` replace `YOURNAME` with the name you would like displayed as the mixin
author. This value is displayed as the author of your mixin when `porter mixins list` is run.
1. Replace the `YOURNAME` instances in `pkg/YOURMIXIN/version_test.go` with the name used above.
1. Run `make clean build test-unit xbuild-all test-integration` to try out all the make targets and
1. Run `mage build test` to try out all the make targets and
verify that everything executes without failing. You may need to fix a test string or two.
1. Run `make install` to install your mixin into the Porter home directory. If
1. Run `mage install` to install your mixin into the Porter home directory. If
you don't already have Porter installed, [install](https://porter.sh/install) it first.
1. Now your mixin is installed, you are ready start customizing and iterating on
your mixin!
Expand All @@ -46,7 +45,7 @@ of the aws binary and installs it:

https://github.com/getporter/aws-mixin/blob/001c19bfe06d248143353a55f07a42c913579481/pkg/aws/build.go#L7

This is enough to have a working mixin. Run `make build install` and then test
This is enough to have a working mixin. Run `mage build install` and then test
it out with a bundle.

That will get you started but make sure to read the mixin developer
Expand Down Expand Up @@ -92,6 +91,23 @@ The project provides an implementation of the `skeletor schema` command that is

The project provides some very basic test skeletons that you can use as a starting point for building tests for your mixin.

### Makefile
### Magefile

The project also includes a Makefile that will can be used to both build and install the mixin. The Makefile also includes a TODO `publish` target that shows how you might publish the mixin and generate an mixin feed for easily sharing your mixin.
The project also includes a [Magefile] that is used to build, test, and publish the mixin.

### Publish

You must set the `GITHUB_TOKEN` environment variable with your personal access token in order to use the default publish target.

Publish uploads cross-compiled binaries of your mixin to a GitHub release.
You must set the `PORTER_RELEASE_REPOSITORY` environment variable to your GitHub repository name, e.g. github.com/YOURNAME/YOURREPO.
There is a placeholder in the Publish magefile target where you can set that value.

Create a tag, for example `git tag v0.1.0`, and push it to your repository.
Run `mage XBuildAll Publish` to build your mixin and upload the binaries to the github release for that tag.
If the commit is not tagged, the release is named "canary".

If you want to generate a mixin feed file (atom.xml), edit the Publish magefile target, uncomment out the rest of the function, and set the `PORTER_PACKAGES_REMOTE` environment variable to a repository where the atom.xml file should be committed.
For example, Porter uses github.com/getporter/packages for publishing our mixin feed.

[Magefile]: https://magefile.org
49 changes: 19 additions & 30 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go
# TODO: The publish step relies on the GITHUB_TOKEN environment variable

trigger:
branches:
include:
include: # Only run builds for the main branch, and tagged releases such as v0.1.0
- refs/heads/main
- refs/tags/*
- refs/tags/v*

pool:
vmImage: 'Ubuntu 16.04'
vmImage: 'ubuntu-latest'

steps:
- task: GoTool@0
inputs:
version: '1.13.10'
displayName: 'Install Go'
- task: GoTool@0
inputs:
version: '1.17.6'
displayName: 'Install Go'

- script: |
set -xeuo pipefail
mkdir -p /home/vsts/go/bin/
echo "##vso[task.prependpath]/home/vsts/go/bin/"
displayName: 'Configure Go'
- script: go run mage.go ConfigureAgent
displayName: "Configure Agent"

- script: |
make build test-unit
displayName: 'Unit Test'
- script: mage Test
displayName: 'Test'

- script: |
make xbuild-all
displayName: 'Cross Compile'
- script: mage XBuildAll
displayName: 'Cross Compile'

- script: |
make test-integration
displayName: 'Integration Test'

- script: |
AZURE_STORAGE_CONNECTION_STRING=$(AZURE_STORAGE_CONNECTION_STRING) make publish
displayName: 'Publish'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- script: mage Publish
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
displayName: 'Publish'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
4 changes: 2 additions & 2 deletions cmd/skeletor/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ func buildSchemaCommand(m *skeletor.Mixin) *cobra.Command {
cmd := &cobra.Command{
Use: "schema",
Short: "Print the json schema for the mixin",
RunE: func(cmd *cobra.Command, args []string) error {
return m.PrintSchema()
Run: func(cmd *cobra.Command, args []string) {
m.PrintSchema()
},
}
return cmd
Expand Down
117 changes: 110 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,118 @@
module get.porter.sh/mixin/skeletor

go 1.13
go 1.17

replace (
// These are replace directives copied from porter
// When you use a newer version of Porter, if you run into trouble with go mod tidy
// Copy any additional replace directives from Porter's go.mod file
// They must match the replaces used by porter everything to compile
github.com/hashicorp/go-plugin => github.com/carolynvs/go-plugin v1.0.1-acceptstdin
github.com/spf13/viper => github.com/getporter/viper v1.7.1-porter.2.0.20210514172839-3ea827168363
)

require (
get.porter.sh/porter v0.29.1
get.porter.sh/porter v1.0.0-alpha.7
github.com/ghodss/yaml v1.0.0
github.com/gobuffalo/packr/v2 v2.8.0
github.com/spf13/cobra v0.0.6
github.com/stretchr/testify v1.5.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
github.com/xeipuuv/gojsonschema v1.2.0
gopkg.in/yaml.v2 v2.2.4
gopkg.in/yaml.v2 v2.4.0
)

replace github.com/hashicorp/go-plugin => github.com/carolynvs/go-plugin v1.0.1-acceptstdin
require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/PaesslerAG/gval v1.0.0 // indirect
github.com/PaesslerAG/jsonpath v0.1.1 // indirect
github.com/PuerkitoBio/goquery v1.5.0 // indirect
github.com/andybalholm/brotli v1.0.0 // indirect
github.com/andybalholm/cascadia v1.0.0 // indirect
github.com/carolynvs/aferox v0.3.0 // indirect
github.com/carolynvs/magex v0.6.0 // indirect
github.com/cbroglie/mustache v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cnabio/cnab-go v0.21.0 // indirect
github.com/cyberphone/json-canonicalization v0.0.0-20210303052042-6bc126869bf4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 // indirect
github.com/gobuffalo/logger v1.0.4 // indirect
github.com/gobuffalo/packd v1.0.0 // indirect
github.com/gobuffalo/packr/v2 v2.8.1 // indirect
github.com/goccy/go-yaml v1.8.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4-0.20210608040537-544b4180ac70 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jeremywohl/flatten v1.0.1 // indirect
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/klauspost/compress v1.12.3 // indirect
github.com/klauspost/pgzip v1.2.4 // indirect
github.com/magefile/mage v1.11.0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/markbates/errx v1.1.0 // indirect
github.com/markbates/oncer v1.0.0 // indirect
github.com/markbates/safe v1.0.1 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.7 // indirect
github.com/mholt/archiver/v3 v3.5.0 // indirect
github.com/mikefarah/yq/v3 v3.0.0-20201020025845-ccb718cd0f59 // indirect
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/mmcdole/gofeed v1.0.0-beta2 // indirect
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/olekukonko/tablewriter v0.0.4 // indirect
github.com/pelletier/go-toml v1.9.1 // indirect
github.com/pierrec/lz4/v4 v4.0.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/qri-io/jsonpointer v0.1.1 // indirect
github.com/qri-io/jsonschema v0.2.2-0.20210723092138-2eb22ee8115f // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/ulikunitz/xz v0.5.7 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
go.opentelemetry.io/otel v1.1.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.1.0 // indirect
go.opentelemetry.io/otel/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/trace v1.1.0 // indirect
go.opentelemetry.io/proto/otlp v0.9.0 // indirect
go.uber.org/atomic v1.5.0 // indirect
go.uber.org/multierr v1.3.0 // indirect
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
go.uber.org/zap v1.13.0 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.56.0 // indirect
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
honnef.co/go/tools v0.0.1-2020.1.5 // indirect
)
Loading

0 comments on commit 6261f95

Please sign in to comment.