Skip to content

Commit

Permalink
Remove release logic for RTOS images (#8587)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna authored Aug 9, 2024
1 parent 8c515ae commit be5e6ac
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 225 deletions.
88 changes: 14 additions & 74 deletions release/cli/pkg/assets/archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,65 +145,6 @@ func KernelArtifactPathGetter(rc *releasetypes.ReleaseConfig, archive *assettype
return sourceS3Key, sourceS3Prefix, releaseName, releaseS3Path, nil
}

func RTOSArtifactPathGetter(rc *releasetypes.ReleaseConfig, archive *assettypes.Archive, projectPath, gitTag, eksDReleaseChannel, eksDReleaseNumber, kubeVersion, latestPath, arch string) (string, string, string, string, error) {
var sourceS3Key string
var sourceS3Prefix string
var releaseS3Path string
var releaseName string
releaseDate := gitTag
eksDReleaseChannel = "1-29" // hardcoding because we vend RTOS artifacts only for 1-29 release branch

imageExtensions := map[string]string{
"ami": "gz",
"ova": "ova",
"raw": "gz",
}
imageExtension := imageExtensions[archive.Format]

if rc.DevRelease || rc.ReleaseEnvironment == "development" {
sourceS3Key = fmt.Sprintf("%s.%s", archive.OSName, imageExtension)
sourceS3Prefix = fmt.Sprintf("%s/%s", projectPath, latestPath)
} else {
sourceS3Key = fmt.Sprintf("%s-%s-%s-eks-a-%d-%s.%s",
archive.OSName,
eksDReleaseChannel,
releaseDate,
rc.BundleNumber,
arch,
imageExtension,
)
sourceS3Prefix = fmt.Sprintf("releases/canonical/%s/artifacts/rtos/%s", releaseDate, eksDReleaseChannel)
}

if rc.DevRelease {
releaseName = fmt.Sprintf("%s-%s-%s-eks-a-%s-%s.%s",
archive.OSName,
eksDReleaseChannel,
releaseDate,
rc.DevReleaseUriVersion,
arch,
imageExtension,
)
releaseS3Path = fmt.Sprintf("artifacts/%s/rtos/%s/%s",
rc.DevReleaseUriVersion,
archive.Format,
eksDReleaseChannel,
)
} else {
releaseName = fmt.Sprintf("%s-%s-%s-eks-a-%d-%s.%s",
archive.OSName,
eksDReleaseChannel,
releaseDate,
rc.BundleNumber,
arch,
imageExtension,
)
releaseS3Path = fmt.Sprintf("releases/canonical/%s/artifacts/rtos/%s", releaseDate, eksDReleaseChannel)
}

return sourceS3Key, sourceS3Prefix, releaseName, releaseS3Path, nil
}

func GetArchiveAssets(rc *releasetypes.ReleaseConfig, archive *assettypes.Archive, projectPath, gitTag, eksDReleaseChannel, eksDReleaseNumber, kubeVersion string) (*releasetypes.ArchiveArtifact, error) {
os := "linux"
arch := "amd64"
Expand All @@ -227,21 +168,20 @@ func GetArchiveAssets(rc *releasetypes.ReleaseConfig, archive *assettypes.Archiv
}

archiveArtifact := &releasetypes.ArchiveArtifact{
SourceS3Key: sourceS3Key,
SourceS3Prefix: sourceS3Prefix,
ArtifactPath: filepath.Join(rc.ArtifactDir, fmt.Sprintf("%s-%s", archive.Name, archive.Format), eksDReleaseChannel, rc.BuildRepoHead),
ReleaseName: releaseName,
ReleaseS3Path: releaseS3Path,
ReleaseCdnURI: cdnURI,
OS: os,
OSName: archive.OSName,
Arch: []string{arch},
GitTag: gitTag,
ProjectPath: projectPath,
SourcedFromBranch: sourcedFromBranch,
ImageFormat: archive.Format,
Private: archive.Private,
UploadToRTOSBucket: archive.UploadToRTOSBucket,
SourceS3Key: sourceS3Key,
SourceS3Prefix: sourceS3Prefix,
ArtifactPath: filepath.Join(rc.ArtifactDir, fmt.Sprintf("%s-%s", archive.Name, archive.Format), eksDReleaseChannel, rc.BuildRepoHead),
ReleaseName: releaseName,
ReleaseS3Path: releaseS3Path,
ReleaseCdnURI: cdnURI,
OS: os,
OSName: archive.OSName,
Arch: []string{arch},
GitTag: gitTag,
ProjectPath: projectPath,
SourcedFromBranch: sourcedFromBranch,
ImageFormat: archive.Format,
Private: archive.Private,
}

return archiveArtifact, nil
Expand Down
17 changes: 0 additions & 17 deletions release/cli/pkg/assets/config/bundle_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,6 @@ var bundleReleaseAssetsConfigMap = []assettypes.AssetConfig{
},
HasReleaseBranches: true,
},
// Canonical Ubuntu RTOS artifacts
{
ProjectName: "ubuntu-rtos",
ProjectPath: "projects/canonical/ubuntu",
GitTagAssigner: tagger.RTOSReleaseDateAssigner,
Archives: []*assettypes.Archive{
{
Name: "rtos",
Format: "raw",
OSName: "ubuntu",
OSVersion: "22.04",
ArchiveS3PathGetter: archives.RTOSArtifactPathGetter,
Private: true,
UploadToRTOSBucket: true,
},
},
},
// Cert-manager artifacts
{
ProjectName: "cert-manager",
Expand Down
13 changes: 0 additions & 13 deletions release/cli/pkg/assets/tagger/tagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ func CliGitTagAssigner(rc *releasetypes.ReleaseConfig, gitTagPath, overrideBranc
return gitTag, nil
}

func RTOSReleaseDateAssigner(rc *releasetypes.ReleaseConfig, rtosImageDatePath, overrideBranch string) (string, error) {
branchName := rc.BuildRepoBranchName
if overrideBranch != "" {
branchName = overrideBranch
}
releaseDate, err := filereader.ReadRTOSImageDate(rtosImageDatePath, rc.BuildRepoSource, branchName)
if err != nil {
return "", errors.Cause(err)
}

return releaseDate, nil
}

func NonExistentTagAssigner(rc *releasetypes.ReleaseConfig, gitTagPath, overrideBranch string) (string, error) {
return "non-existent", nil
}
Expand Down
1 change: 0 additions & 1 deletion release/cli/pkg/assets/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type Archive struct {
ArchitectureOverride string
ArchiveS3PathGetter ArchiveS3PathGenerator
Private bool
UploadToRTOSBucket bool
}

type AssetConfig struct {
Expand Down
3 changes: 1 addition & 2 deletions release/cli/pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ const (
// 01/02 03:04:05PM '06 -0700
//
// (January 2, 15:04:05, 2006, in time zone seven hours west of GMT).
YYYYMMDD = "2006-01-02"
RTOSArtifactsBucketEnvvar = "RTOS_ARTIFACTS_BUCKET"
YYYYMMDD = "2006-01-02"
)
21 changes: 0 additions & 21 deletions release/cli/pkg/filereader/file_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,24 +365,3 @@ func ReadGitTag(projectPath, gitRootPath, branch string) (string, error) {

return gitTag, nil
}

func ReadRTOSImageDate(projectPath, gitRootPath, branch string) (string, error) {
currentBranch, err := git.GetCurrentBranch(gitRootPath)
if err != nil {
return "", fmt.Errorf("error getting current branch: %v", err)
}
if currentBranch != branch {
_, err = git.CheckoutRepo(gitRootPath, branch)
if err != nil {
return "", fmt.Errorf("error checking out repo: %v", err)
}
}

dateFile := filepath.Join(gitRootPath, projectPath, "RTOS_IMAGE_DATE")
releaseDate, err := ReadFileContentsTrimmed(dateFile)
if err != nil {
return "", fmt.Errorf("error reading RTOS image date: %v", err)
}

return releaseDate, nil
}
Loading

0 comments on commit be5e6ac

Please sign in to comment.