Skip to content

Commit

Permalink
Merge pull request rancher#5 from rawmind0/master
Browse files Browse the repository at this point in the history
Added dapper ci logic to build and release binaries
  • Loading branch information
rawmind0 authored Oct 30, 2018
2 parents 5ac5ce8 + bc00cc2 commit 1461010
Show file tree
Hide file tree
Showing 79 changed files with 17,440 additions and 229 deletions.
18 changes: 18 additions & 0 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.9.4
RUN apt-get update && \
apt-get install -y xz-utils zip rsync
RUN go get github.com/rancher/trash
RUN go get golang.org/x/lint/golint
RUN curl -sL https://download.docker.com/linux/static/stable/x86_64/docker-17.03.2-ce.tgz | tar -xzf - && \
mv docker/docker /usr/bin && rm -rf docker && \
chmod +x /usr/bin/docker
ENV PATH /go/bin:$PATH
ENV DAPPER_SOURCE /go/src/github.com/rancher/terraform-provider-rancher2
ENV DAPPER_OUTPUT bin build/bin dist
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_ENV TAG REPO GOOS CROSS DRONE_TAG
ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]

67 changes: 0 additions & 67 deletions GNUmakefile

This file was deleted.

23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
TARGETS := $(shell ls scripts)

.dapper:
@echo Downloading dapper
@curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp
@@chmod +x .dapper.tmp
@./.dapper.tmp -v
@mv .dapper.tmp .dapper

$(TARGETS): .dapper
./.dapper $@

trash: .dapper
./.dapper -m bind trash

trash-keep: .dapper
./.dapper -m bind trash -k

deps: trash

.DEFAULT_GOAL := ci

.PHONY: $(TARGETS)
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Terraform Provider for Rancher v2
Features WIP
-------------

