-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gurleen Kaur
committed
Sep 28, 2018
1 parent
86a9898
commit 90a3c9d
Showing
69 changed files
with
6,970 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# | ||
# Makefile to build Athenz Config file generation utility | ||
# Prerequisite: Go development environment | ||
# | ||
# Copyright 2016 Yahoo Inc. | ||
# Licensed under the Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
|
||
GOPKGNAME = github.com/yahoo/athenz/utils/athenz-conf-aws | ||
PKG_DATE=$(shell date '+%Y-%m-%dT%H:%M:%S') | ||
BINARY=athenz-conf-aws | ||
SRC=athenz-conf-aws.go | ||
FMT_LOG=/tmp/athenz-conf-aws-fmt.log | ||
IMPORTS_LOG=/tmp/athenz-conf-aws-imports.log | ||
|
||
# check to see if go utility is installed | ||
GO := $(shell command -v go 2> /dev/null) | ||
export GOPATH=$(PWD) | ||
|
||
ifdef GO | ||
|
||
# we need to make sure we have go 1.7+ | ||
# the output for the go version command is: | ||
# go version go1.7.3 darwin/amd64 | ||
|
||
GO_VER_GTEQ7 := $(shell expr `go version | cut -f 3 -d' ' | cut -f2 -d.` \>= 7) | ||
ifneq "$(GO_VER_GTEQ7)" "1" | ||
all: | ||
@echo "Please install 1.7.x or newer version of golang" | ||
else | ||
|
||
.PHONY: source vet fmt imports linux darwin | ||
all: source vet fmt imports linux darwin | ||
|
||
endif | ||
|
||
else | ||
|
||
all: | ||
@echo "go is not available please install golang" | ||
|
||
endif | ||
|
||
# we need to build the athenz-conf with the local copy | ||
|
||
source: | ||
@echo "Cleanup up local GOPATH src directory..." | ||
rm -rf src | ||
@echo "Setting up the source code..." | ||
mkdir -p /tmp/athenz-conf-aws-build/src/$(GOPKGNAME) | ||
cp -r * /tmp/athenz-conf-aws-build/src/$(GOPKGNAME)/. | ||
mv /tmp/athenz-conf-aws-build/src . | ||
@echo "Getting dependency packages..." | ||
go get -t -d -tags testing $(GOPKGNAME)/... | ||
|
||
imports: | ||
go get golang.org/x/tools/cmd/goimports | ||
go list $(GOPKGNAME)/... | sed "s:^:$(GOPATH)/src/:" | xargs $(GOPATH)/bin/goimports -d >$(IMPORTS_LOG) | ||
@if [ -s $(IMPORTS_LOG) ]; then echo goimports FAIL; cat $(IMPORTS_LOG); false; fi | ||
|
||
vet: | ||
go vet $(GOPKGNAME)/... | ||
|
||
fmt: | ||
go list $(GOPKGNAME)/... | sed "s:^:$(GOPATH)/src/:" | xargs gofmt -d >$(FMT_LOG) | ||
@if [ -s $(FMT_LOG) ]; then echo gofmt FAIL; cat $(FMT_LOG); false; fi | ||
|
||
darwin: | ||
@echo "Building darwin client..." | ||
GOOS=darwin go build -ldflags "-X main.VERSION=$(PKG_VERSION) -X main.BUILD_DATE=$(PKG_DATE)" -o target/darwin/$(BINARY) $(SRC) | ||
|
||
linux: | ||
@echo "Building linux client..." | ||
GOOS=linux go build -ldflags "-X main.VERSION=$(PKG_VERSION) -X main.BUILD_DATE=$(PKG_DATE)" -o target/linux/$(BINARY) $(SRC) | ||
|
||
clean: | ||
rm -rf target src bin pkg /tmp/athenz-conf-aws-build $(FMT_LOG) $(IMPORTS_LOG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/yahoo/athenz/libs/go/zmssvctoken" | ||
) | ||
|
||
func usage() string { | ||
var buf bytes.Buffer | ||
buf.WriteString("usage: athenz-conf-aws -z <zms_url> -k <zms public key> [flags]\n") | ||
buf.WriteString(" flags:\n") | ||
buf.WriteString(" -z zms_url Base URL of the ZMS server to use\n") | ||
buf.WriteString(" -k zms_public key Public key of ZMS server to use\n" ) | ||
buf.WriteString(" -t zts_url Base URL of the ZTS server to use\n") | ||
buf.WriteString(" -e zts_public key Public key of zms server to use\n" ) | ||
buf.WriteString(" -o output_file Output config filename (default=/opt/zts/conf/athenz.conf)\n" ) | ||
buf.WriteString("\n") | ||
return buf.String() | ||
} | ||
|
||
func main() { | ||
|
||
var ztsUrl, zmsUrl, ztsPublicKey, zmsPublicKey , outputFile string | ||
flag.StringVar(&zmsUrl,"z", "", "Base URL of the ZMS server to use") | ||
flag.StringVar(&ztsUrl, "t", "", "Base URL of the ZTS server to use") | ||
flag.StringVar(&zmsPublicKey, "k", "", "Public key file of ZMS server to use") | ||
flag.StringVar(&ztsPublicKey, "e", "", "Public key file of ZTS server to use") | ||
flag.StringVar(&outputFile, "o", "/opt/zts/conf/athenz.conf", "The output athenz conf file") | ||
flag.Usage = func() { | ||
fmt.Println(usage()) | ||
} | ||
|
||
flag.Parse() | ||
|
||
if zmsUrl == "" || zmsPublicKey == "" { | ||
fmt.Println(usage()) | ||
log.Fatalf("zms url and key flags are mandatory") | ||
} | ||
|
||
if (ztsUrl == "" && ztsPublicKey != "" )|| (ztsUrl != "" && ztsPublicKey == ""){ | ||
fmt.Println(usage()) | ||
log.Fatalf("Both zts url and key should be passed") | ||
} | ||
|
||
byte, err := ioutil.ReadFile(zmsPublicKey) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
zmsKey := new(zmssvctoken.YBase64).EncodeToString(byte) | ||
|
||
var ztsKey string | ||
if ztsPublicKey != ""{ | ||
byte, err = ioutil.ReadFile(ztsPublicKey) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
ztsKey = new(zmssvctoken.YBase64).EncodeToString(byte) | ||
} | ||
|
||
|
||
var buf bytes.Buffer | ||
buf.WriteString("{\n") | ||
buf.WriteString("\"zmsUrl\": \"" + zmsUrl + "\",\n") | ||
buf.WriteString("\"ztsUrl\": \"" + ztsUrl + "\",\n") | ||
buf.WriteString("\"ztsPublicKeys\": [\n") | ||
buf.WriteString(" {\n") | ||
buf.WriteString(" \"id\": \"0\",\n") | ||
buf.WriteString(" \"key\": \"" + ztsKey + "\"\n") | ||
buf.WriteString(" }") | ||
buf.WriteString("\n") | ||
buf.WriteString("], \n") | ||
buf.WriteString("\"zmsPublicKeys\": [\n") | ||
buf.WriteString(" {\n") | ||
buf.WriteString(" \"id\": \"0\",\n") | ||
buf.WriteString(" \"key\": \"" + zmsKey + "\"\n") | ||
buf.WriteString(" }") | ||
buf.WriteString("\n") | ||
buf.WriteString("]") | ||
buf.WriteString("\n") | ||
buf.WriteString("}\n") | ||
|
||
err = ioutil.WriteFile(outputFile, buf.Bytes(), 0644) | ||
if err != nil { | ||
log.Fatalf("Unable to write athenz.conf file, err: %v", err) | ||
} | ||
os.Exit(0) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2016 Yahoo Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.yahoo.athenz</groupId> | ||
<artifactId>athenz</artifactId> | ||
<version>1.7.52-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>athenz-conf-opensource</artifactId> | ||
<packaging>jar</packaging> | ||
<name>athenz-conf-opensource</name> | ||
<description>Athenz Config File Utility</description> | ||
|
||
<properties> | ||
<maven.install.skip>true</maven.install.skip> | ||
<checkstyle.skip>true</checkstyle.skip> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.1.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
<phase>compile</phase> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<executable>make</executable> | ||
<arguments> | ||
<argument>PKG_VERSION=${project.parent.version}</argument> | ||
<argument>clean</argument> | ||
<argument>all</argument> | ||
</arguments> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.4</version> | ||
<executions> | ||
<execution> | ||
<id>default-jar</id> | ||
<phase /> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.