gjallarhorn 0.1.0.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f1803a8eea18b207eaee8efb506435449e7bc44e7b7d42f5641c937600f232f1
4
+ data.tar.gz: e34842e3170ebdc2ea1b51ec9fc66526985fc9c4a2c159bfcedc60bbaf980bd4
5
+ SHA512:
6
+ metadata.gz: 247368e61b771afc91243fade7d0cededffeac32be6252692a43d75abc35ca9445ccbfaad79a1ec0df6da68a3f5eed34f4ca7dbb6ee39350ab64cf8a0ed953ed
7
+ data.tar.gz: 7b1d4a4f148def633aa427874f5079ae38404099bea1ed858bb16f21e286b4433f31a9aca1f87c3cc1716c76150238c8bb9b22e194f2aad4847e87fc914dd0a7
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Ken C. Demanawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Gjallarhorn
2
+
3
+ Multi-cloud deployment guardian as legendary as Heimdall's horn.
4
+
5
+ > **⚠️ ALPHA RELEASE NOTICE**
6
+ > This gem is currently in alpha development and **NOT RECOMMENDED FOR PRODUCTION USE**. We are publishing this early version to RubyGems.org primarily to secure the `gjallarhorn` gem name. The API and functionality are subject to significant changes. Use at your own risk.
7
+
8
+ A Ruby gem that sounds across all cloud realms with secure, API-first deployments beyond SSH:
9
+
10
+ - AWS (SSM)
11
+ - Google Cloud Platform (Compute Engine API)
12
+ - Microsoft Azure (Run Command API)
13
+ - Self-hosted Docker (Docker API)
14
+ - Kubernetes (API)
15
+ - Hybrid/Multi-cloud deployments
16
+
17
+ ## Installation
18
+
19
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
20
+
21
+ Install the gem and add to the application's Gemfile by executing:
22
+
23
+ ```bash
24
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
25
+ ```
26
+
27
+ If bundler is not being used to manage dependencies, install the gem by executing:
28
+
29
+ ```bash
30
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ TODO: Write usage instructions here
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kanutocd/gjallarhorn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kanutocd/gjallarhorn/blob/main/CODE_OF_CONDUCT.md).
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the Gjallarhorn project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kanutocd/gjallarhorn/blob/main/CODE_OF_CONDUCT.md).
data/README.pdf ADDED
Binary file
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
File without changes
@@ -0,0 +1,182 @@
1
+ # deploy.yml - Universal Deployment Configuration
2
+ # Supports AWS, GCP, Azure, Docker, and Kubernetes
3
+
4
+ # Production environment using AWS SSM
5
+ production:
6
+ provider: aws
7
+ region: us-east-1
8
+ environment: production
9
+ services:
10
+ - name: web
11
+ ports: ["3000"]
12
+ replicas: 3
13
+ env:
14
+ RAILS_ENV: production
15
+ DATABASE_URL: postgres://prod-db
16
+ REDIS_URL: redis://prod-redis
17
+ - name: worker
18
+ ports: []
19
+ replicas: 2
20
+ env:
21
+ RAILS_ENV: production
22
+ QUEUE: critical,default
23
+
24
+ # Staging on Google Cloud Platform
25
+ staging:
26
+ provider: gcp
27
+ project_id: my-project-staging
28
+ zone: us-central1-a
29
+ environment: staging
30
+ services:
31
+ - name: web
32
+ ports: ["3000"]
33
+ replicas: 2
34
+ env:
35
+ RAILS_ENV: staging
36
+ DATABASE_URL: postgres://staging-db
37
+ - name: worker
38
+ ports: []
39
+ replicas: 1
40
+ env:
41
+ RAILS_ENV: staging
42
+
43
+ # Development on Azure
44
+ development:
45
+ provider: azure
46
+ subscription_id: "12345678-1234-1234-1234-123456789012"
47
+ resource_group: dev-resources
48
+ access_token: "your-azure-token"
49
+ environment: development
50
+ services:
51
+ - name: web
52
+ ports: ["3000"]
53
+ replicas: 1
54
+ env:
55
+ RAILS_ENV: development
56
+ DATABASE_URL: postgres://dev-db
57
+
58
+ # Self-hosted Docker environments
59
+ docker_production:
60
+ provider: docker
61
+ environment: production
62
+ hosts:
63
+ - url: tcp://docker1.company.com:2376
64
+ ssl_verify: true
65
+ cert_path: /path/to/cert.pem
66
+ key_path: /path/to/key.pem
67
+ ca_path: /path/to/ca.pem
68
+ - url: tcp://docker2.company.com:2376
69
+ ssl_verify: true
70
+ cert_path: /path/to/cert.pem
71
+ key_path: /path/to/key.pem
72
+ ca_path: /path/to/ca.pem
73
+ services:
74
+ - name: web
75
+ ports: ["3000"]
76
+ env:
77
+ RAILS_ENV: production
78
+ DATABASE_URL: postgres://prod-db:5432/myapp
79
+ REDIS_URL: redis://prod-redis:6379
80
+
81
+ # Kubernetes cluster (self-hosted or managed)
82
+ k8s_production:
83
+ provider: kubernetes
84
+ api_server: "https://k8s-api.company.com:6443"
85
+ api_version: "apps/v1"
86
+ namespace: production
87
+ auth_options:
88
+ bearer_token_file: "/var/run/secrets/kubernetes.io/serviceaccount/token"
89
+ ssl_options:
90
+ verify_ssl: true
91
+ ca_file: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
92
+ services:
93
+ - name: web
94
+ ports: [3000]
95
+ replicas: 5
96
+ env:
97
+ RAILS_ENV: production
98
+ DATABASE_URL: postgres://prod-db:5432/myapp
99
+ - name: worker
100
+ ports: []
101
+ replicas: 3
102
+ env:
103
+ RAILS_ENV: production
104
+ REDIS_URL: redis://prod-redis:6379
105
+
106
+ # Hybrid setup - Web on Kubernetes, Workers on AWS
107
+ hybrid_production:
108
+ provider: kubernetes # Primary provider
109
+ api_server: "https://k8s-cluster.com:6443"
110
+ namespace: production
111
+ auth_options:
112
+ bearer_token_file: "/path/to/token"
113
+
114
+ # Override for specific services
115
+ service_overrides:
116
+ worker:
117
+ provider: aws
118
+ region: us-east-1
119
+ instance_filter:
120
+ tags:
121
+ Role: worker
122
+ Environment: production
123
+
124
+ services:
125
+ - name: web
126
+ ports: [3000]
127
+ replicas: 10
128
+ env:
129
+ RAILS_ENV: production
130
+ - name: worker
131
+ ports: []
132
+ replicas: 5 # Will deploy to AWS instances instead
133
+ env:
134
+ RAILS_ENV: production
135
+
136
+ # Local development
137
+ local:
138
+ provider: docker
139
+ environment: development
140
+ hosts:
141
+ - url: unix:///var/run/docker.sock
142
+ ssl_verify: false
143
+ services:
144
+ - name: web
145
+ ports: ["3000"]
146
+ env:
147
+ RAILS_ENV: development
148
+ DATABASE_URL: postgres://localhost:5432/myapp_dev
149
+
150
+ # Multi-region AWS deployment
151
+ aws_multi_region:
152
+ provider: aws
153
+ regions:
154
+ - us-east-1
155
+ - us-west-2
156
+ - eu-west-1
157
+ environment: production
158
+ services:
159
+ - name: web
160
+ ports: ["3000"]
161
+ replicas_per_region: 2
162
+ env:
163
+ RAILS_ENV: production
164
+ DATABASE_URL: postgres://prod-db
165
+
166
+ # Canary deployment configuration
167
+ canary_production:
168
+ provider: kubernetes
169
+ api_server: "https://k8s-cluster.com:6443"
170
+ namespace: production
171
+ deployment_strategy: canary
172
+ canary_config:
173
+ initial_percentage: 10
174
+ increment_percentage: 25
175
+ health_check_interval: 30
176
+ rollback_on_failure: true
177
+ services:
178
+ - name: web
179
+ ports: [3000]
180
+ replicas: 10
181
+ env:
182
+ RAILS_ENV: production
data/exe/gjallarhorn ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "gjallarhorn"
5
+
6
+ Gjallarhorn::CLI.start(ARGV)
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ # AWS SSM Adapter
4
+ module Gjallarhorn
5
+ module Adapters
6
+ class AWSAdapter < Base
7
+ def initialize(config)
8
+ super
9
+ require "aws-sdk-ssm"
10
+ require "aws-sdk-ec2"
11
+ @ssm = Aws::SSM::Client.new(region: config[:region])
12
+ @ec2 = Aws::EC2::Client.new(region: config[:region])
13
+ end
14
+
15
+ def deploy(image:, environment:, services: [])
16
+ instances = get_instances_by_tags(environment)
17
+
18
+ commands = build_deployment_commands(image, services)
19
+
20
+ logger.info "Deploying #{image} to #{instances.size} AWS instances"
21
+
22
+ response = @ssm.send_command(
23
+ instance_ids: instances,
24
+ document_name: "AWS-RunShellScript",
25
+ parameters: {
26
+ "commands" => commands,
27
+ "executionTimeout" => ["3600"]
28
+ },
29
+ comment: "Deploy #{image} via Gjallarhorn"
30
+ )
31
+
32
+ wait_for_command_completion(response.command.command_id, instances)
33
+
34
+ # Verify health across all instances
35
+ services.each do |service|
36
+ wait_for_health(service)
37
+ end
38
+
39
+ logger.info "Deployment completed successfully"
40
+ end
41
+
42
+ def rollback(version:)
43
+ # Similar implementation for rollback
44
+ end
45
+
46
+ def status
47
+ instances = get_instances_by_tags(config[:environment])
48
+ instances.map do |instance_id|
49
+ {
50
+ instance: instance_id,
51
+ status: get_instance_status(instance_id)
52
+ }
53
+ end
54
+ end
55
+
56
+ def health_check(*)
57
+ # Implement health check via SSM command
58
+ true # Simplified
59
+ end
60
+
61
+ private
62
+
63
+ def get_instances_by_tags(environment)
64
+ resp = @ec2.describe_instances(
65
+ filters: [
66
+ { name: "tag:Environment", values: [environment] },
67
+ { name: "tag:Role", values: %w[web app] },
68
+ { name: "instance-state-name", values: ["running"] }
69
+ ]
70
+ )
71
+
72
+ resp.reservations.flat_map(&:instances).map(&:instance_id)
73
+ end
74
+
75
+ def build_deployment_commands(image, services)
76
+ [
77
+ "docker pull #{image}",
78
+ *services.map { |svc| "docker stop #{svc[:name]} || true" },
79
+ *services.map do |svc|
80
+ "docker run -d --name #{svc[:name]} " \
81
+ "#{svc[:ports].map { |p| "-p #{p}" }.join(" ")} " \
82
+ "#{svc[:env].map { |k, v| "-e #{k}=#{v}" }.join(" ")} " \
83
+ "#{image}"
84
+ end
85
+ ]
86
+ end
87
+
88
+ def wait_for_command_completion(command_id, _instances)
89
+ @ssm.wait_until(:command_executed, command_id: command_id) do |w|
90
+ w.max_attempts = 60
91
+ w.delay = 5
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+ require "logger"
5
+
6
+ # Base adapter interface
7
+ module Gjallarhorn
8
+ module Adapters
9
+ class Base
10
+ attr_reader :config, :logger
11
+
12
+ def initialize(config)
13
+ @config = config
14
+ @logger = Logger.new($stdout)
15
+ end
16
+
17
+ # Core deployment interface
18
+ def deploy(image:, environment:, services: [])
19
+ raise NotImplementedError, "Subclasses must implement deploy"
20
+ end
21
+
22
+ def rollback(version:)
23
+ raise NotImplementedError, "Subclasses must implement rollback"
24
+ end
25
+
26
+ def status
27
+ raise NotImplementedError, "Subclasses must implement status"
28
+ end
29
+
30
+ def health_check(service:)
31
+ raise NotImplementedError, "Subclasses must implement health_check"
32
+ end
33
+
34
+ def scale(service:, replicas:)
35
+ raise NotImplementedError, "Subclasses must implement scale"
36
+ end
37
+
38
+ def logs(service:, lines: 100)
39
+ raise NotImplementedError, "Subclasses must implement logs"
40
+ end
41
+
42
+ protected
43
+
44
+ def wait_for_health(service, timeout = 300)
45
+ start_time = Time.now
46
+ loop do
47
+ return true if health_check(service: service)
48
+
49
+ raise "Health check timeout for #{service}" if Time.now - start_time > timeout
50
+
51
+ sleep 5
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require_relative "deployer"
5
+ require_relative "configuration"
6
+
7
+ module Gjallarhorn
8
+ class CLI < Thor
9
+ desc "deploy ENVIRONMENT IMAGE", "Deploy an image to the specified environment"
10
+ option :config, aliases: "-c", default: "deploy.yml", desc: "Configuration file path"
11
+ def deploy(environment, image)
12
+ deployer = Deployer.new(options[:config])
13
+ deployer.deploy(environment, image)
14
+ rescue StandardError => e
15
+ puts "Deployment failed: #{e.message}"
16
+ exit 1
17
+ end
18
+
19
+ desc "status ENVIRONMENT", "Check deployment status for an environment"
20
+ option :config, aliases: "-c", default: "deploy.yml", desc: "Configuration file path"
21
+ def status(environment)
22
+ deployer = Deployer.new(options[:config])
23
+ result = deployer.status(environment)
24
+
25
+ puts "Status for #{environment}:"
26
+ result.each do |status_info|
27
+ puts " #{status_info}"
28
+ end
29
+ rescue StandardError => e
30
+ puts "Status check failed: #{e.message}"
31
+ exit 1
32
+ end
33
+
34
+ desc "rollback ENVIRONMENT VERSION", "Rollback to a previous version"
35
+ option :config, aliases: "-c", default: "deploy.yml", desc: "Configuration file path"
36
+ def rollback(environment, version)
37
+ deployer = Deployer.new(options[:config])
38
+ deployer.rollback(environment, version)
39
+ rescue StandardError => e
40
+ puts "Rollback failed: #{e.message}"
41
+ exit 1
42
+ end
43
+
44
+ desc "config", "Show current configuration"
45
+ option :config, aliases: "-c", default: "deploy.yml", desc: "Configuration file path"
46
+ def config
47
+ configuration = Configuration.new(options[:config])
48
+ puts configuration.to_yaml
49
+ rescue StandardError => e
50
+ puts "Configuration error: #{e.message}"
51
+ exit 1
52
+ end
53
+
54
+ desc "version", "Show Gjallarhorn version"
55
+ def version
56
+ puts Gjallarhorn::VERSION
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+
5
+ module Gjallarhorn
6
+ class Configuration
7
+ attr_reader :config_file, :data
8
+
9
+ def initialize(config_file = "deploy.yml")
10
+ @config_file = config_file
11
+ load_configuration
12
+ end
13
+
14
+ def environment(name)
15
+ env_config = @data[name.to_s]
16
+ raise ConfigurationError, "Environment '#{name}' not found in #{config_file}" unless env_config
17
+
18
+ env_config
19
+ end
20
+
21
+ def environments
22
+ @data.keys
23
+ end
24
+
25
+ def provider_for(environment)
26
+ env_config = environment(environment)
27
+ env_config["provider"]
28
+ end
29
+
30
+ def services_for(environment)
31
+ env_config = environment(environment)
32
+ env_config["services"] || []
33
+ end
34
+
35
+ def to_yaml
36
+ @data.to_yaml
37
+ end
38
+
39
+ private
40
+
41
+ def load_configuration
42
+ raise ConfigurationError, "Configuration file '#{config_file}' not found" unless File.exist?(config_file)
43
+
44
+ @data = YAML.load_file(config_file)
45
+ validate_configuration
46
+ rescue Psych::SyntaxError => e
47
+ raise ConfigurationError, "Invalid YAML in #{config_file}: #{e.message}"
48
+ end
49
+
50
+ def validate_configuration
51
+ raise ConfigurationError, "Configuration file is empty" if @data.nil? || @data.empty?
52
+
53
+ @data.each do |env_name, env_config|
54
+ validate_environment(env_name, env_config)
55
+ end
56
+ end
57
+
58
+ def validate_environment(env_name, env_config)
59
+ raise ConfigurationError, "Environment '#{env_name}' is not a hash" unless env_config.is_a?(Hash)
60
+
61
+ unless env_config["provider"]
62
+ raise ConfigurationError,
63
+ "Environment '#{env_name}' missing required 'provider' field"
64
+ end
65
+
66
+ valid_providers = %w[aws gcp azure docker kubernetes]
67
+ provider = env_config["provider"]
68
+ return if valid_providers.include?(provider)
69
+
70
+ raise ConfigurationError,
71
+ "Invalid provider '#{provider}' for environment '#{env_name}'. Must be one of: #{valid_providers.join(", ")}"
72
+ end
73
+ end
74
+
75
+ class ConfigurationError < Error; end
76
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require_relative "configuration"
5
+ require_relative "adapters/base"
6
+ require_relative "adapters/aws"
7
+
8
+ # Main Deployer Class
9
+ module Gjallarhorn
10
+ class Deployer
11
+ ADAPTERS = {
12
+ "aws" => Adapters::AWSAdapter,
13
+ "gcp" => nil, # TODO: Implement in Phase 2
14
+ "azure" => nil, # TODO: Implement in Phase 2
15
+ "docker" => nil, # TODO: Implement in Phase 2
16
+ "kubernetes" => nil # TODO: Implement in Phase 3
17
+ }.freeze
18
+
19
+ attr_reader :configuration, :logger
20
+
21
+ def initialize(config_file = "deploy.yml")
22
+ @configuration = Configuration.new(config_file)
23
+ @logger = Logger.new($stdout)
24
+ end
25
+
26
+ def deploy(environment, image)
27
+ adapter = create_adapter(environment)
28
+ @logger.info "Deploying #{image} to #{environment} using #{adapter.class.name}"
29
+
30
+ adapter.deploy(
31
+ image: image,
32
+ environment: environment,
33
+ services: @configuration.services_for(environment)
34
+ )
35
+
36
+ @logger.info "Deployment completed successfully"
37
+ end
38
+
39
+ def status(environment)
40
+ adapter = create_adapter(environment)
41
+ adapter.status
42
+ end
43
+
44
+ def rollback(environment, version)
45
+ adapter = create_adapter(environment)
46
+ adapter.rollback(version: version)
47
+ end
48
+
49
+ private
50
+
51
+ def create_adapter(environment)
52
+ env_config = @configuration.environment(environment)
53
+ provider = env_config["provider"]
54
+ adapter_class = ADAPTERS[provider]
55
+
56
+ raise DeploymentError, "Provider '#{provider}' not yet implemented" unless adapter_class
57
+
58
+ adapter_class.new(env_config)
59
+ end
60
+ end
61
+
62
+ class DeploymentError < Error; end
63
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gjallarhorn
4
+ VERSION = "0.1.0.alpha"
5
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "gjallarhorn/version"
4
+
5
+ module Gjallarhorn
6
+ class Error < StandardError; end
7
+ end
8
+
9
+ require_relative "gjallarhorn/configuration"
10
+ require_relative "gjallarhorn/deployer"
11
+ require_relative "gjallarhorn/cli"
data/sig/bifrost.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Bifrost
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gjallarhorn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Ken C. Demanawa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: irb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.21'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.21'
69
+ description: A Ruby gem that sounds across all cloud realms with secure, API-first
70
+ deployments beyond SSH.
71
+ email:
72
+ - kenneth.c.demanawa@gmail.com
73
+ executables:
74
+ - gjallarhorn
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - CODE_OF_CONDUCT.md
79
+ - LICENSE.txt
80
+ - README.md
81
+ - README.pdf
82
+ - Rakefile
83
+ - examples/deploy.yml
84
+ - examples/dream-deploy.yml
85
+ - exe/gjallarhorn
86
+ - lib/gjallarhorn.rb
87
+ - lib/gjallarhorn/adapters/aws.rb
88
+ - lib/gjallarhorn/adapters/base.rb
89
+ - lib/gjallarhorn/cli.rb
90
+ - lib/gjallarhorn/configuration.rb
91
+ - lib/gjallarhorn/deployer.rb
92
+ - lib/gjallarhorn/version.rb
93
+ - sig/bifrost.rbs
94
+ homepage: https://github.com/kanutocd/gjallarhorn
95
+ licenses:
96
+ - MIT
97
+ metadata:
98
+ allowed_push_host: https://rubygems.org
99
+ homepage_uri: https://github.com/kanutocd/gjallarhorn
100
+ source_code_uri: https://github.com/kanutocd/gjallarhorn
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 3.1.0
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">"
113
+ - !ruby/object:Gem::Version
114
+ version: 1.3.1
115
+ requirements: []
116
+ rubygems_version: 3.3.27
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Multi-cloud deployment guardian as legendary as Heimdall's horn.
120
+ test_files: []