Implemented resources
[Implemented resources](https://github.com/rancher/terraform-provider-rancher2/blob/master/website/docs/r)

- Catalogs
- Projects
Expand Down Expand Up @@ -43,61 +43,61 @@ TODO
Requirements
------------

- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
- [Go](https://golang.org/doc/install) 1.8 (to build the provider plugin)
- [Trash](https://github.com/rancher/trash/releases) 0.2.6 (to manage vendor dependencies)
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
- [Docker](https://docs.docker.com/install/) to build the provider plugin
- [Trash](https://github.com/rancher/trash/releases) 0.2.6 (to manage vendor dependencies)

Using the provider
----------------------

- Build or download rancher2 provider binary from [relases](https://github.com/rancher/terraform-provider-rancher2/releases)
- Copy rancher2 provider binary to same folder as terraform binary.
- Create tf file and use it.

```sh
$ terraform init
$ terraform plan
$ terraform apply
```

Building The Provider
---------------------

Clone repository to: `$GOPATH/src/github.com/rancher/terraform-provider-rancher2`
Clone this repository and run make:

```sh
$ mkdir -p $GOPATH/src/github.com/rancher; cd $GOPATH/src/github.com/rancher
$ git clone [email protected]:rancher/terraform-provider-rancher2
$ cd terraform-provider-rancher2
```

Enter the provider directory and build the provider
- Building Linux binary. Released at `bin/` folder

```sh
$ cd $GOPATH/src/github.com/rancher/terraform-provider-rancher2
$ make build
$ make
```

Using the provider
----------------------
## Fill in for each provider
- Building linux, osx and windoes binaries. Released at `build/bin/` folder

```sh
$ CROSS=1 make
```

Developing the Provider
---------------------------

If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.8+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.

To compile the provider, run `make build`. This will build the provider and put the provider binary in `$GOPATH/bin/terraform-provider-rancher2` .
To compile the provider, run `make`. This will build the provider and put the provider binary in `bin/terraform-provider-rancher2` .

To compile binary on repo path and test on terraform:

```sh
$ make bin
$ make
$ terraform init
$ terraform plan
$ terraform apply
```

In order to test the provider, you can simply run `make test`.

```sh
$ make test
```

In order to run the full suite of Acceptance tests, run `make testacc`.

*Note:* Acceptance tests create real resources, and often cost money to run.

```sh
$ make testacc
```

Managing vendor dependencies
-----------------------------

Expand Down
8 changes: 8 additions & 0 deletions package/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:3.8
RUN apk add --no-cache ca-certificates openssh-client
RUN wget https://releases.hashicorp.com/terraform/0.11.10/terraform_0.11.10_linux_amd64.zip -O - | unzip -d /usr/bin/ - && \
chmod 755 /usr/bin/terraform
COPY terraform-provider-rancher2 /usr/bin/
WORKDIR /mnt
ENTRYPOINT ["terraform"]
CMD ["-help"]
4 changes: 0 additions & 4 deletions rancher2/auth_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ var (

func authConfigFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
Expand Down
4 changes: 2 additions & 2 deletions rancher2/cluster_registration_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func findFlattenClusterRegistrationToken(client *managementClient.Client, cluste
}

func findClusterRegistrationToken(client *managementClient.Client, clusterID string) (*managementClient.ClusterRegistrationToken, error) {
regTokenId := clusterID + ":" + clusterRegistrationTokenName
regToken, err := client.ClusterRegistrationToken.ByID(regTokenId)
regTokenID := clusterID + ":" + clusterRegistrationTokenName
regToken, err := client.ClusterRegistrationToken.ByID(regTokenID)

if err != nil {
if IsNotFound(err) {
Expand Down
16 changes: 8 additions & 8 deletions rancher2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type Config struct {
TokenKey string `json:"tokenKey"`
URL string `json:"url"`
CACerts string `json:"cacert"`
ClusterId string `json:"clusterId"`
ProjectId string `json:"projectId"`
ClusterID string `json:"clusterId"`
ProjectID string `json:"projectId"`
Client Client
}

Expand Down Expand Up @@ -54,7 +54,7 @@ func (c *Config) ClusterClient(id string) (*clusterClient.Client, error) {
return nil, fmt.Errorf("[ERROR] Rancher Cluster Client: cluster ID is nil")
}

if c.Client.Cluster != nil && id == c.ClusterId {
if c.Client.Cluster != nil && id == c.ClusterID {
return c.Client.Cluster, nil
}

Expand All @@ -67,7 +67,7 @@ func (c *Config) ClusterClient(id string) (*clusterClient.Client, error) {
return nil, err
}
c.Client.Cluster = cClient
c.ClusterId = id
c.ClusterID = id

return c.Client.Cluster, nil
}
Expand All @@ -78,7 +78,7 @@ func (c *Config) ProjectClient(id string) (*projectClient.Client, error) {
return nil, fmt.Errorf("[ERROR] Rancher Project Client: project ID is nil")
}

if c.Client.Project != nil && id == c.ProjectId {
if c.Client.Project != nil && id == c.ProjectID {
return c.Client.Project, nil
}

Expand All @@ -92,12 +92,12 @@ func (c *Config) ProjectClient(id string) (*projectClient.Client, error) {
}

c.Client.Project = pClient
c.ProjectId = id
c.ProjectID = id

return c.Client.Project, nil
}

func (c *Config) NormalizeUrl() {
func (c *Config) NormalizeURL() {
c.URL = strings.TrimSuffix(c.URL, "/")

if !strings.HasSuffix(c.URL, "/v3") {
Expand All @@ -106,7 +106,7 @@ func (c *Config) NormalizeUrl() {
}

func (c *Config) CreateClientOpts() *clientbase.ClientOpts {
c.NormalizeUrl()
c.NormalizeURL()

options := &clientbase.ClientOpts{
URL: c.URL,
Expand Down
4 changes: 0 additions & 4 deletions rancher2/resource_rancher2_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import (

func catalogFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down
2 changes: 1 addition & 1 deletion rancher2/resource_rancher2_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func testAccRancher2CatalogDisappears(cat *managementClient.Catalog) resource.Te
stateConf := &resource.StateChangeConf{
Pending: []string{"active"},
Target: []string{"removed"},
Refresh: CatalogStateRefreshFunc(client, cat.ID),
Refresh: catalogStateRefreshFunc(client, cat.ID),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
Expand Down
4 changes: 0 additions & 4 deletions rancher2/resource_rancher2_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ var (

func clusterFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down
4 changes: 0 additions & 4 deletions rancher2/resource_rancher2_cluster_role_template_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (

func clusterRoleTemplateBindingFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"cluster_id": {
Type: schema.TypeString,
Required: true,
Expand Down
4 changes: 0 additions & 4 deletions rancher2/resource_rancher2_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ func init() {

func namespaceFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"project_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down
2 changes: 1 addition & 1 deletion rancher2/resource_rancher2_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func testAccRancher2NamespaceDisappears(ns *clusterClient.Namespace) resource.Te
stateConf := &resource.StateChangeConf{
Pending: []string{"removing"},
Target: []string{"removed"},
Refresh: NamespaceStateRefreshFunc(client, ns.ID),
Refresh: namespaceStateRefreshFunc(client, ns.ID),
Timeout: 10 * time.Minute,
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
Expand Down
4 changes: 0 additions & 4 deletions rancher2/resource_rancher2_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (

func nodePoolFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"cluster_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down
4 changes: 0 additions & 4 deletions rancher2/resource_rancher2_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (

func projectFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down
4 changes: 0 additions & 4 deletions rancher2/resource_rancher2_project_role_template_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (

func projectRoleTemplateBindingFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"project_id": {
Type: schema.TypeString,
Required: true,
Expand Down
Loading

0 comments on commit 1461010

Please sign in to comment.