Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/google.golang.org/pr…
Browse files Browse the repository at this point in the history
…otobuf-1.33.0
  • Loading branch information
satr authored Apr 25, 2024
2 parents 7c997d1 + 6ba1912 commit 9231023
Show file tree
Hide file tree
Showing 23 changed files with 1,331 additions and 74 deletions.
93 changes: 93 additions & 0 deletions cmd/createApplyConfigPipelineJob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright © 2023
//
// Licensed 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 cmd

import (
"errors"

"github.com/equinor/radix-cli/generated-client/client/application"
"github.com/equinor/radix-cli/generated-client/models"
"github.com/equinor/radix-cli/pkg/client"
"github.com/equinor/radix-cli/pkg/flagnames"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

var createApplyConfigPipelineJobCmd = &cobra.Command{
Use: "apply-config",
Short: "Will trigger apply-config of a Radix application",
Long: "Triggers applyConfig of a Radix application according to the radix config in its repository's master branch.",
Example: ` # Create a Radix pipeline apply-config job to apply the radixconfig properties without re-building or re-deploying components.
Currently applied changes in properties DNS alias, build secrets, create new or soft-delete existing environments.
rx create job apply-config --application radix-test
# Create a Radix pipeline applyConfig-only job, short option versions
rx create job apply-config -a radix-test`,
RunE: func(cmd *cobra.Command, args []string) error {
var errs []error
appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application)
if err != nil {
errs = append(errs, err)
}
triggeredByUser, err := cmd.Flags().GetString(flagnames.User)
if err != nil {
errs = append(errs, err)
}
follow, err := cmd.Flags().GetBool(flagnames.Follow)
if err != nil {
errs = append(errs, err)
}
if len(errs) > 0 {
return errors.Join(errs...)
}
if appName == nil || *appName == "" {
return errors.New("application name is required")
}

cmd.SilenceUsage = true

apiClient, err := client.GetForCommand(cmd)
if err != nil {
return err
}

triggerPipelineParams := application.NewTriggerPipelineApplyConfigParams()
triggerPipelineParams.SetAppName(*appName)
parametersApplyConfig := models.PipelineParametersApplyConfig{
TriggeredBy: triggeredByUser,
}
triggerPipelineParams.SetPipelineParametersApplyConfig(&parametersApplyConfig)

newJob, err := apiClient.Application.TriggerPipelineApplyConfig(triggerPipelineParams, nil)
if err != nil {
return err
}

jobName := newJob.GetPayload().Name
log.Infof("Apply-config pipeline job triggered with the name %s\n", jobName)
if !follow {
return nil
}
return getLogsJob(cmd, apiClient, *appName, jobName)
},
}

func init() {
createJobCmd.AddCommand(createApplyConfigPipelineJobCmd)
createApplyConfigPipelineJobCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to apply-config")
createApplyConfigPipelineJobCmd.Flags().StringP(flagnames.User, "u", "", "The user who triggered the apply-config")
createApplyConfigPipelineJobCmd.Flags().BoolP(flagnames.Follow, "f", false, "Follow applyConfig")
setContextSpecificPersistentFlags(createApplyConfigPipelineJobCmd)
}
6 changes: 4 additions & 2 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package cmd

import (
"github.com/equinor/radix-cli/pkg/client"
"github.com/equinor/radix-cli/pkg/flagnames"
"github.com/spf13/cobra"
)

Expand All @@ -25,10 +26,10 @@ var loginCmd = &cobra.Command{
Short: "Login to Radix",
Long: `Login to Radix.`,
RunE: func(cmd *cobra.Command, args []string) error {

cmd.SilenceUsage = true

err := client.LoginCommand(cmd)
useDeviceCode, _ := cmd.Flags().GetBool(flagnames.UseDeviceCode)
err := client.LoginCommand(cmd, useDeviceCode)
if err != nil {
return err
}
Expand All @@ -39,5 +40,6 @@ var loginCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(loginCmd)
loginCmd.Flags().Bool(flagnames.UseDeviceCode, false, "Use CLI's old authentication flow based on device code. The device code flow does not work for compliant device policy enabled accounts.")
setVerbosePersistentFlag(loginCmd)
}
41 changes: 41 additions & 0 deletions generated-client/client/application/application_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9231023

Please sign in to comment.