Class: Serverless::Domain

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/serverless/domain.rb

Constant Summary collapse

REGEXP =
%r{^(?<scheme>https?://)?(?<function_name>[^.]+)-(?<cluster_left>\h{2})a1(?<cluster_middle>\h{10})f2(?<cluster_right>\h{2})(?<environment_id>\h+)-(?<environment_slug>[^.]+)\.(?<pages_domain_name>.+)}.freeze
UUID_LENGTH =
14

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#environmentObject

Returns the value of attribute environment


10
11
12
# File 'app/models/serverless/domain.rb', line 10

def environment
  @environment
end

#function_nameObject

Returns the value of attribute function_name


10
11
12
# File 'app/models/serverless/domain.rb', line 10

def function_name
  @function_name
end

#serverless_domain_clusterObject

Returns the value of attribute serverless_domain_cluster


10
11
12
# File 'app/models/serverless/domain.rb', line 10

def serverless_domain_cluster
  @serverless_domain_cluster
end

Class Method Details

.generate_uuidObject


16
17
18
# File 'app/models/serverless/domain.rb', line 16

def self.generate_uuid
  SecureRandom.hex(UUID_LENGTH / 2)
end

Instance Method Details

#knative_uriObject


24
25
26
# File 'app/models/serverless/domain.rb', line 24

def knative_uri
  URI("http://#{function_name}.#{namespace}.#{serverless_domain_cluster.knative.hostname}")
end

#uriObject


20
21
22
# File 'app/models/serverless/domain.rb', line 20

def uri
  URI("https://#{function_name}-#{serverless_domain_cluster_uuid}#{"%x" % environment.id}-#{environment.slug}.#{serverless_domain_cluster.domain}")
end