- 
                Notifications
    You must be signed in to change notification settings 
- Fork 554
feat: custom tag #3847
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
                    feat: custom tag #3847
Changes from 53 commits
      Commits
    
    
            Show all changes
          
          
            55 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8a7d822
              
                Add custom tag
              
              
                avdhesh-devtron 127ad00
              
                Refactor handle concurrency
              
              
                avdhesh-devtron d5c6102
              
                Refactor
              
              
                avdhesh-devtron c559393
              
                Update workflow when trigger failes due to tag conflict
              
              
                avdhesh-devtron 3dfde7a
              
                Fix error
              
              
                avdhesh-devtron 2768ea5
              
                temp
              
              
                avdhesh-devtron e3da3b8
              
                Build history failure case
              
              
                avdhesh-devtron ae8b894
              
                Merge branch 'custom-tag' of github.com:devtron-labs/devtron into ref…
              
              
                avdhesh-devtron edd2d54
              
                Custom tag logic extracted
              
              
                avdhesh-devtron abd20e8
              
                Fix build
              
              
                avdhesh-devtron bd6b603
              
                fix get query
              
              
                avdhesh-devtron f97fac5
              
                fix error handling
              
              
                avdhesh-devtron 9ebfbb5
              
                fix iota value
              
              
                avdhesh-devtron 0818862
              
                Fix errors
              
              
                avdhesh-devtron ef9af2c
              
                Return error when image path conflicts
              
              
                avdhesh-devtron 7c672de
              
                Handle errors
              
              
                avdhesh-devtron 98cd350
              
                Handle failed ci_workflow
              
              
                avdhesh-devtron 0b8efba
              
                Handle failed ci_workflow
              
              
                avdhesh-devtron 47729b1
              
                Remove unnecessary image  path deactivation
              
              
                avdhesh-devtron ec8510f
              
                Fix migration
              
              
                avdhesh-devtron a564454
              
                Merge branch 'main' of github.com:devtron-labs/devtron into refactor-…
              
              
                avdhesh-devtron bf99dce
              
                Refactor
              
              
                avdhesh-devtron 720a99d
              
                Refactor
              
              
                avdhesh-devtron b841f29
              
                Add validations
              
              
                avdhesh-devtron c955e21
              
                Remove regex check
              
              
                avdhesh-devtron 3ea5834
              
                Fix error message
              
              
                avdhesh-devtron 8fde21d
              
                Return bad request in case of trigger
              
              
                avdhesh-devtron 0f3c248
              
                add validation
              
              
                avdhesh-devtron 06edac9
              
                add validation
              
              
                avdhesh-devtron df484ca
              
                ad ci workflow id in status api
              
              
                avdhesh-devtron 786121b
              
                add comments
              
              
                avdhesh-devtron 500a256
              
                main merge
              
              
                iamayushm 1febd7d
              
                custom image tag migration
              
              
                iamayushm ec1dd53
              
                sql script correction
              
              
                iamayushm 8f3a54b
              
                fix: validation and sql script
              
              
                iamayushm 33ae161
              
                fixing null value in custom tag
              
              
                iamayushm 558928c
              
                Merge branch 'main' into refactor-tag-generation
              
              
                iamayushm 74f1c38
              
                marking image tag unreserved on abort
              
              
                iamayushm 5ab08bb
              
                main merge
              
              
                iamayushm 1252c91
              
                main merge
              
              
                iamayushm 3a1f591
              
                Merge branch 'main' into refactor-tag-generation
              
              
                iamayushm 15b3ba1
              
                migration script fix
              
              
                iamayushm 2ff5cf8
              
                fix get api
              
              
                iamayushm badac18
              
                tag validation updated
              
              
                iamayushm 849ebfe
              
                wip: validaion using regex
              
              
                iamayushm 784b65a
              
                fix validation
              
              
                iamayushm fca223a
              
                fixing error string
              
              
                iamayushm 8b39dbe
              
                fix validation
              
              
                iamayushm 20f35c6
              
                tag validation updated
              
              
                iamayushm a3277dc
              
                tag pattern modification
              
              
                iamayushm 5f1a6c7
              
                wip: fix
              
              
                iamayushm d89d12e
              
                fixing regex
              
              
                iamayushm 5be2095
              
                Merge branch 'main' into refactor-tag-generation
              
              
                iamayushm b713e2d
              
                pr review changes
              
              
                iamayushm f8f8d8b
              
                Merge branch 'main' into refactor-tag-generation
              
              
                iamayushm File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package bean | ||
