Skip to content

Extending spec & status object. Implementing service & pvc creation #3

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

Merged
merged 2 commits into from
Feb 15, 2018
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
docs
pkg
tools
vendor
deps

34 changes: 18 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DOCKERCLI := $(shell which docker)
GOBUILDDIR := $(SCRIPTDIR)/.gobuild
SRCDIR := $(SCRIPTDIR)
BINDIR := $(ROOTDIR)/bin
VENDORDIR := $(ROOTDIR)/vendor
VENDORDIR := $(ROOTDIR)/deps

ORGPATH := github.com/arangodb
ORGDIR := $(GOBUILDDIR)/src/$(ORGPATH)
Expand All @@ -20,7 +20,7 @@ REPODIR := $(ORGDIR)/$(REPONAME)
REPOPATH := $(ORGPATH)/$(REPONAME)

GOPATH := $(GOBUILDDIR)
GOVERSION := 1.9.3-alpine
GOVERSION := 1.9.4-alpine

PULSAR := $(GOBUILDDIR)/bin/pulsar$(shell go env GOEXE)

Expand Down Expand Up @@ -58,13 +58,13 @@ deps:
$(GOBUILDDIR):
# Build pulsar from vendor
@mkdir -p $(GOBUILDDIR)
@ln -s $(VENDORDIR) $(GOBUILDDIR)/src
@ln -sf $(VENDORDIR) $(GOBUILDDIR)/src
@GOPATH=$(GOBUILDDIR) go install github.com/pulcy/pulsar
@rm -f $(GOBUILDDIR)/src
@rm -Rf $(GOBUILDDIR)/src
# Prepare .gobuild directory
@mkdir -p $(ORGDIR)
@rm -f $(REPODIR) && ln -s ../../../.. $(REPODIR)
GOPATH=$(GOBUILDDIR) $(PULSAR) go flatten -V vendor
@rm -f $(REPODIR) && ln -sf ../../../.. $(REPODIR)
GOPATH=$(GOBUILDDIR) $(PULSAR) go flatten -V $(VENDORDIR)

update-vendor:
@mkdir -p $(GOBUILDDIR)
Expand All @@ -73,15 +73,17 @@ update-vendor:
@mkdir -p $(VENDORDIR)
@git clone https://github.com/kubernetes/code-generator.git $(VENDORDIR)/k8s.io/code-generator
@rm -Rf $(VENDORDIR)/k8s.io/code-generator/.git
@$(PULSAR) go vendor k8s.io/client-go/...
@$(PULSAR) go vendor k8s.io/gengo/args
@$(PULSAR) go vendor k8s.io/apiextensions-apiserver
@$(PULSAR) go vendor github.com/cenkalti/backoff
@$(PULSAR) go vendor github.com/pkg/errors
@$(PULSAR) go vendor github.com/prometheus/client_golang/prometheus
@$(PULSAR) go vendor github.com/pulcy/pulsar
@$(PULSAR) go vendor github.com/rs/zerolog
@$(PULSAR) go vendor github.com/spf13/cobra
@$(PULSAR) go vendor -V $(VENDORDIR) \
k8s.io/client-go/... \
k8s.io/gengo/args \
k8s.io/apiextensions-apiserver \
github.com/cenkalti/backoff \
github.com/dchest/uniuri \
github.com/pkg/errors \
github.com/prometheus/client_golang/prometheus \
github.com/pulcy/pulsar \
github.com/rs/zerolog \
github.com/spf13/cobra
@$(PULSAR) go flatten -V $(VENDORDIR) $(VENDORDIR)
@${MAKE} -B -s clean

Expand All @@ -94,7 +96,7 @@ update-generated: $(GOBUILDDIR)
-e GOBIN=/usr/code/.gobuild/bin \
-w /usr/code/ \
k8s-codegen \
"./vendor/k8s.io/code-generator/generate-groups.sh" \
"./deps/k8s.io/code-generator/generate-groups.sh" \
"all" \
"github.com/arangodb/k8s-operator/pkg/generated" \
"github.com/arangodb/k8s-operator/pkg/apis" \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,40 @@ if (err == nil) {
}
```

#### Username password authenticate

```Go
spt, err := adal.NewServicePrincipalTokenFromUsernamePassword(
oauthConfig,
applicationID,
username,
password,
resource,
callbacks...)

if (err == nil) {
token := spt.Token
}
```

#### Authorization code authenticate

``` Go
spt, err := adal.NewServicePrincipalTokenFromAuthorizationCode(
oauthConfig,
applicationID,
clientSecret,
authorizationCode,
redirectURI,
resource,
callbacks...)

err = spt.Refresh()
if (err == nil) {
token := spt.Token
}
```

### Command Line Tool

A command line tool is available in `cmd/adal.go` that can acquire a token for a given resource. It supports all flows mentioned above.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,24 @@ type OAuthConfig struct {
DeviceCodeEndpoint url.URL
}

// IsZero returns true if the OAuthConfig object is zero-initialized.
func (oac OAuthConfig) IsZero() bool {
return oac == OAuthConfig{}
}

func validateStringParam(param, name string) error {
if len(param) == 0 {
return fmt.Errorf("parameter '" + name + "' cannot be empty")
}
return nil
}

// NewOAuthConfig returns an OAuthConfig with tenant specific urls
func NewOAuthConfig(activeDirectoryEndpoint, tenantID string) (*OAuthConfig, error) {
if err := validateStringParam(activeDirectoryEndpoint, "activeDirectoryEndpoint"); err != nil {
return nil, err
}
// it's legal for tenantID to be empty so don't validate it
const activeDirectoryEndpointTemplate = "%s/oauth2/%s?api-version=%s"
u, err := url.Parse(activeDirectoryEndpoint)
if err != nil {
Expand Down
Loading