Skip to content

Commit

Permalink
Fix gitops-promotion compatibility (#30)
Browse files Browse the repository at this point in the history
* change notifications to replicate fluxcd behaviour

* fix compat
  • Loading branch information
simongottschlag authored Oct 14, 2022
1 parent 1eb9510 commit fbd55a5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

type Config struct {
ResourceGroupName string `json:"resource_group_name" arg:"-g,--resource-group-name,env:RESOURCE_GROUP_NAME,required" help:"Azure Resource Group Name"`
Environment string `json:"environment" arg:"--environment,env:ENVIRONMENT,required" help:"The current environment that azcagit is running in"`
SubscriptionID string `json:"subscription_id" arg:"-s,--subscription-id,env:AZURE_SUBSCRIPTION_ID,required" help:"Azure Subscription ID"`
ManagedEnvironmentID string `json:"managed_environment_id" arg:"-m,--managed-environment-id,env:MANAGED_ENVIRONMENT_ID,required" help:"Azure Container Apps Managed Environment ID"`
KeyVaultName string `json:"key_vault_name" arg:"-k,--key-vault-name,env:KEY_VAULT_NAME,required" help:"Azure KeyVault name to extract secrets from"`
Expand All @@ -26,6 +27,7 @@ type Config struct {
DaprPubsubName string `json:"dapr_pubsub_name" arg:"--dapr-pubsub-name,env:DAPR_PUBSUB_NAME" default:"azcagit-trigger" help:"The PubSub name for the trigger"`
DaprTopic string `json:"dapr_topic" arg:"--dapr-topic-name,env:DAPR_TOPIC_NAME,required" help:"The PubSub topic name for the trigger"`
NotificationsEnabled bool `json:"notifications_enabled" arg:"--notifications-enabled,env:NOTIFICATIONS_ENABLED" default:"false" help:"Sets if Notifications should be sent to the git provider, should be disabled if no token is provided in git url"`
NotificationGroup string `json:"notification_group" arg:"--notification-group,env:NOTIFICATION_GROUP" default:"apps" help:"The notification group used by gitops-promotion"`
DebugEnabled bool `json:"debug_enabled" arg:"--debug,env:DEBUG" default:"false" help:"Enabled debug logging"`
}

Expand Down
4 changes: 4 additions & 0 deletions src/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func TestNewConfig(t *testing.T) {
"/foo/bar/bin",
"--resource-group-name",
"foo",
"--environment",
"foobar",
"--subscription-id",
"bar",
"--managed-environment-id",
Expand All @@ -30,6 +32,7 @@ func TestNewConfig(t *testing.T) {
require.NoError(t, err)
require.Equal(t, Config{
ResourceGroupName: "foo",
Environment: "foobar",
SubscriptionID: "bar",
ManagedEnvironmentID: "baz",
KeyVaultName: "ze-keyvault",
Expand All @@ -43,6 +46,7 @@ func TestNewConfig(t *testing.T) {
DaprAppPort: 8080,
DaprPubsubName: "azcagit-trigger",
DaprTopic: "ze-topic",
NotificationGroup: "apps",
}, cfg)
}

Expand Down
3 changes: 2 additions & 1 deletion src/notification/azure_devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ func (a *AzureDevOpsNotification) Send(ctx context.Context, event NotificationEv
Description: &event.Description,
State: &state,
Context: &git.GitStatusContext{
Genre: toPtr("azcagit"),
// using fluxcd to be compatible with gitops-promotion
Genre: toPtr("fluxcd"),
Name: &event.Name,
},
},
Expand Down
4 changes: 1 addition & 3 deletions src/reconcile/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,7 @@ func (r *Reconciler) sendNotification(ctx context.Context, revision string, reco
state = notification.NotificationStateFailure
}

location := strings.ReplaceAll(r.cfg.Location, " ", "")
resourceGroup := r.cfg.ResourceGroupName
name := strings.ToLower(fmt.Sprintf("%s/%s", location, resourceGroup))
name := strings.ToLower(fmt.Sprintf("%s/%s-%s", r.cfg.ResourceGroupName, r.cfg.NotificationGroup, r.cfg.Environment))
event := notification.NotificationEvent{
Revision: revision,
State: state,
Expand Down
1 change: 1 addition & 0 deletions terraform-module/azcagit.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ resource "azapi_resource" "container_app_azcagit" {
image = "ghcr.io/xenitab/azcagit:${var.azcagit_version}"
args = [
"--resource-group-name", azurerm_resource_group.tenant.name,
"--environment", var.environment,
"--subscription-id", data.azurerm_client_config.current.subscription_id,
"--managed-environment-id", azapi_resource.managed_environment.id,
"--key-vault-name", azurerm_key_vault.tenant_kv.name,
Expand Down

0 comments on commit fbd55a5

Please sign in to comment.