|  | ||
| type CustomTag struct { | ||
| EntityKey int `json:"entityKey"` | ||
| EntityValue string `json:"entityValue"` | ||
| TagPattern string `json:"tagPattern"` | ||
| AutoIncreasingNumber int `json:"counterX"` | ||
| Metadata string `json:"metadata"` | ||
| } | ||
|  | ||
| type CustomTagErrorResponse struct { | ||
| ConflictingArtifactPath string `json:"conflictingLink"` | ||
| TagPattern string `json:"tagPattern"` | ||
| AutoIncreasingNumber int `json:"counterX"` | ||
| Message string `json:"message"` | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| package repository | ||
|  | ||
| import ( | ||
| "github.com/go-pg/pg" | ||
| "go.uber.org/zap" | ||
| ) | ||
|  | ||
| type CustomTag struct { | ||
| tableName struct{} `sql:"custom_tag" pg:",discard_unknown_columns"` | ||
| Id int `sql:"id"` | ||
| EntityKey int `sql:"entity_key"` | ||
| EntityValue string `sql:"entity_value"` | ||
| TagPattern string `sql:"tag_pattern"` | ||
| AutoIncreasingNumber int `sql:"auto_increasing_number, notnull"` | ||
| Active bool `sql:"active"` | ||
| Metadata string `sql:"metadata"` | ||
| } | ||
|  | ||
| type ImagePathReservation struct { | ||
| tableName struct{} `sql:"image_path_reservation" pg:",discard_unknown_columns"` | ||
| Id int `sql:"id"` | ||
| ImagePath string `sql:"image_path"` | ||
| CustomTagId int `sql:"custom_tag_id"` | ||
| active bool `sql:"active"` | ||
| } | ||
|  | ||
| type ImageTagRepository interface { | ||
| GetConnection() *pg.DB | ||
| CreateImageTag(customTagData *CustomTag) error | ||
| FetchCustomTagData(entityType int, entityValue string) (*CustomTag, error) | ||
| IncrementAndFetchByEntityKeyAndValue(tx *pg.Tx, entityKey int, entityValue string) (*CustomTag, error) | ||
| FindByImagePath(tx *pg.Tx, path string) ([]*ImagePathReservation, error) | ||
| InsertImagePath(tx *pg.Tx, reservation *ImagePathReservation) error | ||
| UpdateImageTag(customTag *CustomTag) error | ||
| DeleteByEntityKeyAndValue(entityKey int, entityValue string) error | ||
| DeactivateImagePathReservation(id int) error | ||
| FetchActiveCustomTagData(entityKey int, entityValue string) (*CustomTag, error) | ||
| } | ||
|  | ||
| type ImageTagRepositoryImpl struct { | ||
| dbConnection *pg.DB | ||
| logger *zap.SugaredLogger | ||
| } | ||
|  | ||
| func NewImageTagRepository(dbConnection *pg.DB, logger *zap.SugaredLogger) *ImageTagRepositoryImpl { | ||
| return &ImageTagRepositoryImpl{dbConnection: dbConnection, logger: logger} | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) GetConnection() *pg.DB { | ||
| return impl.dbConnection | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) CreateImageTag(customTagData *CustomTag) error { | ||
| return impl.dbConnection.Insert(customTagData) | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) UpdateImageTag(customTag *CustomTag) error { | ||
| return impl.dbConnection.Update(customTag) | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) DeleteByEntityKeyAndValue(entityKey int, entityValue string) error { | ||
| query := `update custom_tag set active = false where entity_key = ? and entity_value = ?` | ||
| _, err := impl.dbConnection.Exec(query, entityKey, entityValue) | ||
| return err | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) DeactivateImagePathReservation(id int) error { | ||
| query := `update image_path_reservation set active=? where id=?` | ||
| _, err := impl.dbConnection.Exec(query, false, id) | ||
| return err | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) FetchCustomTagData(entityType int, entityValue string) (*CustomTag, error) { | ||
| var customTagData CustomTag | ||
| err := impl.dbConnection.Model(&customTagData). | ||
| Where("entity_key = ?", entityType). | ||
| Where("entity_value = ?", entityValue).Select() | ||
| return &customTagData, err | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) FetchActiveCustomTagData(entityType int, entityValue string) (*CustomTag, error) { | ||
| var customTagData CustomTag | ||
| err := impl.dbConnection.Model(&customTagData). | ||
| Where("entity_key = ?", entityType). | ||
| Where("entity_value = ?", entityValue). | ||
| Where("active = ?", true).Select() | ||
| return &customTagData, err | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) IncrementAndFetchByEntityKeyAndValue(tx *pg.Tx, entityKey int, entityValue string) (*CustomTag, error) { | ||
| var customTag CustomTag | ||
| query := `update custom_tag set auto_increasing_number=auto_increasing_number+1 where entity_key=? and entity_value=? and active = ? returning id, tag_pattern, auto_increasing_number, entity_key, entity_value` | ||
| _, err := tx.Query(&customTag, query, entityKey, entityValue, true) | ||
| return &customTag, err | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) FindByImagePath(tx *pg.Tx, path string) ([]*ImagePathReservation, error) { | ||
| var imagePaths []*ImagePathReservation | ||
| err := tx.Model(&imagePaths). | ||
| Where("image_path = ?", path). | ||
| Where("active = ?", true).Select() | ||
| return imagePaths, err | ||
| } | ||
|  | ||
| func (impl *ImageTagRepositoryImpl) InsertImagePath(tx *pg.Tx, reservation *ImagePathReservation) error { | ||
| return tx.Insert(reservation) | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be used better name for counterX