-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from mbussolotto/ptf
add upgrade and support ptf command
- Loading branch information
Showing
49 changed files
with
1,604 additions
and
515 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
//go:build !ptf | ||
|
||
package ptf | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
// NewCommand is the command for creates supportptf. | ||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
return nil | ||
} |
This file contains 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,47 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
//go:build ptf | ||
|
||
package podman | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
mgradm_utils "github.com/uyuni-project/uyuni-tools/mgradm/shared/utils" | ||
. "github.com/uyuni-project/uyuni-tools/shared/l10n" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
type podmanPTFFlags struct { | ||
Image types.ImageFlags `mapstructure:",squash"` | ||
PTFId string `mapstructure:"ptf"` | ||
TestId string `mapstructure:"test"` | ||
CustomerId string `mapstructure:"user"` | ||
} | ||
|
||
// NewCommand for podman installation. | ||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
podmanCmd := &cobra.Command{ | ||
Use: "podman", | ||
|
||
Short: L("Install a PTF or Test package on podman"), | ||
Long: L(`Install a PTF or Test package on podman | ||
The support ptf podman command assumes podman is installed locally and | ||
the host machine is register to SCC. | ||
NOTE: for now installing on a remote podman is not supported! | ||
`), | ||
Args: cobra.MaximumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var flags podmanPTFFlags | ||
return utils.CommandHelper(globalFlags, cmd, args, &flags, ptfForPodman) | ||
}, | ||
} | ||
|
||
mgradm_utils.AddImagePTFlag(podmanCmd) | ||
utils.AddPTFFlag(podmanCmd) | ||
|
||
return podmanCmd | ||
} |
This file contains 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,60 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
//go:build ptf | ||
|
||
package podman | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/rs/zerolog/log" | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/mgradm/shared/podman" | ||
. "github.com/uyuni-project/uyuni-tools/shared/l10n" | ||
podman_shared "github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
func ptfForPodman( | ||
globalFlags *types.GlobalFlags, | ||
flags *podmanPTFFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
//we don't want to perform a postgres version upgrade when installing a PTF. | ||
//in that case, we can use the upgrade command. | ||
dummyMigration := types.ImageFlags{} | ||
if err := flags.checkParameters(); err != nil { | ||
return err | ||
} | ||
return podman.Upgrade(flags.Image, dummyMigration, args) | ||
} | ||
|
||
func (flags *podmanPTFFlags) checkParameters() error { | ||
if flags.TestId != "" && flags.PTFId != "" { | ||
return errors.New(L("ptf and test flags cannot be set simultaneously ")) | ||
} | ||
if flags.TestId == "" && flags.PTFId == "" { | ||
return errors.New(L("ptf and test flags cannot be empty simultaneously ")) | ||
} | ||
if flags.CustomerId == "" { | ||
return errors.New(L("user flag cannot be empty")) | ||
} | ||
serverImage, err := podman_shared.GetRunningImage(podman_shared.ServerContainerName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
suffix := "ptf" | ||
if flags.TestId != "" { | ||
suffix = "test" | ||
} | ||
flags.Image.Name, err = utils.ComputePTF(flags.CustomerId, flags.PTFId, serverImage, suffix) | ||
if err != nil { | ||
return err | ||
} | ||
log.Info().Msgf(L("The image computed is: %s"), flags.Image.Name) | ||
return nil | ||
} |
Oops, something went wrong.