You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/04/18 20:50:36 UTC

[incubator-trafficcontrol] branch master updated (d13f91e -> 1245305)

This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git.


    from d13f91e  Add some authentication API integration tests
     new d7a81fb  Traffic Ops golang API servers test cleanup
     new ac22015  converted the swaggerdocs generation into a Docker infrastructure
     new bff6085  updated the README
     new a5c7a40  removed the dockgen.sh
     new 1245305  updated to support swagger to rst conversion using Docker

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../traffic_ops_golang/swaggerdocs/v13/.gitignore  |  3 +-
 .../traffic_ops_golang/swaggerdocs/v13/Dockerfile  | 25 ++++-----
 .../traffic_ops_golang/swaggerdocs/v13/README.md   | 62 ++++++++++++++--------
 .../swaggerdocs/v13/cors-http-server.py            | 33 ------------
 .../swaggerdocs/v13/docker-compose.yml             | 34 ++++++++----
 .../traffic_ops_golang/swaggerdocs/v13/docs.go     |  2 +-
 .../v13/{gen_docs.sh => gen_swaggerspec.sh}        | 10 ++--
 .../v13/swaggerspec-server/swaggerspec-server.go   | 26 +++++++++
 .../swaggerdocs/v13/swaggerspec/Dockerfile         | 24 +++++----
 .../swaggerdocs/v13/swaggerspec/docker-compose.yml | 30 ++++++-----
 .../swaggerdocs/v13/swaggerspec/requirements.txt   |  1 +
 .../swaggerdocs/v13/swaggerspec/swagger2rst.sh     | 23 ++++----
 12 files changed, 155 insertions(+), 118 deletions(-)
 copy traffic_portal/docker/reset.sh => traffic_ops/traffic_ops_golang/swaggerdocs/v13/Dockerfile (70%)
 mode change 100755 => 100644
 delete mode 100755 traffic_ops/traffic_ops_golang/swaggerdocs/v13/cors-http-server.py
 copy traffic_portal/docker/reset.sh => traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml (63%)
 mode change 100755 => 100644
 rename traffic_ops/traffic_ops_golang/swaggerdocs/v13/{gen_docs.sh => gen_swaggerspec.sh} (74%)
 create mode 100644 traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec-server/swaggerspec-server.go
 copy traffic_portal/docker/reset.sh => traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/Dockerfile (75%)
 mode change 100755 => 100644
 copy traffic_portal/build/etc/logrotate.d/traffic_portal-access => traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/docker-compose.yml (77%)
 create mode 100644 traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/requirements.txt
 copy traffic_portal/docker/reset.sh => traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/swagger2rst.sh (77%)

-- 
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.

[incubator-trafficcontrol] 02/05: converted the swaggerdocs generation into a Docker infrastructure

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit ac22015279564a6c231fa531fb254e12fc47b251
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Tue Apr 17 10:29:30 2018 -0600

    converted the swaggerdocs generation into a Docker infrastructure
---
 .../traffic_ops_golang/swaggerdocs/v13/README.md   | 34 ++++++++++------------
 .../swaggerdocs/v13/docker-compose.yml             | 15 +++++++---
 .../swaggerdocs/v13/docker/Dockerfile              | 28 ++++--------------
 .../v13/{gen_docs.sh => gen_swaggerspec.sh}        |  7 +++--
 .../swaggerdocs/v13/swagger-server/Dockerfile      | 29 ------------------
 .../swaggerspec-server.go}                         |  8 +++--
 6 files changed, 42 insertions(+), 79 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
index 19fff3d..f92bbbd 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
@@ -23,32 +23,28 @@ This directory contains the Go structs that glue together the Swagger 2.0 metada
 
 ### Setup
 
