-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide useful utility to fetch domain attrs (#2803)
Signed-off-by: Henry Avetisyan <[email protected]>
- Loading branch information
1 parent
8161f55
commit 3c51ddd
Showing
10 changed files
with
407 additions
and
0 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,58 @@ | ||
# | ||
# Makefile to build ZMS Domain Attributes utility | ||
# Prerequisite: Go development environment | ||
# | ||
# Copyright The Athenz Authors | ||
# Licensed under the Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
|
||
GOPKGNAME = github.com/AthenZ/athenz/utils/zms-domainattrs | ||
PKG_DATE=$(shell date '+%Y-%m-%dT%H:%M:%S') | ||
BINARY=zms-domainattrs | ||
SRC=zms-domainattrs.go | ||
|
||
# check to see if go utility is installed | ||
GO := $(shell command -v go 2> /dev/null) | ||
GOPATH := $(shell pwd) | ||
export $(GOPATH) | ||
|
||
ifdef GO | ||
|
||
# we need to make sure we have go 1.19+ | ||
# the output for the go version command is: | ||
# go version go1.19 darwin/amd64 | ||
|
||
GO_VER_GTEQ := $(shell expr `go version | cut -f 3 -d' ' | cut -f2 -d.` \>= 19) | ||
ifneq "$(GO_VER_GTEQ)" "1" | ||
all: | ||
@echo "Please install 1.19.x or newer version of golang" | ||
else | ||
|
||
.PHONY: vet fmt linux darwin | ||
all: vet fmt linux darwin | ||
|
||
endif | ||
|
||
else | ||
|
||
all: | ||
@echo "go is not available please install golang" | ||
|
||
endif | ||
|
||
vet: | ||
go vet . | ||
|
||
fmt: | ||
go fmt . | ||
|
||
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 |
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,58 @@ | ||
zms-domainattrs | ||
=============== | ||
|
||
The utility looks at the domains specified in a given file (one domain per line) and | ||
for each domain, it retrieves and displays the requested attributes associated with | ||
the domain. | ||
|
||
The utility supports the following list of attributes: | ||
|
||
- businessService | ||
- productId | ||
- account | ||
- gcpProject | ||
- gcpProjectNumber | ||
- azureSubscription | ||
- azureTenant | ||
- azureClient | ||
- org | ||
- slackChannel | ||
- environment | ||
|
||
For businessService and productId attributes, if the given domain does not have the | ||
attribute set, the utility will look at the parent domain to see if the attribute | ||
is set there. If the attribute is set in the parent domain, the utility will display | ||
the value from the parent domain. It will continue to look at the parent domains until | ||
it finds the attribute set, or it reaches the top level domain. | ||
|
||
## Usage | ||
|
||
``` | ||
zms-domainattrs -svc-key-file ./key.pem -svc-cert-file ./cert.pem -zms https://athenz.io:4443/zms/v1 -domain-file ./domain.txt -attrs businessService,account | ||
``` | ||
|
||
where domain.txt might contain: | ||
|
||
``` | ||
weather | ||
sports.prod | ||
sports.nhl | ||
sys.auth | ||
``` | ||
|
||
And the output might look like ('weather' domain does not have a businessService attribute and | ||
'sports.prod' domain does not have an account attribute): | ||
|
||
``` | ||
Domain,businessService,account | ||
weather,,123456 | ||
sports.prod,sports-service, | ||
sports.nhl,sports-service,123456 | ||
sys.auth,athenz,456789 | ||
``` | ||
|
||
## License | ||
|
||
Copyright The Athenz Authors | ||
|
||
Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.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,7 @@ | ||
// Copyright The Athenz Authors | ||
// Licensed under the terms of the Apache version 2.0 license. See LICENSE file for terms. | ||
|
||
// The utility looks at the domains specified in a given file (one domain per line) and | ||
// for each domain, it retrieves and displays the requested attributes associated with | ||
// the domain. | ||
package main |
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,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright The Athenz Authors | ||
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.12.5-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>zms-domainattrs</artifactId> | ||
<packaging>jar</packaging> | ||
<name>zms-domainattrs</name> | ||
<description>ZMS Domain Attribute Lookup 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>${maven-exec-plugin.version}</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>${maven-jar-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>default-jar</id> | ||
<phase /> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.