diff --git a/.github/workflows/databases.yml b/.github/workflows/databases.yml index 69c778b..59e81e8 100644 --- a/.github/workflows/databases.yml +++ b/.github/workflows/databases.yml @@ -32,8 +32,6 @@ jobs: run: | ./bin/apppack create region --region us-east-2 \ --aws-credentials \ - --dockerhub-username $DOCKERHUB_USERNAME \ - --dockerhub-access-token $DOCKERHUB_ACCESS_TOKEN \ --non-interactive ./bin/apppack create cluster --region us-east-2 \ --aws-credentials \ @@ -41,8 +39,6 @@ jobs: --non-interactive timeout-minutes: 15 env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} standard-mysql: diff --git a/.github/workflows/functional_tests.yml b/.github/workflows/functional_tests.yml index 434dc4b..91dfbdb 100644 --- a/.github/workflows/functional_tests.yml +++ b/.github/workflows/functional_tests.yml @@ -49,14 +49,10 @@ jobs: --aws-credentials \ --region us-east-1 \ --create-region \ - --dockerhub-username $DOCKERHUB_USERNAME \ - --dockerhub-access-token $DOCKERHUB_ACCESS_TOKEN \ --domain testclusters.apppack.io \ --non-interactive timeout-minutes: 20 env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c7459a..9aa41d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] - 2024-10-XX + +## [Unreleased] - TBD ### Fixed * Verify existence of review app before resizing process with `ps resize`. +### Removed + +* Region creation no longer requires Docker Hub credentials + ## [4.6.2] - 2024-09-03 ### Fixed diff --git a/cmd/create.go b/cmd/create.go index 6a3c7bd..3652990 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -379,11 +379,4 @@ func init() { createDatabaseCmd.Flags().Int("max-allocated-storage", stacks.DefaultDatabaseStackParameters.MaxAllocatedStorage, "maximum storage allocated on-demand in GB (does not apply to Aurora engines)") createCmd.AddCommand(createRegionCmd) - createRegionCmd.Flags().String("dockerhub-username", "", "Docker Hub username") - createRegionCmd.Flags().String("dockerhub-access-token", "", "Docker Hub Access Token (https://hub.docker.com/settings/security)") - // All flags need to be added to `createCluster` as well so it can call this cmd - createClusterCmd.Flags().String("dockerhub-username", "", "Docker Hub username") - createClusterCmd.Flags().String("dockerhub-access-token", "", "Docker Hub Access Token (https://hub.docker.com/settings/security)") - createClusterCmd.Flags().MarkHidden("dockerhub-username") - createClusterCmd.Flags().MarkHidden("dockerhub-access-token") } diff --git a/stacks/region.go b/stacks/region.go index 95cf98d..9d3da1a 100644 --- a/stacks/region.go +++ b/stacks/region.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/AlecAivazis/survey/v2" "github.com/apppackio/apppack/ui" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" @@ -15,8 +14,6 @@ import ( ) type RegionStackParameters struct { - DockerhubUsername string `flag:"dockerhub-username"` - DockerhubAccessToken string `flag:"dockerhub-access-token"` } func (p *RegionStackParameters) Import(parameters []*cloudformation.Parameter) error { @@ -24,52 +21,11 @@ func (p *RegionStackParameters) Import(parameters []*cloudformation.Parameter) e } func (p *RegionStackParameters) ToCloudFormationParameters() ([]*cloudformation.Parameter, error) { - cfnParams, err := StructToCloudformationParameters(p) - if err != nil { - return nil, err - } - // pop DockerhubAccessToken from the list of parameters - // it is stored in SSM instead of getting directly passed to CloudFormation - accessTokenIndex := -1 - - for i, param := range cfnParams { - if *param.ParameterKey == "DockerhubAccessToken" { - accessTokenIndex = i - - break - } - } - if accessTokenIndex == -1 { - return nil, fmt.Errorf("DockerhubAccessToken not found in parameters") - } - return append(cfnParams[:accessTokenIndex], cfnParams[accessTokenIndex+1:]...), nil + return StructToCloudformationParameters(p) } // SetInternalFields updates fields that aren't exposed to the user -func (p *RegionStackParameters) SetInternalFields(sess *session.Session, name *string) error { - ui.StartSpinner() - parameterName := "/apppack/account/dockerhub-access-token" - ssmSvc := ssm.New(sess) - // Verify that DockerhubAccessToken exists if it's not set - if p.DockerhubAccessToken == "" { - logrus.WithFields(logrus.Fields{"parameter": parameterName}).Debug("getting parameter from SSM") - _, err := ssmSvc.GetParameter(&ssm.GetParameterInput{Name: ¶meterName}) - ui.Spinner.Stop() - return err - } - _, err := ssmSvc.PutParameter(&ssm.PutParameterInput{ - Name: ¶meterName, - Value: &p.DockerhubAccessToken, - Type: aws.String("SecureString"), - Tags: []*ssm.Tag{ - {Key: aws.String("apppack:region"), Value: name}, - {Key: aws.String("apppack"), Value: aws.String("true")}, - }, - }) - if err != nil { - return err - } - ui.Spinner.Stop() +func (*RegionStackParameters) SetInternalFields(_ *session.Session, _ *string) error { return nil } @@ -99,10 +55,16 @@ func (*RegionStack) PreDelete(_ *session.Session) error { } func (*RegionStack) PostDelete(sess *session.Session, _ *string) error { + // Stacks before `formations/5.8.0` used this parameter ssmSvc := ssm.New(sess) _, err := ssmSvc.DeleteParameter(&ssm.DeleteParameterInput{ Name: aws.String("/apppack/account/dockerhub-access-token"), }) + // Ignore error if the parameter doesn't exist + if err != nil && !strings.Contains(err.Error(), "ParameterNotFound") { + logrus.WithError(err).Debug("dockerhub-access-token parameter does not exist") + return nil + } return err } @@ -110,30 +72,8 @@ func (a *RegionStack) UpdateFromFlags(flags *pflag.FlagSet) error { return ui.FlagsToStruct(a.Parameters, flags) } -func (a *RegionStack) AskQuestions(_ *session.Session) error { - questions := []*ui.QuestionExtra{ - { - Verbose: "What is your Docker Hub username?", - HelpText: "App images will be created using base images from Docker Hub. " + - "To avoid hitting rate limits during the build process, a free Docker Hub account is required. " + - "See https://docs.docker.com/docker-hub/download-rate-limit/ for more info.", - Question: &survey.Question{ - Name: "DockerhubUsername", - Prompt: &survey.Input{Message: "Docker Hub Username", Default: a.Parameters.DockerhubUsername}, - Validate: survey.Required, - }, - }, - { - Verbose: "What is your Docker Hub access token?", - HelpText: "An access token for your Docker Hub account can be generated at https://hub.docker.com/settings/security.", - Question: &survey.Question{ - Name: "DockerhubAccessToken", - Prompt: &survey.Password{Message: "Docker Hub Access Token"}, - Validate: survey.Required, - }, - }, - } - return ui.AskQuestions(questions, a.Parameters) +func (*RegionStack) AskQuestions(_ *session.Session) error { + return nil } func (*RegionStack) StackName(name *string) *string {