Skip to content

Added suport for Microsoft Azure Blob Storage #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions Block/System/Config/Form/Modal/UploadVcl.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@
*/
class UploadVcl extends Template
{
/**
* Prepare layout
*
* @return $this|void
*/
protected function _prepareLayout() // @codingStandardsIgnoreLine - required by parent class
{
parent::_prepareLayout();

$this->addChild('dialogs', 'Fastly\Cdn\Block\System\Config\Form\Dialogs');
}

/**
* Get dialogs
*
Expand Down
7 changes: 6 additions & 1 deletion Controller/Adminhtml/FastlyCdn/Logging/UpdateEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ public function execute()
['response_condition' => $condition]
);

$endpoint = $this->api->updateLogEndpoint($clone->number, $endpointType, array_filter($params), $oldName);
$params = array_filter($params);
//Array filter removes empty strings, but empty compression_codec param turns off compression formats
if (!isset($params['compression_codec'])){
$params['compression_codec'] = "";
}
$endpoint = $this->api->updateLogEndpoint($clone->number, $endpointType, $params, $oldName);

if (!$endpoint) {
return $result->setData([
Expand Down
1 change: 1 addition & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function getAvailableLogEndpointProviders()
'honeycomb' => 'Honeycomb',
'newrelic' => 'New Relic Logs',
'sumologic' => 'Sumologic',
'azureblob' => 'Azure Blob Storage'
];
}
}
11 changes: 9 additions & 2 deletions view/adminhtml/layout/adminhtml_system_config_edit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<?xml version="1.0"?>

<page>
<body>
<referenceContainer name="content">
<block class="Fastly\Cdn\Block\System\Config\Form\Modal\UploadVcl" name="adminhtml.system.backup.container"/>
<block class="Fastly\Cdn\Block\System\Config\Form\Modal\UploadVcl" name="adminhtml.system.backup.container">
<block class="Fastly\Cdn\Block\System\Config\Form\Dialogs"
name="adminhtml.system.backup.container.dialogs" as="dialogs">
<block class="Magento\Framework\View\Element\Text\ListText" name="admin.fastly.tools.log">
<block name="admin.fastly.log.azure-blob"
template="Fastly_Cdn::system/config/form/log/azure.phtml"/>
</block>
</block>
</block>
</referenceContainer>
</body>
</page>
1 change: 1 addition & 0 deletions view/adminhtml/templates/system/config/dialogs.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@
</fieldset>
</form>
</script>
<?= $block->getChildHtml('admin.fastly.tools.log') ?>
<!-- End Log endpoints creation overlay templates -->

<!-- Create condition template -->
Expand Down
224 changes: 224 additions & 0 deletions view/adminhtml/templates/system/config/form/log/azure.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
<!-- Azure Blob Storage -->
<script type="text/x-magento-template" id="fastly-create-log-endpoint-template-azureblob">
<div class="messages">
<div class="message message-warning fastly-message-warning" style="display: none">
<?php /* @noEscape */ echo __("You are about to clone your active version #x.")?>
<?php /* @noEscape */ echo __("Your log endpoint will be created in version #y.")?>
</div>
<div class="message message-error fastly-message-error" style="display: none">
</div>
</div>
<form action="<?php /* @noEscape */ echo $block->getUrl('adminhtml/fastlyCdn_Vcl/upload'); ?>"
method="POST"
id="create-log-endpoint-form"
name="create-log-endpoint-form"
class="form-inline"
enctype="multipart/form-data">
<fieldset class="admin__fieldset form-list question">
<div class="admin__field field maintenance-checkbox-container">
<label for="fastly_activate_log_endpoint" class="admin__field-label">
<span><?php /* @noEscape */ echo __('Activate after the change')?></span>
</label>
<div class="admin__field-control">
<div class="admin__field-option">
<input class="admin__control-checkbox"
type="checkbox"
name="fastly_activate_log_endpoint"
id="fastly_activate_log_endpoint"
checked/>
<label class="admin__field-label" for="fastly_activate_log_endpoint"></label>
</div>
</div>
</div>
<div class="admin__field field">
<label for="condition" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Condition") ?></span>
</label>
<div class="admin__field-control">
<span id="attach_span" style>
This will happen all the time unless you <a id="attach" href="#">Attach a condition</a>
</span>
<select name="conditions" id="conditions" class="admin__control-select"></select>
<div class="admin__field-note"><a id="detach" href="#">Detach condition</a> <span id="sep">|</span>
<a id="create-response-condition" href="#">Create a new response condition</a>
</div>
<input type="hidden" name="condition_name" id="condition_name"/>
<input type="hidden" name="apply_if" id="apply_if"/>
<input type="hidden" name="condition_priority" id="condition_priority"/>
</div>
</div>
<input type="hidden" name="endpoint_type">
<input type="hidden" name="old_name">
<div class="admin__field field _required">
<label for="log_endpoint[name]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Name") ?></span>
</label>
<div class="admin__field-control">
<input name="log_endpoint[name]" id="log_endpoint[name]" class="admin__control-text required-entry">
<div class="admin__field-note">
The name of your endpoint, such as <b>My endpoint</b>.
</div>
</div>
</div>
<div class="admin__field field __required">
<label for="log_endpoint[format]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Log format") ?></span>
</label>
<div class="admin__field-control">
<textarea rows="6" name="log_endpoint[format]" id="log_endpoint[format]" class="admin__control-text required-entry">
%h %l %u %t "%r" %>s %b</textarea>
<div class="admin__field-note">
An Apache-style string or VCL variables to use for log formatting (the Apache Common Log format string appears by default).
See <a target="_blank" href="https://docs.fastly.com/en/guides/setting-up-remote-log-streaming" rel="noopener noreferrer" class="external-link">Fastly's log files docs</a>,
<a target="_blank" href="https://www.varnish-cache.org/docs/2.1/reference/vcl.html#variables" rel="noopener noreferrer" class="external-link">Varnish's descriptions of VCL variables</a>,
and <a target="_blank" href="https://docs.fastly.com/vcl/variables/" rel="noopener noreferrer" class="external-link">Fastly's available VCL variables</a> for more info.
</div>
</div>
</div>
<div class="admin__field field _required">
<label for="log_endpoint[timestamp_format]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Timestamp format") ?></span>
</label>
<div class="admin__field-control">
<input name="log_endpoint[timestamp_format]" id="log_endpoint[timestamp_format]" class="admin__control-text required-entry" value="%Y-%m-%dT%H:%M:%S.000">
<div class="admin__field-note">
The timestamp format on log files. The default is an strftime compatible string.
</div>
</div>
</div>
<div class="admin__field field _required">
<label for="log_endpoint[account_name]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Storage account name") ?></span>
</label>
<div class="admin__field-control">
<input name="log_endpoint[account_name]" id="log_endpoint[account_name]" class="admin__control-text required-entry">
<div class="admin__field-note">
<?php /* @noEscape */ echo __("Storage account name") ?>
</div>
</div>
</div>
<div class="admin__field field _required">
<label for="log_endpoint[container]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Container") ?></span>
</label>
<div class="admin__field-control">
<input name="log_endpoint[container]" id="log_endpoint[container]" class="admin__control-text required-entry">
<div class="admin__field-note">
<?php /* @noEscape */ echo __("The name of the Azure Blob Storage container in which to store logs.") ?>
</div>
</div>
</div>
<div class="admin__field field __required">
<label for="log_endpoint[sas_token]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Sas token") ?></span>
</label>
<div class="admin__field-control">
<textarea rows="6" name="log_endpoint[sas_token]" id="log_endpoint[sas_token]" class="admin__control-text required-entry masked"></textarea>
<div class="admin__field-note">
The Microsoft Azure shared access signature providing write access to the blob service objects. Be sure to update your token before it expires or the logging functionality will not work.
<a href="https://docs.fastly.com/en/guides/log-streaming-azure-blob-storage">For more info check guide</a>
</div>
</div>
</div>
<div class="admin__field field _required">
<label for="log_endpoint[period]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Period") ?></span>
</label>
<div class="admin__field-control">
<input name="log_endpoint[period]" id="log_endpoint[period]" class="admin__control-text required-entry" value="3600">
<div class="admin__field-note">
This manages how frequently in seconds to rotate your log files. Use numbers only in this field.
</div>
</div>
</div>