-See the install documentation for [https://github.com/go-swagger/go-swagger](go-swagger)
+* Install Docker for your platform:
+[https://docs.docker.com/install](https://docs.docker.com/install)
 
+* Install Docker Compose for your platform:
+[https://docs.docker.com/compose/install](https://docs.docker.com/compose/install)
 
-### Generate your Documentation
+### Running
 
-The **gen_docs.sh** script will scan all the Go files in the swaggerdocs directory and extract out all of the swagger meta tags that are embedded as comments.  The output of the **gen_docs.sh** script will be the **swagger.json** spec file.
+The docker-compose.yml will start 2 services a custom http service for hosting the `swaggerspec/swagger.json` and the Swagger UI.  
 
-### Verifying your Documentation
+To start the Swagger UI services just run:
 
-Once the **swagger.json** spec file has been generated it needs to to be served over http so that you can validate it using the Swagger Editor.  
+```$ docker-compose up```
 
-See the following steps:
+Once started navigate your browser to [http://localhost:8080](http://localhost:8080)
 
-*    Execute the **cors-http-server.py** (this will start a server on **http://localhost:8000**
-  so that you can point to it using the [https://editor.swagger.io](Swagger Editor).  
-  
-  `$ ./cors-http-server.py`
+### Generating your Swagger Spec File
 
-*    Navigate to [https://editor.swagger.io](Swagger Editor)
-    
-*    Use File->Import URL then plugin **http://localhost:8000**
-	* At this point the Swagger Editor will convert the **swagger.json** to yaml format and show the resulting documentation rendered as html.
+The **gen_swaggerspec.sh** script will scan all the Go files in the swaggerdocs directory and extract out all of the swagger meta tags that are embedded as comments.  The output of the **gen_swaggerspec.sh** script will be the **swaggerspec/swagger.json** spec file. 
 
-	OR
-	
-*	 Install the [https://swagger.io/swagger-ui/](Swagger UI) yourself and run locally.
-	
-  
+While the Docker services are running, just re-run **gen_swaggerspec.sh** and hit refresh on the page to see the Swagger doc updates in real time.
 
+### Verifying your Documentation
+
+Once the **swagger.json** spec file has been generated it needs to to be served over http so that you can validate it using the Swagger Editor.  
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
index ad92633..696438c 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
@@ -1,15 +1,22 @@
 version: '3.6'
- 
+
 services:
-   swagger-generator:
+   swagger-spec-server:
      build:
        context: .
        dockerfile: ./docker/Dockerfile
      ports:
        - 8000:8000
      volumes:
-       - output:/output
+       - ./swaggerspec:/swaggerspec
+
+   swagger-ui:
+     image: swaggerapi/swagger-ui
+     ports:
+       - 8080:8080
+     environment:
+       - API_URL=http://localhost:8000/swaggerspec/swagger.json
 
 volumes:
-    output:
+    swaggerspec:
 
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
index e89ae50..fb3095f 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
@@ -15,30 +15,14 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+FROM golang:1.10.1 AS go-swagger
 
-FROM golang:1.10.1 AS swagger-gen
-
-RUN mkdir /go/src/v13
-WORKDIR /go/src/v13
-ADD . .
-
-RUN mkdir /output
-
-RUN go get -d -v ./...
-RUN go install -v ./...
-RUN go get -u github.com/go-swagger/go-swagger/cmd/swagger
-
-CMD ["./gen_docs.sh"]
-
+#  Swagger Spec Server
 FROM golang:1.10.1 AS swagger-server
 
-#RUN mkdir /usr/src/swagger-server
-
-ADD ./swagger-server /usr/src/swagger-server
-WORKDIR /usr/src/swagger-server
-
-
-COPY --from=swagger-gen /output /output
+ADD /swaggerspec .
+ADD ./swaggerspec-server /usr/src/swaggerspec-server
+WORKDIR /usr/src/swaggerspec-server
 
 RUN go build 
-CMD ["./swagger-server"]
+ENTRYPOINT ["./swaggerspec-server"]
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_docs.sh b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_swaggerspec.sh
similarity index 81%
rename from traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_docs.sh
rename to traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_swaggerspec.sh
index 02ccec2..ce06d60 100755
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_docs.sh
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_swaggerspec.sh
@@ -19,5 +19,8 @@
 
 unset DEBUG
 #export DEBUG=true
-swagger generate spec -o /output/swagger.json
-echo "successfully generated swagger output file: ./swagger.json"
+OUTPUT_DIR=swaggerspec
+SWAGGER_SPEC_FILE=$OUTPUT_DIR/swagger.json
+mkdir -p $OUTPUT_DIR
+swagger generate spec -o $SWAGGER_SPEC_FILE
+echo "successfully generated swagger output file: $SWAGGER_SPEC_FILE"
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/Dockerfile
deleted file mode 100644
index 8deba91..0000000
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/Dockerfile
+++ /dev/null
@@ -1,29 +0,0 @@
-# 
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-FROM golang:1.10.1 AS swagger-server
-
-WORKDIR /usr/src/app
-COPY /output/swagger.json .
-
-ADD . .
-RUN go build 
-
-COPY --from=swagger-gen /output /output
-
-CMD ["./app"]
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/swagger-server.go b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec-server/swaggerspec-server.go
similarity index 60%
rename from traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/swagger-server.go
rename to traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec-server/swaggerspec-server.go
index a873ad7..6d27c1b 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/swagger-server.go
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec-server/swaggerspec-server.go
@@ -7,18 +7,20 @@ import (
 )
 
 func main() {
+	hostName := flag.String("h", "localhost", "hostname to serve on")
 	port := flag.String("p", "8000", "port to serve on")
 	flag.Parse()
 
-	swaggerFile := "swagger.json"
+	swaggerFile := "/swaggerspec/swagger.json"
 
-	http.HandleFunc("/swagger.json", func(w http.ResponseWriter, r *http.Request) {
+	http.HandleFunc(swaggerFile, func(w http.ResponseWriter, r *http.Request) {
 		w.Header().Set("Access-Control-Allow-Credentials", "true")
 		w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie")
 		w.Header().Set("Access-Control-Allow-Methods", "POST,GET,OPTIONS,PUT,DELETE")
 		w.Header().Set("Access-Control-Allow-Origin", "*")
 		http.ServeFile(w, r, swaggerFile)
 	})
-	log.Printf("Serving %s on HTTP port: %s\n", swaggerFile, *port)
+	log.Printf("Serving swagger spec file here: http://%s:%s%s\n", *hostName, *port, swaggerFile)
+	log.Printf("Serving Swagger UI here: http://localhost:8080\n")
 	log.Fatal(http.ListenAndServe(":"+*port, nil))
 }

-- 
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.

[incubator-trafficcontrol] 05/05: updated to support swagger to rst conversion using Docker

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit 1245305051680727de02a30326d936092c84b428
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Wed Apr 18 09:00:38 2018 -0600

    updated to support swagger to rst conversion using Docker
    
    updated to point out the debug flag
    
    updated docs for docker-compose info
    
    updated the base url
    
    moved Dockerfile to top dir
    
    added swagger2rst.sh
    
    updated gitignore
    
    added files for swaggerspec to rst
---
 .../traffic_ops_golang/swaggerdocs/v13/.gitignore  |  3 +-
 .../swaggerdocs/v13/{docker => }/Dockerfile        |  1 +
 .../traffic_ops_golang/swaggerdocs/v13/README.md   | 42 ++++++++++++++++++----
 .../swaggerdocs/v13/docker-compose.yml             | 20 ++++++++++-
 .../traffic_ops_golang/swaggerdocs/v13/docs.go     |  2 +-
 .../swaggerdocs/v13/gen_swaggerspec.sh             |  3 +-
 .../v13/{docker => swaggerspec}/Dockerfile         | 18 +++++-----
 .../Dockerfile => swaggerspec/docker-compose.yml}  | 20 ++++++-----
 .../swaggerdocs/v13/swaggerspec/requirements.txt   |  1 +
 .../Dockerfile => swaggerspec/swagger2rst.sh}      | 17 ++++-----
 10 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/.gitignore b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/.gitignore
index 168aa94..3ccf628 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/.gitignore
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/.gitignore
@@ -1 +1,2 @@
-swagger.json
+swaggerspec/swagger.json
+swaggerspec/v13_api_docs.rst
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/Dockerfile
similarity index 99%
copy from traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
copy to traffic_ops/traffic_ops_golang/swaggerdocs/v13/Dockerfile
index fb3095f..4f6fd1f 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/Dockerfile
@@ -15,6 +15,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+ 
 FROM golang:1.10.1 AS go-swagger
 
 #  Swagger Spec Server
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
index 392e4e2..2153783 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
@@ -17,9 +17,9 @@
     under the License.
 -->
 
-#### `./swaggerdocs` 
-This directory contains the Go structs that glue together the Swagger 2.0 metadata that will generate the Traffic Ops API documentation using [go-swagger](https://github.com/go-swagger/go-swagger) meta tags.  The Traffic Ops API documentation is maintained by modifying the Go files in this directory that point to the **incubator-trafficcontrol/lib/go-tc/*.go** structs that render the Traffic Ops Go Proxy API's.
+#### `./swaggerdocs` overview
 
+This directory contains the Go structs that glue together the Swagger 2.0 metadata that will generate the Traffic Ops API documentation using the [go-swagger](https://github.com/go-swagger/go-swagger) meta tags.  The Traffic Ops API documentation is maintained by modifying the Go files in this directory and the Go structs that they reference from here **incubator-trafficcontrol/lib/go-tc/*.go**.  These combination of these two areas of .go files will produce Swagger documentation for the [...]
 
 ### Setup
 
@@ -29,18 +29,46 @@ This directory contains the Go structs that glue together the Swagger 2.0 metada
 * Install Docker Compose for your platform:
 [https://docs.docker.com/compose/install](https://docs.docker.com/compose/install)
 
+### Generating your Swagger Spec File
+
+The **gen_swaggerspec.sh** script will scan all the Go files in the swaggerdocs directory and extract out all of the swagger meta tags that are embedded as comments.  The output of the **gen_swaggerspec.sh** script will be the **swaggerspec/swagger.json** spec file. 
+
+While the Docker services are running, just re-run **gen_swaggerspec.sh** and hit refresh on the page to see the Swagger doc updates in real time.
+
 ### Running the web services
 
-The `docker-compose.yml` will start 2 services a custom http service for hosting the `swaggerspec/swagger.json` and the Swagger UI.  
+Once your `swaggerspec/swagger.json` file has been generated you will want to render it to verify it's contents with the HTTP web rendering services.
+
+The `docker-compose.yml` will start two rendering services, a custom http service for hosting the `swaggerspec/swagger.json` and the Swagger UI.  
 
-To start the Swagger UI services just run:
+To start the Swagger UI services (and build them if not already built) just run:
 
 ```$ docker-compose up```
 
+NOTE: Iterative Workflow Tips:
+
+Blow away only the local images (excluding remote ones) and bring down the container:
+```$ docker-compose down --rmi local```
+
+Blow away all the images (including remote ones) and bring down the container:
+```$ docker-compose down --rmi all```
+
 Once started navigate your browser to [http://localhost:8080](http://localhost:8080)
 
-### Generating your Swagger Spec File
+### Converting the swaggerspec/swagger.json to .rst
 
-The **gen_swaggerspec.sh** script will scan all the Go files in the swaggerdocs directory and extract out all of the swagger meta tags that are embedded as comments.  The output of the **gen_swaggerspec.sh** script will be the **swaggerspec/swagger.json** spec file. 
+After you generate the `swaggerspec/swagger.json` from the steps above use the `swaggerspec` Docker Compose file to convert the `swagger.json` to .rst so that it can merged in with the existing Traffic Control documentation.
+
+* `$ cd swaggerspec`
+* `$ docker-compose up` - will convert the `swagger.json` in this directory into `v13_api_docs.rst`
+* `$ cp v13_api_docs.rst ../../../../../docs/source/development/traffic_ops_api`
+* `$ cd ../../../../../docs`
+* `$ make` - will generate all the Sphinx documentation along with the newly generated TO Swagger API 1.3 docs
+
+NOTE: Iterative Workflow Tips:
+
+Blow away only the local images (excluding remote ones) and bring down the container:
+```$ docker-compose down --rmi local```
 
-While the Docker services are running, just re-run **gen_swaggerspec.sh** and hit refresh on the page to see the Swagger doc updates in real time.
\ No newline at end of file
+Blow away all the images (including remote ones) and bring down the container:
+```$ docker-compose down --rmi all```
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
index 696438c..98a09ab 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
@@ -1,10 +1,28 @@
+# 
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+ 
 version: '3.6'
 
 services:
    swagger-spec-server:
      build:
        context: .
-       dockerfile: ./docker/Dockerfile
+       dockerfile: ./Dockerfile
      ports:
        - 8000:8000
      volumes:
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docs.go b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docs.go
index 730a8c7..11ecc71 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docs.go
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docs.go
@@ -6,7 +6,7 @@
  This documentation is fully compliant with the Swagger 2.0 specification
 
      Schemes: http, https
-	 Host: localhost:8443
+	 Host: your-traffic-ops
      BasePath: /api/1.3
      Version: 1.3
      License: Apache 2 https://github.com/apache/incubator-trafficcontrol/blob/master/LICENSE
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_swaggerspec.sh b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_swaggerspec.sh
index ce06d60..edeca44 100755
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_swaggerspec.sh
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_swaggerspec.sh
@@ -17,8 +17,9 @@
 #    specific language governing permissions and limitations
 #    under the License.
 
-unset DEBUG
+# Uncomment (or set in your environment) to enable debug output for the swagger generation
 #export DEBUG=true
+
 OUTPUT_DIR=swaggerspec
 SWAGGER_SPEC_FILE=$OUTPUT_DIR/swagger.json
 mkdir -p $OUTPUT_DIR
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/Dockerfile
similarity index 75%
copy from traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
copy to traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/Dockerfile
index fb3095f..94b469b 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/Dockerfile
@@ -15,14 +15,16 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-FROM golang:1.10.1 AS go-swagger
+ 
+FROM python:2
 
-#  Swagger Spec Server
-FROM golang:1.10.1 AS swagger-server
+WORKDIR /usr/src/app
+RUN mkdir /swagger2rst
 
-ADD /swaggerspec .
-ADD ./swaggerspec-server /usr/src/swaggerspec-server
-WORKDIR /usr/src/swaggerspec-server
+COPY requirements.txt ./
+RUN pip install --no-cache-dir -r requirements.txt
 
-RUN go build 
-ENTRYPOINT ["./swaggerspec-server"]
+ADD . .
+ADD swagger.json .
+
+CMD [ "./swagger2rst.sh" ]
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/docker-compose.yml
similarity index 75%
copy from traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
copy to traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/docker-compose.yml
index fb3095f..c461f96 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/docker-compose.yml
@@ -15,14 +15,18 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-FROM golang:1.10.1 AS go-swagger
+ 
+version: '3.6'
 
-#  Swagger Spec Server
-FROM golang:1.10.1 AS swagger-server
+services:
+   to-rst:
+     build:
+       context: .
+       dockerfile: ./Dockerfile
+     volumes:
+       - .:/swagger2rst
 
-ADD /swaggerspec .
-ADD ./swaggerspec-server /usr/src/swaggerspec-server
-WORKDIR /usr/src/swaggerspec-server
 
-RUN go build 
-ENTRYPOINT ["./swaggerspec-server"]
+volumes:
+    swagger2rst:
+
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/requirements.txt b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/requirements.txt
new file mode 100644
index 0000000..96c9e84
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/requirements.txt
@@ -0,0 +1 @@
+swagger2rst
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/swagger2rst.sh
old mode 100644
new mode 100755
similarity index 75%
rename from traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
rename to traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/swagger2rst.sh
index fb3095f..ae59737
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swaggerspec/swagger2rst.sh
@@ -1,3 +1,5 @@
+#!/usr/bin/env bash
+
 # 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -15,14 +17,9 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-FROM golang:1.10.1 AS go-swagger
-
-#  Swagger Spec Server
-FROM golang:1.10.1 AS swagger-server
-
-ADD /swaggerspec .
-ADD ./swaggerspec-server /usr/src/swaggerspec-server
-WORKDIR /usr/src/swaggerspec-server
 
-RUN go build 
-ENTRYPOINT ["./swaggerspec-server"]
+OUTPUT_DIR=/swagger2rst
+OUTPUT_FILE=v13_api_docs.rst
+RST_FILE=$OUTPUT_DIR/$OUTPUT_FILE
+swg2rst swagger.json -f rst -o $RST_FILE
+echo "Created $OUTPUT_FILE from swagger.json"

-- 
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.

[incubator-trafficcontrol] 03/05: updated the README

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit bff608578d14b07aa70da43545cfba488c46ef5b
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Tue Apr 17 12:13:55 2018 -0600

    updated the README
---
 traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
index f92bbbd..392e4e2 100644
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/README.md
@@ -29,9 +29,9 @@ This directory contains the Go structs that glue together the Swagger 2.0 metada
 * Install Docker Compose for your platform:
 [https://docs.docker.com/compose/install](https://docs.docker.com/compose/install)
 
-### Running
+### Running the web services
 
-The docker-compose.yml will start 2 services a custom http service for hosting the `swaggerspec/swagger.json` and the Swagger UI.  
+The `docker-compose.yml` will start 2 services a custom http service for hosting the `swaggerspec/swagger.json` and the Swagger UI.  
 
 To start the Swagger UI services just run:
 
@@ -43,8 +43,4 @@ Once started navigate your browser to [http://localhost:8080](http://localhost:8
 
 The **gen_swaggerspec.sh** script will scan all the Go files in the swaggerdocs directory and extract out all of the swagger meta tags that are embedded as comments.  The output of the **gen_swaggerspec.sh** script will be the **swaggerspec/swagger.json** spec file. 
 
-While the Docker services are running, just re-run **gen_swaggerspec.sh** and hit refresh on the page to see the Swagger doc updates in real time.
-
-### Verifying your Documentation
-
-Once the **swagger.json** spec file has been generated it needs to to be served over http so that you can validate it using the Swagger Editor.  
+While the Docker services are running, just re-run **gen_swaggerspec.sh** and hit refresh on the page to see the Swagger doc updates in real time.
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.

[incubator-trafficcontrol] 04/05: removed the dockgen.sh

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit a5c7a4097a30871c40c18f50a7915fa983688190
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Tue Apr 17 13:58:48 2018 -0600

    removed the dockgen.sh
---
 traffic_ops/traffic_ops_golang/swaggerdocs/v13/dockgen.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/dockgen.sh b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/dockgen.sh
deleted file mode 100755
index c2bed7f..0000000
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/dockgen.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-rm ./swagger.json
-docker build -t tc-swaggerdocs -f Dockerfile-swagger-gen .
-docker run --rm -it -v `(pwd)`:/output tc-swaggerdocs

-- 
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.

[incubator-trafficcontrol] 01/05: Traffic Ops golang API servers test cleanup

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit d7a81fb583ace3ed5c995440b1c995c9fadcc8ec
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Mon Apr 16 09:37:45 2018 -0600

    Traffic Ops golang API servers test cleanup
---
 .../swaggerdocs/v13/cors-http-server.py            | 33 ----------------
 .../swaggerdocs/v13/docker-compose.yml             | 15 ++++++++
 .../swaggerdocs/v13/docker/Dockerfile              | 44 ++++++++++++++++++++++
 .../traffic_ops_golang/swaggerdocs/v13/dockgen.sh  |  5 +++
 .../traffic_ops_golang/swaggerdocs/v13/gen_docs.sh |  4 +-
 .../swaggerdocs/v13/swagger-server/Dockerfile      | 29 ++++++++++++++
 .../v13/swagger-server/swagger-server.go           | 24 ++++++++++++
 7 files changed, 119 insertions(+), 35 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/cors-http-server.py b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/cors-http-server.py
deleted file mode 100755
index 3c1687f..0000000
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/cors-http-server.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-
-
- # Licensed to the Apache Software Foundation (ASF) under one
- # or more contributor license agreements.  See the NOTICE file
- # distributed with this work for additional information
- # regarding copyright ownership.  The ASF licenses this file
- # to you 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.
-
-from SimpleHTTPServer import SimpleHTTPRequestHandler
-import BaseHTTPServer
-
-#
-# Simple HTTP server that serves up port 8000 with the CORS header enabled
-#
-class CORSRequestHandler (SimpleHTTPRequestHandler):
-    def end_headers (self):
-        self.send_header('Access-Control-Allow-Origin', '*')
-        SimpleHTTPRequestHandler.end_headers(self)
-
-if __name__ == '__main__':
-    BaseHTTPServer.test(CORSRequestHandler, BaseHTTPServer.HTTPServer)
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
new file mode 100644
index 0000000..ad92633
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker-compose.yml
@@ -0,0 +1,15 @@
+version: '3.6'
+ 
+services:
+   swagger-generator:
+     build:
+       context: .
+       dockerfile: ./docker/Dockerfile
+     ports:
+       - 8000:8000
+     volumes:
+       - output:/output
+
+volumes:
+    output:
+
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
new file mode 100644
index 0000000..e89ae50
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/docker/Dockerfile
@@ -0,0 +1,44 @@
+# 
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+FROM golang:1.10.1 AS swagger-gen
+
+RUN mkdir /go/src/v13
+WORKDIR /go/src/v13
+ADD . .
+
+RUN mkdir /output
+
+RUN go get -d -v ./...
+RUN go install -v ./...
+RUN go get -u github.com/go-swagger/go-swagger/cmd/swagger
+
+CMD ["./gen_docs.sh"]
+
+FROM golang:1.10.1 AS swagger-server
+
+#RUN mkdir /usr/src/swagger-server
+
+ADD ./swagger-server /usr/src/swagger-server
+WORKDIR /usr/src/swagger-server
+
+
+COPY --from=swagger-gen /output /output
+
+RUN go build 
+CMD ["./swagger-server"]
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/dockgen.sh b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/dockgen.sh
new file mode 100755
index 0000000..c2bed7f
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/dockgen.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+rm ./swagger.json
+docker build -t tc-swaggerdocs -f Dockerfile-swagger-gen .
+docker run --rm -it -v `(pwd)`:/output tc-swaggerdocs
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_docs.sh b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_docs.sh
index a7c7154..02ccec2 100755
--- a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_docs.sh
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/gen_docs.sh
@@ -19,5 +19,5 @@
 
 unset DEBUG
 #export DEBUG=true
-swagger generate spec -o ./swagger.json
-echo "successfully generated the swagger.json file"
+swagger generate spec -o /output/swagger.json
+echo "successfully generated swagger output file: ./swagger.json"
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/Dockerfile b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/Dockerfile
new file mode 100644
index 0000000..8deba91
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/Dockerfile
@@ -0,0 +1,29 @@
+# 
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+FROM golang:1.10.1 AS swagger-server
+
+WORKDIR /usr/src/app
+COPY /output/swagger.json .
+
+ADD . .
+RUN go build 
+
+COPY --from=swagger-gen /output /output
+
+CMD ["./app"]
diff --git a/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/swagger-server.go b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/swagger-server.go
new file mode 100644
index 0000000..a873ad7
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/swaggerdocs/v13/swagger-server/swagger-server.go
@@ -0,0 +1,24 @@
+package main
+
+import (
+	"flag"
+	"log"
+	"net/http"
+)
+
+func main() {
+	port := flag.String("p", "8000", "port to serve on")
+	flag.Parse()
+
+	swaggerFile := "swagger.json"
+
+	http.HandleFunc("/swagger.json", func(w http.ResponseWriter, r *http.Request) {
+		w.Header().Set("Access-Control-Allow-Credentials", "true")
+		w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie")
+		w.Header().Set("Access-Control-Allow-Methods", "POST,GET,OPTIONS,PUT,DELETE")
+		w.Header().Set("Access-Control-Allow-Origin", "*")
+		http.ServeFile(w, r, swaggerFile)
+	})
+	log.Printf("Serving %s on HTTP port: %s\n", swaggerFile, *port)
+	log.Fatal(http.ListenAndServe(":"+*port, nil))
+}

-- 
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.