walheim 0.1.2 → 0.2.0
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 +4 -4
- data/bin/whctl +8 -695
- data/lib/walheim/cli/base_command.rb +176 -0
- data/lib/walheim/cli/helpers.rb +113 -0
- data/lib/walheim/cli/legacy_context.rb +206 -0
- data/lib/walheim/cli/resource_command.rb +51 -0
- data/lib/walheim/cli.rb +62 -0
- data/lib/walheim/handler_registry.rb +27 -0
- data/lib/walheim/namespaced_resource.rb +27 -0
- data/lib/walheim/resource.rb +8 -3
- data/lib/walheim/resources/apps.rb +24 -7
- data/lib/walheim/resources/namespaces.rb +57 -0
- data/lib/walheim/version.rb +1 -1
- data/lib/walheim.rb +3 -0
- metadata +20 -1
|
@@ -6,8 +6,10 @@ require_relative '../handler_registry'
|
|
|
6
6
|
|
|
7
7
|
module Resources
|
|
8
8
|
class Apps < Walheim::NamespacedResource
|
|
9
|
-
def initialize(
|
|
10
|
-
super
|
|
9
|
+
def initialize(data_dir: Dir.pwd)
|
|
10
|
+
super(data_dir: data_dir)
|
|
11
|
+
# Sync needs the full path to namespaces directory
|
|
12
|
+
namespaces_dir = File.join(data_dir, 'namespaces')
|
|
11
13
|
@syncer = Walheim::Sync.new(namespaces_dir: namespaces_dir)
|
|
12
14
|
end
|
|
13
15
|
|
|
@@ -44,23 +46,32 @@ module Resources
|
|
|
44
46
|
# Start with base operations
|
|
45
47
|
ops = super
|
|
46
48
|
|
|
49
|
+
namespace_opt = { type: :string, aliases: [:n], desc: 'Target namespace', required: true }
|
|
50
|
+
|
|
47
51
|
# Add apps-specific operations
|
|
48
52
|
ops.merge({
|
|
49
53
|
import: {
|
|
50
54
|
description: 'Import docker-compose as Walheim App',
|
|
51
|
-
usage: ['import app {name} -n {namespace} -f {docker-compose.yml}']
|
|
55
|
+
usage: ['import app {name} -n {namespace} -f {docker-compose.yml}'],
|
|
56
|
+
options: {
|
|
57
|
+
namespace: namespace_opt,
|
|
58
|
+
file: { type: :string, aliases: [:f], desc: 'docker-compose.yml path', required: true }
|
|
59
|
+
}
|
|
52
60
|
},
|
|
53
61
|
start: {
|
|
54
62
|
description: 'Compile, sync, and start app on host',
|
|
55
|
-
usage: ['start app {name} -n {namespace}']
|
|
63
|
+
usage: ['start app {name} -n {namespace}'],
|
|
64
|
+
options: { namespace: namespace_opt }
|
|
56
65
|
},
|
|
57
66
|
pause: {
|
|
58
67
|
description: 'Stop app containers (keep files)',
|
|
59
|
-
usage: ['pause app {name} -n {namespace}']
|
|
68
|
+
usage: ['pause app {name} -n {namespace}'],
|
|
69
|
+
options: { namespace: namespace_opt }
|
|
60
70
|
},
|
|
61
71
|
stop: {
|
|
62
72
|
description: 'Stop app and remove files from host',
|
|
63
|
-
usage: ['stop app {name} -n {namespace}']
|
|
73
|
+
usage: ['stop app {name} -n {namespace}'],
|
|
74
|
+
options: { namespace: namespace_opt }
|
|
64
75
|
},
|
|
65
76
|
logs: {
|
|
66
77
|
description: 'View logs from remote containers',
|
|
@@ -69,7 +80,13 @@ module Resources
|
|
|
69
80
|
'logs app {name} -n {namespace} --follow',
|
|
70
81
|
'logs app {name} -n {namespace} --tail 100',
|
|
71
82
|
'logs app {name} -n {namespace} --timestamps'
|
|
72
|
-
]
|
|
83
|
+
],
|
|
84
|
+
options: {
|
|
85
|
+
namespace: namespace_opt,
|
|
86
|
+
follow: { type: :boolean, desc: 'Follow log output' },
|
|
87
|
+
tail: { type: :numeric, desc: 'Number of lines from end' },
|
|
88
|
+
timestamps: { type: :boolean, desc: 'Show timestamps' }
|
|
89
|
+
}
|
|
73
90
|
}
|
|
74
91
|
})
|
|
75
92
|
end
|
|
@@ -22,6 +22,63 @@ module Resources
|
|
|
22
22
|
}
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# Override operation_info for cluster resource
|
|
26
|
+
def self.operation_info
|
|
27
|
+
{
|
|
28
|
+
get: {
|
|
29
|
+
description: 'List all namespaces',
|
|
30
|
+
usage: ['get namespaces'],
|
|
31
|
+
options: {} # No namespace flag for cluster resource
|
|
32
|
+
},
|
|
33
|
+
create: {
|
|
34
|
+
description: 'Create a new namespace',
|
|
35
|
+
usage: ['create namespace {name} [--username {user}] [--hostname {host}]'],
|
|
36
|
+
options: {
|
|
37
|
+
username: { type: :string, desc: 'SSH username for namespace' },
|
|
38
|
+
hostname: { type: :string, desc: 'Hostname for namespace' }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
apply: {
|
|
42
|
+
description: 'Create or update namespace',
|
|
43
|
+
usage: ['apply namespace {name}', 'apply -f namespace.yaml'],
|
|
44
|
+
options: {
|
|
45
|
+
file: { type: :string, aliases: [:f], desc: 'Manifest file' }
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
delete: {
|
|
49
|
+
description: 'Delete a namespace',
|
|
50
|
+
usage: ['delete namespace {name}'],
|
|
51
|
+
options: {}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Create a new namespace
|
|
57
|
+
def create(name:, username: nil, hostname: nil)
|
|
58
|
+
hostname ||= name
|
|
59
|
+
|
|
60
|
+
namespace_path = File.join(@data_dir, 'namespaces', name)
|
|
61
|
+
if Dir.exist?(namespace_path)
|
|
62
|
+
warn "Error: namespace '#{name}' already exists at #{namespace_path}"
|
|
63
|
+
exit 1
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Create directory structure
|
|
67
|
+
Dir.mkdir(namespace_path)
|
|
68
|
+
Dir.mkdir(File.join(namespace_path, 'apps'))
|
|
69
|
+
Dir.mkdir(File.join(namespace_path, 'secrets'))
|
|
70
|
+
Dir.mkdir(File.join(namespace_path, 'configmaps'))
|
|
71
|
+
|
|
72
|
+
# Create .namespace.yaml with optional username
|
|
73
|
+
config_content = "hostname: #{hostname}\n"
|
|
74
|
+
config_content = "username: #{username}\n#{config_content}" if username
|
|
75
|
+
File.write(File.join(namespace_path, '.namespace.yaml'), config_content)
|
|
76
|
+
|
|
77
|
+
puts "Created namespace '#{name}' at #{namespace_path}"
|
|
78
|
+
puts " Username: #{username || '(from SSH config)'}"
|
|
79
|
+
puts " Hostname: #{hostname}"
|
|
80
|
+
end
|
|
81
|
+
|
|
25
82
|
private
|
|
26
83
|
|
|
27
84
|
def manifest_filename
|
data/lib/walheim/version.rb
CHANGED
data/lib/walheim.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: walheim
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akhyar Amarullah
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '3.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: thor
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.3'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.3'
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: bundler
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -65,6 +79,11 @@ files:
|
|
|
65
79
|
- README.md
|
|
66
80
|
- bin/whctl
|
|
67
81
|
- lib/walheim.rb
|
|
82
|
+
- lib/walheim/cli.rb
|
|
83
|
+
- lib/walheim/cli/base_command.rb
|
|
84
|
+
- lib/walheim/cli/helpers.rb
|
|
85
|
+
- lib/walheim/cli/legacy_context.rb
|
|
86
|
+
- lib/walheim/cli/resource_command.rb
|
|
68
87
|
- lib/walheim/cluster_resource.rb
|
|
69
88
|
- lib/walheim/config.rb
|
|
70
89
|
- lib/walheim/handler_registry.rb
|