-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 90e8221
Showing
37 changed files
with
988 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Gojira Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | ||
with: | ||
ruby-version: '3.3.1' | ||
- run: bundle install | ||
- run: bundle exec rspec | ||
|
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,14 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
vendor/ | ||
local/ | ||
|
||
# rspec failure tracking | ||
.rspec_status | ||
test-files/ |
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,3 @@ | ||
--format documentation | ||
--color | ||
--require spec_helper |
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 @@ | ||
3.3.1 |
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,13 @@ | ||
FROM ruby:3.3.1 | ||
|
||
RUN curl -sL https://github.com/Kong/deck/releases/download/v1.39.4/deck_1.39.4_linux_arm64.tar.gz -o deck.tar.gz | ||
RUN tar -xf deck.tar.gz -C /tmp | ||
RUN cp /tmp/deck /usr/local/bin/ | ||
|
||
COPY . /app | ||
|
||
WORKDIR /app | ||
|
||
RUN bundle install | ||
RUN gem build gojira.gemspec | ||
RUN gem install *.gem |
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,8 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } | ||
|
||
# Specify your gem's dependencies in gojira.gemspec | ||
gemspec |
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,75 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
gojira (0.1.0) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
ast (2.4.2) | ||
coderay (1.1.3) | ||
diff-lcs (1.5.1) | ||
json (2.7.2) | ||
language_server-protocol (3.17.0.3) | ||
method_source (1.1.0) | ||
parallel (1.25.1) | ||
parser (3.3.3.0) | ||
ast (~> 2.4.1) | ||
racc | ||
pry (0.14.2) | ||
coderay (~> 1.1) | ||
method_source (~> 1.0) | ||
racc (1.8.0) | ||
rainbow (3.1.1) | ||
rake (10.5.0) | ||
regexp_parser (2.9.2) | ||
rexml (3.3.0) | ||
strscan | ||
rspec (3.13.0) | ||
rspec-core (~> 3.13.0) | ||
rspec-expectations (~> 3.13.0) | ||
rspec-mocks (~> 3.13.0) | ||
rspec-core (3.13.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-expectations (3.13.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-mocks (3.13.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-support (3.13.1) | ||
rubocop (1.64.1) | ||
json (~> 2.3) | ||
language_server-protocol (>= 3.17.0) | ||
parallel (~> 1.10) | ||
parser (>= 3.3.0.2) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 1.8, < 3.0) | ||
rexml (>= 3.2.5, < 4.0) | ||
rubocop-ast (>= 1.31.1, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 2.4.0, < 3.0) | ||
rubocop-ast (1.31.3) | ||
parser (>= 3.3.1.0) | ||
ruby-progressbar (1.13.0) | ||
strscan (3.1.0) | ||
thor (1.3.1) | ||
unicode-display_width (2.5.0) | ||
yaml (0.3.0) | ||
|
||
PLATFORMS | ||
arm64-darwin-23 | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler (~> 2.5) | ||
gojira! | ||
pry | ||
rake (~> 10.0) | ||
rspec (~> 3.0) | ||
rubocop (~> 1.64) | ||
thor (~> 1.3.1) | ||
yaml | ||
|
||
BUNDLED WITH | ||
2.5.9 |
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,41 @@ | ||
# Gojira | ||
|
||
**Maintaining order within the Kong realm** [[ref](https://en.wikipedia.org/wiki/Gojira)] | ||
|
||
<img src="docs/gojira.png" alt="drawing" width="500"/> | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
```ruby | ||
gem 'gojira' | ||
``` | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install gojira | ||
|
||
## Usage | ||
|
||
## Commands | ||
|
||
### Env | ||
|
||
* Lint: | ||
* Searches through env directory | ||
* get list of all products/services | ||
* checks if their upstream info is available across all clusters of that env | ||
* service level validations(PCI/NPCI service tags, no route with tags) | ||
* Gives out errors of each validation level in JSON | ||
|
||
* Generate: | ||
* Merge product services files into one config | ||
* Substitute kong upstreams for respective compliance type and DC | ||
* Merge all product configs into one file | ||
* Not to interfere and merge global conf and certs, they will be passed with -s | ||
* Can include local config here later |
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,8 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task default: :spec |
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,15 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/setup' | ||
require 'gojira' | ||
|
||
# You can add fixtures and/or initialization code here to make experimenting | ||
# with your gem easier. You can also use a different console, if you like. | ||
|
||
# (If you use this, don't forget to add pry to your Gemfile!) | ||
# require "pry" | ||
# Pry.start | ||
|
||
require 'irb' | ||
IRB.start(__FILE__) |
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,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,20 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
lib_path = File.expand_path('../lib', __dir__) | ||
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path) | ||
|
||
begin | ||
require 'pry-byebug' if ENV['GOJIRA_ENV'] == 'debug' | ||
rescue LoadError | ||
# do nothing | ||
end | ||
|
||
require 'gojira' | ||
|
||
Signal.trap('INT') do | ||
warn("\n#{caller.join("\n")}: interrupted") | ||
exit(1) | ||
end | ||
|
||
Gojira::CLI.start(ARGV) |
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,47 @@ | ||
# frozen_string_literal: true | ||
|
||
lib = File.expand_path('lib', __dir__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'gojira/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = 'gojira' | ||
spec.version = Gojira::VERSION | ||
spec.authors = ['Kumar Abhijeet'] | ||
spec.email = ['kumarabhijeet1202@gmail.com'] | ||
|
||
spec.summary = 'A ruby gem to generate Kong configs across multiple clusters to achieve service equivalence' | ||
spec.description = 'A ruby gem to generate Kong configs across multiple clusters to achieve service equivalence' | ||
spec.homepage = 'https://github.com/kumar1202/gojira/tree/main' | ||
|
||
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' | ||
# to allow pushing to a single host or delete this section to allow pushing to any host. | ||
if spec.respond_to?(:metadata) | ||
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" | ||
|
||
spec.metadata['homepage_uri'] = spec.homepage | ||
spec.metadata['source_code_uri'] = 'https://github.com/PL-infrastructure-platform/gojira/tree/main' | ||
spec.metadata['changelog_uri'] = 'https://github.com/PL-infrastructure-platform/gojira/tree/main' | ||
else | ||
raise 'RubyGems 2.0 or newer is required to protect against ' \ | ||
'public gem pushes.' | ||
end | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
spec.files = Dir.chdir(File.expand_path(__dir__)) do | ||
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } | ||
end | ||
spec.bindir = 'exe' | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_development_dependency 'bundler', '~> 2.5' | ||
spec.add_development_dependency 'rake', '~> 10.0' | ||
spec.add_development_dependency 'rspec', '~> 3.0' | ||
spec.add_development_dependency 'rubocop', '~> 1.64' | ||
spec.add_development_dependency 'thor', '~> 1.3.1' | ||
spec.add_development_dependency 'yaml' | ||
|
||
spec.add_development_dependency 'pry' | ||
end |
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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'thor' | ||
require_relative 'gojira/version' | ||
require_relative 'gojira/deck/base' | ||
require_relative 'gojira/deck/gateway' | ||
require_relative 'gojira/deck/file' | ||
require_relative 'gojira/cli' | ||
|
||
module Gojira | ||
class << self | ||
attr_writer :config | ||
|
||
def config | ||
@config ||= Config.new | ||
end | ||
|
||
def configure | ||
yield(config) | ||
end | ||
|
||
def reset! | ||
@config = nil | ||
end | ||
end | ||
end |
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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Gojira | ||
module APIOps | ||
class Merge | ||
attr_accessor :errors | ||
attr_reader :gateway_folder, :env_dir, :cluster_file | ||
|
||
def initialize | ||
@gateway_folder = gateway_folder | ||
@env_dir = env_dir | ||
@cluster_file = cluster_file | ||
@errors = [] | ||
end | ||
|
||
def execute | ||
end | ||
end | ||
end | ||
end |
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,54 @@ | ||
# frozen_string_literal: true | ||
|
||
module Gojira | ||
module APIOps | ||
class Validations | ||
attr_accessor :errors | ||
attr_reader :gateway_folder, :env_dir, :cluster_file | ||
|
||
def initialize(gateway_folder, env_dir, cluster_file) | ||
@gateway_folder = gateway_folder | ||
@env_dir = env_dir | ||
@cluster_file = cluster_file | ||
@errors = [] | ||
end | ||
|
||
def execute | ||
validate_env | ||
validate_cluster_file | ||
validate_env_dir | ||
validate_service | ||
validate_upstreams | ||
end | ||
|
||
def validate_env | ||
Dir.open(@gateway_folder + @env_dir) | ||
# Check env name if is allowed | ||
end | ||
|
||
def validate_cluster_file | ||
# Check if all env have defined DCs and each DC have pci and npci control planes | ||
end | ||
|
||
def validate_env_dir | ||
# check the structure of the env dir: | ||
# product_group -> one or more services | ||
# product_group has a valid upstreams file | ||
# figure out if any unknown files are present | ||
end | ||
|
||
def validate_service(service_file) | ||
# Check if only one service is defined per file | ||
# Check if the correct pci/non-pci tag is present on the service | ||
# Check if routes don't have tags | ||
# Check if | ||
end | ||
|
||
def validate_upstreams(upstreams_file) | ||
# Check if upstreams for all services in the product_group is present or not | ||
# Check if both pci and non-pci upstreams for a service are defined | ||
# Check if all targets of a given upstream add up to 100 | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.