Skip to content
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
1 change: 1 addition & 0 deletions backend/plugins/argocd/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (p ArgoCD) GetTablesInfo() []dal.Tabler {
&models.ArgocdConnection{},
&models.ArgocdApplication{},
&models.ArgocdSyncOperation{},
&models.ArgocdRevisionImage{},
&models.ArgocdScopeConfig{},
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/plugins/argocd/models/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ArgocdApplication struct {
SyncStatus string `gorm:"type:varchar(100)" json:"syncStatus" mapstructure:"syncStatus"` // Synced, OutOfSync, Unknown
HealthStatus string `gorm:"type:varchar(100)" json:"healthStatus" mapstructure:"healthStatus"` // Healthy, Progressing, Degraded, Suspended, Missing, Unknown
CreatedDate *time.Time `json:"createdDate,omitempty" mapstructure:"createdDate,omitempty"`
SummaryImages []string `gorm:"type:json;serializer:json" json:"summaryImages" mapstructure:"summaryImages"`
common.NoPKModel
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package migrationscripts

import (
"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/migrationhelper"
"github.com/apache/incubator-devlake/plugins/argocd/models/migrationscripts/archived"
)

var _ plugin.MigrationScript = (*addImageSupportArtifacts)(nil)

type addImageSupportArtifacts struct{}

func (m *addImageSupportArtifacts) Up(basicRes context.BasicRes) errors.Error {
return migrationhelper.AutoMigrateTables(
basicRes,
&archived.ArgocdApplication{},
&archived.ArgocdSyncOperation{},
&archived.ArgocdRevisionImage{},
)
}

func (*addImageSupportArtifacts) Version() uint64 {
return 20251102160000
}

func (*addImageSupportArtifacts) Name() string {
return "argocd add image support artifacts"
}
14 changes: 14 additions & 0 deletions backend/plugins/argocd/models/migrationscripts/archived/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type ArgocdApplication struct {
SyncStatus string `gorm:"type:varchar(100)"`
HealthStatus string `gorm:"type:varchar(100)"`
CreatedDate *time.Time
SummaryImages []string `gorm:"type:json;serializer:json"`
ScopeConfigId uint64
archived.NoPKModel
}
Expand All @@ -69,13 +70,26 @@ type ArgocdSyncOperation struct {
SyncStatus string `gorm:"type:varchar(100)"`
HealthStatus string `gorm:"type:varchar(100)"`
ResourcesCount int
ContainerImages []string `gorm:"type:json;serializer:json"`
archived.NoPKModel
}

func (ArgocdSyncOperation) TableName() string {
return "_tool_argocd_sync_operations"
}

type ArgocdRevisionImage struct {
ConnectionId uint64 `gorm:"primaryKey"`
ApplicationName string `gorm:"primaryKey;type:varchar(255)"`
Revision string `gorm:"primaryKey;type:varchar(255)"`
Images []string `gorm:"type:json;serializer:json"`
archived.NoPKModel
}

func (ArgocdRevisionImage) TableName() string {
return "_tool_argocd_revision_images"
}

type ArgocdScopeConfig struct {
archived.ScopeConfig `mapstructure:",squash" json:",inline" gorm:"embedded"`
ConnectionId uint64 `gorm:"index"`
Expand Down
1 change: 1 addition & 0 deletions backend/plugins/argocd/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ import (
func All() []plugin.MigrationScript {
return []plugin.MigrationScript{
new(addInitTables),
new(addImageSupportArtifacts),
}
}
37 changes: 37 additions & 0 deletions backend/plugins/argocd/models/revision_image.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package models

import "github.com/apache/incubator-devlake/core/models/common"

// ArgocdRevisionImage captures the container images observed for a given
// Argo CD application revision. It enables historical lookups so that
// previously processed sync operations retain the images that were active
// when they first ran, even after subsequent deployments update the
// application summary images.
type ArgocdRevisionImage struct {
ConnectionId uint64 `gorm:"primaryKey"`
ApplicationName string `gorm:"primaryKey;type:varchar(255)"`
Revision string `gorm:"primaryKey;type:varchar(255)"`
Images []string `gorm:"type:json;serializer:json"`
common.NoPKModel
}

func (ArgocdRevisionImage) TableName() string {
return "_tool_argocd_revision_images"
}
1 change: 1 addition & 0 deletions backend/plugins/argocd/models/sync_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ArgocdSyncOperation struct {
SyncStatus string `gorm:"type:varchar(100)"` // Synced, OutOfSync
HealthStatus string `gorm:"type:varchar(100)"` // Healthy, Degraded, etc.
ResourcesCount int
ContainerImages []string `gorm:"type:json;serializer:json"`
common.NoPKModel
}

Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/argocd/tasks/application_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type ArgocdApiApplication struct {
Health struct {
Status string `json:"status"` // Healthy, Progressing, Degraded, etc.
} `json:"health"`
Summary struct {
Images []string `json:"images"`
} `json:"summary"`
} `json:"status"`
}

Expand Down Expand Up @@ -96,6 +99,7 @@ func ExtractApplications(taskCtx plugin.SubTaskContext) errors.Error {
DestNamespace: apiApp.Spec.Destination.Namespace,
SyncStatus: apiApp.Status.Sync.Status,
HealthStatus: apiApp.Status.Health.Status,
SummaryImages: apiApp.Status.Summary.Images,
CreatedDate: &apiApp.Metadata.CreationTimestamp,
}
application.ConnectionId = data.Options.ConnectionId
Expand Down
Loading
Loading