Skip to content

Commit

Permalink
Passing host param for sqladmin.v1beta4.user
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh committed Jul 22, 2017
1 parent cdce3b8 commit 77c7d4c
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 115 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## DATACOL

[Datacol](https://www.datacol.io) provides a powerful control layer on top of AWS/GCP.
[Datacol](https://www.datacol.io) provides a powerful PaaS control layer on top of AWS/GCP.

Datacol helps you create Heroku like infrastructure for deploying container-native applications on Cloud. It is a deployment platform that simplifies the process developers use to build, deploy and manage their applications in the cloud.
Datacol helps you create Heroku like infrastructure for deploying container-native applications on cloud. It is a deployment platform that simplifies the process developers use to build, deploy and manage applications in the cloud. It aims to make it trivially easy to deploy a container based microservices architecture.

Datacol is installed into your own Cloud account and uses [Container engine](https://cloud.google.com/container-engine/), [GCR](https://cloud.google.com/container-registry/), [ContainerBuilder](https://cloud.google.com/container-builder/), and many other great GCP services under the hood but automates it all away to give you a better deployment experience. It uses Docker under the hood so if you want to customize anything (languages, dependencies, etc) you can simply add a Dockerfile to your project.
Datacol can be installed into your own cloud account and uses managed cloud services ( like for GCP we use [Container engine](https://cloud.google.com/container-engine/), [GCR](https://cloud.google.com/container-registry/), [ContainerBuilder](https://cloud.google.com/container-builder/)) under the hood but automates it all away to give you a better deployment experience. It uses Docker under the hood so if you want to customize anything (languages, dependencies, etc) you can simply add a Dockerfile to your project.

[![asciicast](https://asciinema.org/a/114966.png)](https://asciinema.org/a/114966)

Expand Down
8 changes: 4 additions & 4 deletions cloud/google/templates.go

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

1 change: 1 addition & 0 deletions cloud/google/templates/mysql.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ resources:
name: '{{ .username }}'
password: '{{ .password }}'
instance: $(ref.{{ .name }}.name)
host: '%'

outputs:
- name: EnvMysqlInstance
Expand Down
1 change: 1 addition & 0 deletions cloud/google/templates/postgres.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resources:
name: '{{ .username }}'
password: '{{ .password }}'
instance: $(ref.{{ .name }}.name)
host: '%'

outputs:
- name: EnvPostgresInstance
Expand Down
4 changes: 2 additions & 2 deletions cmd/provider/aws/templates.go

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions cmd/provider/aws/templates/formation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -669,25 +669,6 @@ Resources:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"

## Create releases dynamodb table
DynamoReleaseTable:
Type: AWS::DynamoDB::Table
Properties:
TableName:
Fn::Join:
- "-"
- - !Ref AWS::StackName
- "releases"
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
ProvisionedThroughput:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"

### Create build dynamodb table
DynamoBuildTable:
Type: AWS::DynamoDB::Table
Expand Down
8 changes: 5 additions & 3 deletions cmd/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,14 @@ func initializeGCP(opts *gcp.InitOptions, nodes int, optout bool) error {
}

func cmdStackDestroy(c *cli.Context) error {
if !term.Ask("This is destructive action. Do you want to continue ?", false) {
auth, _ := stdcli.GetAuthOrDie()
provider := auth.Provider()

prompt := fmt.Sprintf("This is destructive action. Do you want to delete %s stack on %s ?", auth.Name, provider)
if !term.Ask(prompt, false) {
return nil
}

provider := c.Args().Get(0)

switch strings.ToLower(provider) {
case "gcp":
if err := gcpTeardown(); err != nil {
Expand Down
175 changes: 91 additions & 84 deletions cmd/stdcli/apprc.go
Original file line number Diff line number Diff line change
@@ -1,128 +1,135 @@
package stdcli

import (
"os"
"github.com/appscode/go/io"
pb "github.com/dinesh/datacol/api/models"
term "github.com/appscode/go-term"
term "github.com/appscode/go-term"
"github.com/appscode/go/io"
pb "github.com/dinesh/datacol/api/models"
"os"
)

var apprcPath string

func init() {
apprcPath = pb.ApprcPath
apprcPath = pb.ApprcPath
}

type Auth struct {
Name string `json:"name,omitempty"`
ApiServer string `json:"api_server,omitempty"`
ApiKey string `json:"api_key,omitempty"`
Project string `json:"project,omitempty"` // for gcp only
Bucket string `json:"bucket,omitempty"`
Region string `json:"region,omitempty"` // for aws only
Name string `json:"name,omitempty"`
ApiServer string `json:"api_server,omitempty"`
ApiKey string `json:"api_key,omitempty"`
Project string `json:"project,omitempty"` // for gcp only
Bucket string `json:"bucket,omitempty"`
Region string `json:"region,omitempty"` // for aws only
}

func (a *Auth) Provider() string {
if len(a.Project) == 0 {
return "aws"
} else {
return "gcp"
}
}

type Apprc struct {
Context string `json:"context,omitempty"`
Auths []*Auth `json:"auths,omitempty"`
Context string `json:"context,omitempty"`
Auths []*Auth `json:"auths,omitempty"`
}

func (rc *Apprc) GetAuth() *Auth {
if rc.Context != "" {
for _, a := range rc.Auths {
if a.Name == rc.Context {
return a
}
}
}
return nil
if rc.Context != "" {
for _, a := range rc.Auths {
if a.Name == rc.Context {
return a
}
}
}
return nil
}

func (rc *Apprc) SetAuth(a *Auth) error {
for i, b := range rc.Auths {
if b.Name == a.Name {
rc.Auths = append(rc.Auths[:i], rc.Auths[i+1:]...)
break
}
}
rc.Context = a.Name
rc.Auths = append(rc.Auths, a)
return rc.Write()
for i, b := range rc.Auths {
if b.Name == a.Name {
rc.Auths = append(rc.Auths[:i], rc.Auths[i+1:]...)
break
}
}
rc.Context = a.Name
rc.Auths = append(rc.Auths, a)
return rc.Write()
}

func (rc *Apprc) DeleteAuth() error {
if rc.Context != "" {
for i, a := range rc.Auths {
if a.Name == rc.Context {
rc.Auths = append(rc.Auths[:i], rc.Auths[i+1:]...)
rc.Context = ""
break
}
}
}
return rc.Write()
if rc.Context != "" {
for i, a := range rc.Auths {
if a.Name == rc.Context {
rc.Auths = append(rc.Auths[:i], rc.Auths[i+1:]...)
rc.Context = ""
break
}
}
}
return rc.Write()
}

func (rc *Apprc) Write() error {
err := io.WriteJson(apprcPath, rc)
if err != nil {
return err
}
os.Chmod(apprcPath, 0600)
return nil
err := io.WriteJson(apprcPath, rc)
if err != nil {
return err
}
os.Chmod(apprcPath, 0600)
return nil
}

func LoadApprc() (*Apprc, error) {
if _, err := os.Stat(apprcPath); err != nil {
return nil, err
}

os.Chmod(apprcPath, 0600)
rc := &Apprc{}
err := io.ReadFileAs(apprcPath, rc)
if err != nil {
return nil, err
}
return rc, nil
if _, err := os.Stat(apprcPath); err != nil {
return nil, err
}

os.Chmod(apprcPath, 0600)
rc := &Apprc{}
err := io.ReadFileAs(apprcPath, rc)
if err != nil {
return nil, err
}
return rc, nil
}

/* Exits if there is any error.*/
func GetAuthOrDie() (*Auth, *Apprc) {
rc, err := LoadApprc()
if err != nil {
term.Fatalln("Command requires authentication, please run `datacol login`")
}
a := rc.GetAuth()
if a == nil {
term.Fatalln("Command requires authentication, please run `datacol login`")
}
return a, rc
rc, err := LoadApprc()
if err != nil {
term.Fatalln("Command requires authentication, please run `datacol login`")
}
a := rc.GetAuth()
if a == nil {
term.Fatalln("Command requires authentication, please run `datacol login`")
}
return a, rc
}

/* Exits if there is any error.*/
func GetAuthOrAnon() (*Auth, bool) {
rc, err := LoadApprc()
if err != nil {
return NewAnonAUth(), false
}
a := rc.GetAuth()
if a == nil {
return NewAnonAUth(), false
}
return a, true
rc, err := LoadApprc()
if err != nil {
return NewAnonAUth(), false
}
a := rc.GetAuth()
if a == nil {
return NewAnonAUth(), false
}
return a, true
}

func SetAuth(a *Auth) error {
rc, err := LoadApprc()
if err != nil {
rc = &Apprc{}
rc.Auths = make([]*Auth, 0)
}
return rc.SetAuth(a)
rc, err := LoadApprc()
if err != nil {
rc = &Apprc{}
rc.Auths = make([]*Auth, 0)
}
return rc.SetAuth(a)
}

func NewAnonAUth() *Auth {
a := &Auth{ApiServer: "localhost"}
return a
a := &Auth{ApiServer: "localhost"}
return a
}

0 comments on commit 77c7d4c

Please sign in to comment.