<div class="admin__field field">
<label class="admin__field-label">
Advanced options
</label>
</div>
<div class="admin__field field">
<label for="log_endpoint[path]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Path") ?></span>
</label>
<div class="admin__field-control">
<input name="log_endpoint[path]" id="log_endpoint[path]" class="admin__control-text">
</div>
</div>
<div class="admin__field field">
<label for="log_endpoint[message_type]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Select a log line format") ?></span>
</label>
<div class="admin__field-control">
<select name="log_endpoint[message_type]" id="log_endpoint[message_type]" class="admin__control-text">
<option value="classic" selected>Classic</option>
<option value="loggly">Loggly</option>
<option value="logplex">Logplex</option>
<option value="blank">Blank</option>
</select>
<div class="admin__field-note">
<a target="_blank" href="https://docs.fastly.com/en/guides/changing-log-line-formats" rel="noopener noreferrer" class="external-link">Learn more about changing log line formats</a>
</div>
</div>
</div>
<div class="admin__field field">
<label for="log_endpoint[placement]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Placement") ?></span>
</label>
<div class="admin__field-control">
<select name="log_endpoint[placement]" id="log_endpoint[placement]" class="admin__control-text">
<option value="" selected>Format Version Default</option>
<option value="waf_debug">WAF Debug</option>
<option value="none">None</option>
</select>
<div class="admin__field-note">
<a target="_blank" href="https://docs.fastly.com/api/logging" rel="noopener noreferrer">Learn more about changing logging call placement</a>
</div>
</div>
</div>
<div class="admin__field field __required">
<label for="log_endpoint[public_key]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("PGP public key") ?></span>
</label>
<div class="admin__field-control">
<textarea rows="6" name="log_endpoint[public_key]" id="log_endpoint[public_key]" class="admin__control-text masked"></textarea>
<div class="admin__field-note">
A PGP Public Key that Fastly will use to encrypt your log files before writing them to disk. You will only be able to read the contents by decrypting them with your private key. The PGP key should be in <a target="_blank" href="https://en.wikipedia.org/wiki/Privacy-enhanced_Electronic_Mail" rel="noopener noreferrer" class="external-link">PEM (Privacy Enhanced Mail) format</a>.
</div>
</div>
</div>

<div class="admin__field field">
<label for="log_endpoint[compression_codec]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Compression") ?></span>
</label>
<div class="admin__field-control">
<select name="log_endpoint[compression_codec]" id="log_endpoint[compression_codec]" class="admin__control-text">
<option value="" selected>None</option>
<option value="zstd">Zstandard</option>
<option value="snappy">Snappy</option>
<option value="gzip">Gzip</option>
</select>
<div class="admin__field-note">
<a href="https://docs.fastly.com/en/guides/changing-log-compression-options" target="_blank">
Learn more about changing compression formats
</a>
</div>
</div>
</div>

<div class="admin__field field">
<label for="log_endpoint[gzip_level]" class="admin__field-label">
<span><?php /* @noEscape */ echo __("Gzip level") ?></span>
</label>
<div class="admin__field-control">
<input name="log_endpoint[gzip_level]" id="log_endpoint[gzip_level]" class="admin__control-text">
<div class="admin__field-note">
The level of gzip compression, if any, to apply to log files.<br>
The setting defaults to 0 (no compression). You can specify any whole number from 1 (fastest and least compressed) to 9 (slowest and most compressed).
</div>
</div>
</div>
</fieldset>
</form>
</script>