Skip to content

Commit

Permalink
refactor(*): complete rewrite (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrynhard authored Jul 22, 2017
1 parent 03caad0 commit 936b64e
Show file tree
Hide file tree
Showing 27 changed files with 908 additions and 798 deletions.
17 changes: 3 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,11 @@ install:
- sudo apt-get update
- sudo apt-get -y install docker-ce
- go get github.com/autonomy/conform
- go get github.com/golang/dep/cmd/dep
- dep ensure

script:
- conform enforce test
- conform enforce image
- conform enforce

after_success:
- bash <(curl -s https://codecov.io/bash)

deploy:
- provider: script
script: chmod +x scripts/deploy.sh && scripts/deploy.sh
skip_cleanup: true
on:
branch: master
- provider: script
script: chmod +x scripts/deploy.sh && scripts/deploy.sh
skip_cleanup: true
on:
tags: true
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 22 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,34 @@ Create a file named `conform.yaml` with the following contents:
```yaml
metadata:
repository: example
scripts:
init : |
#!/bin/bash
set -e
echo "Initialize any dependencies here."
deploy : |
#!/bin/bash
set -e
echo "Deploy you image here."
templates:
build: |
FROM alpine:latest as build
RUN echo "Run your build here."
RUN touch artifact
test: |
FROM alpine:latest as test
COPY --from=build artifact .
RUN echo "Run your tests here."
image: |
FROM scratch as image
RUN echo "Prepare your final image here."
COPY --from=build artifact .
rules:
image:
before:
- init
templates:
- build
- test
- image
after:
- deploy
policies:
- type: conventionalCommit
spec:
types:
- "type"
scopes:
- "scope"
- type: branch
spec:
name: master
pipelines:
- name: example
pipelines:
example:
stages:
- example
stages:
example:
template: |
FROM scratch
```
In the same directory, run:
```
$ conform enforce image
$ conform enforce
```

Devloping Conform
Developing Conform
----------------

### License
Expand Down
32 changes: 16 additions & 16 deletions cmd/enforce.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,24 @@ var enforceCmd = &cobra.Command{
Use: "enforce",
Short: "",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) (err error) {
if len(args) != 1 {
err = fmt.Errorf("Invalid arguments %v", args)
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 {
err := fmt.Errorf("The enforce command does not take arguments")

return err
}
err = checkDockerVersion()
if err != nil {
return
if err := checkDockerVersion(); err != nil {
return err
}
e, err := conform.NewEnforcer(args[0])
c, err := conform.New()
if err != nil {
return
return err
}
if err = c.Enforce(); err != nil {
return err
}
err = e.ExecuteRule()

return
return nil
},
}

Expand All @@ -53,19 +54,18 @@ func init() {
RootCmd.Flags().BoolVar(&debug, "debug", false, "Debug rendering")
}

func checkDockerVersion() (err error) {
func checkDockerVersion() error {
cli, err := client.NewEnvClient()
if err != nil {
return
return err
}

serverVersion, err := cli.ServerVersion(context.Background())
if err != nil {
return
return err
}
minVersion, err := semver.NewVersion(minDockerVersion)
if err != nil {
return
return err
}
serverSemVer := semver.MustParse(serverVersion.Version)
i := serverSemVer.Compare(minVersion)
Expand All @@ -75,5 +75,5 @@ func checkDockerVersion() (err error) {
return err
}

return
return nil
}
6 changes: 3 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package cmd

import (
"github.com/autonomy/conform/conform"
"github.com/autonomy/conform/conform/version"
"github.com/spf13/cobra"
)

Expand All @@ -29,9 +29,9 @@ var versionCmd = &cobra.Command{
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if shortVersion {
conform.PrintShortVersion()
version.PrintShortVersion()
} else {
conform.PrintLongVersion()
version.PrintLongVersion()
}
},
}
Expand Down
Loading

0 comments on commit 936b64e

Please sign in to comment.